@radix-ng/primitives 0.20.2 → 0.22.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.
- package/avatar/src/avatar-fallback.directive.d.ts +1 -1
- package/avatar/src/avatar-image.directive.d.ts +3 -3
- package/compodoc/documentation.json +6879 -2567
- package/core/index.d.ts +1 -0
- package/core/src/id-generator.d.ts +12 -0
- package/esm2022/avatar/src/avatar-fallback.directive.mjs +6 -8
- package/esm2022/avatar/src/avatar-image.directive.mjs +4 -3
- package/esm2022/core/index.mjs +2 -1
- package/esm2022/core/src/create-inject-context/index.mjs +2 -2
- package/esm2022/core/src/id-generator.mjs +43 -0
- package/esm2022/popover/index.mjs +14 -4
- package/esm2022/popover/src/popover-anchor.directive.mjs +70 -0
- package/esm2022/popover/src/popover-anchor.token.mjs +3 -0
- package/esm2022/popover/src/popover-arrow.directive.mjs +12 -7
- package/esm2022/popover/src/popover-close.directive.mjs +16 -4
- package/esm2022/popover/src/popover-close.token.mjs +3 -0
- package/esm2022/popover/src/popover-content-attributes.component.mjs +70 -0
- package/esm2022/popover/src/popover-content-attributes.token.mjs +3 -0
- package/esm2022/popover/src/popover-content.directive.mjs +120 -84
- package/esm2022/popover/src/popover-root.directive.mjs +232 -64
- package/esm2022/popover/src/popover-root.inject.mjs +4 -4
- package/esm2022/popover/src/popover-trigger.directive.mjs +5 -7
- package/esm2022/popover/src/popover.types.mjs +18 -1
- package/esm2022/popover/src/popover.utils.mjs +4 -6
- package/esm2022/switch/src/switch-input.directive.mjs +16 -7
- package/esm2022/switch/src/switch-root.directive.mjs +59 -14
- package/esm2022/switch/src/switch-thumb.directive.mjs +3 -3
- package/esm2022/tabs/index.mjs +3 -6
- package/esm2022/tabs/src/tabs-content.directive.mjs +14 -8
- package/esm2022/tabs/src/tabs-list.directive.mjs +9 -6
- package/esm2022/tabs/src/tabs-root.directive.mjs +40 -37
- package/esm2022/tabs/src/tabs-trigger.directive.mjs +43 -17
- package/esm2022/tabs/src/utils.mjs +7 -0
- package/esm2022/toggle/index.mjs +2 -2
- package/esm2022/toggle/src/toggle-visually-hidden-input.directive.mjs +31 -0
- package/esm2022/toggle/src/toggle.directive.mjs +39 -8
- package/esm2022/toggle-group/src/toggle-group-item.directive.mjs +4 -3
- package/fesm2022/radix-ng-primitives-avatar.mjs +8 -9
- package/fesm2022/radix-ng-primitives-avatar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-core.mjs +44 -3
- package/fesm2022/radix-ng-primitives-core.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-popover.mjs +672 -303
- package/fesm2022/radix-ng-primitives-popover.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-switch.mjs +76 -22
- package/fesm2022/radix-ng-primitives-switch.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-tabs.mjs +109 -109
- package/fesm2022/radix-ng-primitives-tabs.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toggle-group.mjs +3 -2
- package/fesm2022/radix-ng-primitives-toggle-group.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toggle.mjs +47 -15
- package/fesm2022/radix-ng-primitives-toggle.mjs.map +1 -1
- package/package.json +1 -1
- package/popover/index.d.ts +5 -1
- package/popover/src/popover-anchor.directive.d.ts +28 -0
- package/popover/src/popover-anchor.token.d.ts +3 -0
- package/popover/src/popover-arrow.directive.d.ts +8 -5
- package/popover/src/popover-close.directive.d.ts +1 -1
- package/popover/src/popover-close.token.d.ts +3 -0
- package/popover/src/popover-content-attributes.component.d.ts +17 -0
- package/popover/src/popover-content-attributes.token.d.ts +3 -0
- package/popover/src/popover-content.directive.d.ts +36 -23
- package/popover/src/popover-root.directive.d.ts +89 -18
- package/popover/src/popover-root.inject.d.ts +2 -1
- package/popover/src/popover-trigger.directive.d.ts +3 -5
- package/popover/src/popover.types.d.ts +14 -3
- package/switch/src/switch-input.directive.d.ts +2 -0
- package/switch/src/switch-root.directive.d.ts +33 -5
- package/tabs/index.d.ts +0 -1
- package/tabs/src/tabs-content.directive.d.ts +6 -1
- package/tabs/src/tabs-list.directive.d.ts +6 -2
- package/tabs/src/tabs-root.directive.d.ts +25 -9
- package/tabs/src/tabs-trigger.directive.d.ts +13 -3
- package/tabs/src/utils.d.ts +2 -0
- package/toggle/index.d.ts +2 -2
- package/toggle/src/toggle-visually-hidden-input.directive.d.ts +6 -0
- package/toggle/src/toggle.directive.d.ts +20 -2
- package/esm2022/popover/src/popover-root.token.mjs +0 -3
- package/esm2022/tabs/src/tabs-context.service.mjs +0 -43
- package/esm2022/toggle/src/toggle-input.directive.mjs +0 -30
- package/popover/src/popover-root.token.d.ts +0 -3
- package/tabs/src/tabs-context.service.d.ts +0 -22
- package/toggle/src/toggle-input.directive.d.ts +0 -6
@@ -1,19 +1,18 @@
|
|
1
1
|
import * as i0 from '@angular/core';
|
2
|
-
import { InjectionToken,
|
3
|
-
import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
2
|
+
import { InjectionToken, inject, TemplateRef, DestroyRef, computed, input, output, effect, untracked, SimpleChange, Directive, ElementRef, signal, booleanAttribute, contentChild, ViewContainerRef, afterNextRender, isDevMode, assertInInjectionContext, forwardRef, Renderer2, Component, ChangeDetectionStrategy, NgModule } from '@angular/core';
|
4
3
|
import * as i1 from '@angular/cdk/overlay';
|
5
4
|
import { Overlay, CdkConnectedOverlay, CdkOverlayOrigin } from '@angular/cdk/overlay';
|
6
|
-
import { filter, tap } from 'rxjs';
|
7
5
|
import { DOCUMENT } from '@angular/common';
|
6
|
+
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
|
7
|
+
import { filter, tap } from 'rxjs';
|
8
|
+
|
9
|
+
const RdxPopoverAnchorToken = new InjectionToken('RdxPopoverAnchorToken');
|
8
10
|
|
9
11
|
const RdxPopoverArrowToken = new InjectionToken('RdxPopoverArrowToken');
|
10
12
|
|
11
|
-
const
|
13
|
+
const RdxPopoverCloseToken = new InjectionToken('RdxPopoverCloseToken');
|
12
14
|
|
13
|
-
|
14
|
-
isDevMode() && assertInInjectionContext(injectPopoverRoot);
|
15
|
-
return inject(RdxPopoverRootToken);
|
16
|
-
}
|
15
|
+
const RdxPopoverContentAttributesToken = new InjectionToken('RdxPopoverContentAttributesToken');
|
17
16
|
|
18
17
|
var RdxPopoverSide;
|
19
18
|
(function (RdxPopoverSide) {
|
@@ -28,6 +27,23 @@ var RdxPopoverAlign;
|
|
28
27
|
RdxPopoverAlign["Center"] = "center";
|
29
28
|
RdxPopoverAlign["End"] = "end";
|
30
29
|
})(RdxPopoverAlign || (RdxPopoverAlign = {}));
|
30
|
+
var RdxPopoverState;
|
31
|
+
(function (RdxPopoverState) {
|
32
|
+
RdxPopoverState["OPEN"] = "open";
|
33
|
+
RdxPopoverState["CLOSED"] = "closed";
|
34
|
+
})(RdxPopoverState || (RdxPopoverState = {}));
|
35
|
+
var RdxPopoverAttachDetachEvent;
|
36
|
+
(function (RdxPopoverAttachDetachEvent) {
|
37
|
+
RdxPopoverAttachDetachEvent["ATTACH"] = "attach";
|
38
|
+
RdxPopoverAttachDetachEvent["DETACH"] = "detach";
|
39
|
+
})(RdxPopoverAttachDetachEvent || (RdxPopoverAttachDetachEvent = {}));
|
40
|
+
var RdxPopoverAnimationStatus;
|
41
|
+
(function (RdxPopoverAnimationStatus) {
|
42
|
+
RdxPopoverAnimationStatus["OPEN_STARTED"] = "open_started";
|
43
|
+
RdxPopoverAnimationStatus["OPEN_ENDED"] = "open_ended";
|
44
|
+
RdxPopoverAnimationStatus["CLOSED_STARTED"] = "closed_started";
|
45
|
+
RdxPopoverAnimationStatus["CLOSED_ENDED"] = "closed_ended";
|
46
|
+
})(RdxPopoverAnimationStatus || (RdxPopoverAnimationStatus = {}));
|
31
47
|
|
32
48
|
const POPOVER_POSITIONS = {
|
33
49
|
[RdxPopoverSide.Top]: {
|
@@ -186,9 +202,7 @@ function getContentPosition(sideAndAlignWithOffsets) {
|
|
186
202
|
function getArrowPositionParams(sideAndAlign, arrowWidthAndHeight, triggerWidthAndHeight) {
|
187
203
|
const posParams = {
|
188
204
|
top: '',
|
189
|
-
bottom: '',
|
190
205
|
left: '',
|
191
|
-
right: '',
|
192
206
|
transform: ''
|
193
207
|
};
|
194
208
|
if ([RdxPopoverSide.Top, RdxPopoverSide.Bottom].includes(sideAndAlign.side)) {
|
@@ -206,12 +220,12 @@ function getArrowPositionParams(sideAndAlign, arrowWidthAndHeight, triggerWidthA
|
|
206
220
|
posParams.left = `calc(50% - ${arrowWidthAndHeight.width / 2}px)`;
|
207
221
|
}
|
208
222
|
else if (sideAndAlign.align === RdxPopoverAlign.End) {
|
209
|
-
posParams.
|
223
|
+
posParams.left = `calc(100% - ${(triggerWidthAndHeight.width + arrowWidthAndHeight.width) / 2}px)`;
|
210
224
|
}
|
211
225
|
}
|
212
226
|
else if ([RdxPopoverSide.Left, RdxPopoverSide.Right].includes(sideAndAlign.side)) {
|
213
227
|
if (sideAndAlign.side === RdxPopoverSide.Left) {
|
214
|
-
posParams.
|
228
|
+
posParams.left = `100%`;
|
215
229
|
posParams.transform = `rotate(-90deg) translate(0, -50%)`;
|
216
230
|
}
|
217
231
|
else {
|
@@ -225,152 +239,12 @@ function getArrowPositionParams(sideAndAlign, arrowWidthAndHeight, triggerWidthA
|
|
225
239
|
posParams.top = `calc(50% - ${arrowWidthAndHeight.height / 2}px)`;
|
226
240
|
}
|
227
241
|
else if (sideAndAlign.align === RdxPopoverAlign.End) {
|
228
|
-
posParams.
|
242
|
+
posParams.top = `calc(100% - ${(triggerWidthAndHeight.height + arrowWidthAndHeight.height) / 2}px)`;
|
229
243
|
}
|
230
244
|
}
|
231
245
|
return posParams;
|
232
246
|
}
|
233
247
|
|
234
|
-
class RdxPopoverArrowDirective {
|
235
|
-
constructor() {
|
236
|
-
/** @ignore */
|
237
|
-
this.renderer = inject(Renderer2);
|
238
|
-
/** @ignore */
|
239
|
-
this.popoverRoot = injectPopoverRoot();
|
240
|
-
/** @ignore */
|
241
|
-
this.elementRef = inject(ElementRef);
|
242
|
-
/**
|
243
|
-
* The width of the arrow in pixels.
|
244
|
-
*/
|
245
|
-
this.width = input(10);
|
246
|
-
/**
|
247
|
-
* The height of the arrow in pixels.
|
248
|
-
*/
|
249
|
-
this.height = input(5);
|
250
|
-
/** @ignore */
|
251
|
-
this.arrowSvgElement = computed(() => {
|
252
|
-
const width = this.width();
|
253
|
-
const height = this.height();
|
254
|
-
const svgElement = this.renderer.createElement('svg', 'svg');
|
255
|
-
this.renderer.setAttribute(svgElement, 'viewBox', '0 0 30 10');
|
256
|
-
this.renderer.setAttribute(svgElement, 'width', String(width));
|
257
|
-
this.renderer.setAttribute(svgElement, 'height', String(height));
|
258
|
-
const polygonElement = this.renderer.createElement('polygon', 'svg');
|
259
|
-
this.renderer.setAttribute(polygonElement, 'points', '0,0 30,0 15,10');
|
260
|
-
this.renderer.setAttribute(svgElement, 'preserveAspectRatio', 'none');
|
261
|
-
this.renderer.appendChild(svgElement, polygonElement);
|
262
|
-
return svgElement;
|
263
|
-
});
|
264
|
-
/** @ignore */
|
265
|
-
this.currentArrowSvgElement = signal(void 0);
|
266
|
-
/** @ignore */
|
267
|
-
this.position = toSignal(this.popoverRoot.popoverContentDirective().positionChange());
|
268
|
-
this.onArrowSvgElementChangeEffect();
|
269
|
-
this.onContentPositionChangeEffect();
|
270
|
-
}
|
271
|
-
/** @ignore */
|
272
|
-
ngAfterViewInit() {
|
273
|
-
if (this.elementRef.nativeElement.parentElement) {
|
274
|
-
this.renderer.setStyle(this.elementRef.nativeElement.parentElement, 'position', 'relative');
|
275
|
-
}
|
276
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'position', 'absolute');
|
277
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'boxSizing', '');
|
278
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'fontSize', '0px');
|
279
|
-
this.triggerRect = this.popoverRoot.popoverTriggerDirective().elementRef.nativeElement.getBoundingClientRect();
|
280
|
-
}
|
281
|
-
/** @ignore */
|
282
|
-
setPosition(position) {
|
283
|
-
const posParams = getArrowPositionParams(getSideAndAlignFromAllPossibleConnectedPositions(position.connectionPair), { width: this.width(), height: this.height() }, { width: this.triggerRect.width, height: this.triggerRect.height });
|
284
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'top', posParams.top);
|
285
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'bottom', posParams.bottom);
|
286
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'left', posParams.left);
|
287
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'right', posParams.right);
|
288
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'transform', posParams.transform);
|
289
|
-
}
|
290
|
-
/** @ignore */
|
291
|
-
onArrowSvgElementChangeEffect() {
|
292
|
-
effect(() => {
|
293
|
-
const arrowElement = this.arrowSvgElement();
|
294
|
-
untracked(() => {
|
295
|
-
const currentArrowSvgElement = this.currentArrowSvgElement();
|
296
|
-
if (currentArrowSvgElement) {
|
297
|
-
this.renderer.removeChild(this.elementRef.nativeElement, currentArrowSvgElement);
|
298
|
-
}
|
299
|
-
this.currentArrowSvgElement.set(arrowElement);
|
300
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'width', `${this.width()}px`);
|
301
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'height', `${this.height()}px`);
|
302
|
-
this.renderer.appendChild(this.elementRef.nativeElement, this.currentArrowSvgElement());
|
303
|
-
});
|
304
|
-
});
|
305
|
-
}
|
306
|
-
/** @ignore */
|
307
|
-
onContentPositionChangeEffect() {
|
308
|
-
effect(() => {
|
309
|
-
const position = this.position();
|
310
|
-
untracked(() => {
|
311
|
-
if (!position) {
|
312
|
-
return;
|
313
|
-
}
|
314
|
-
this.setPosition(position);
|
315
|
-
});
|
316
|
-
});
|
317
|
-
}
|
318
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverArrowDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
319
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.11", type: RdxPopoverArrowDirective, isStandalone: true, selector: "[rdxPopoverArrow]", inputs: { width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
320
|
-
{
|
321
|
-
provide: RdxPopoverArrowToken,
|
322
|
-
useExisting: forwardRef(() => RdxPopoverArrowDirective)
|
323
|
-
}
|
324
|
-
], ngImport: i0 }); }
|
325
|
-
}
|
326
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverArrowDirective, decorators: [{
|
327
|
-
type: Directive,
|
328
|
-
args: [{
|
329
|
-
selector: '[rdxPopoverArrow]',
|
330
|
-
standalone: true,
|
331
|
-
providers: [
|
332
|
-
{
|
333
|
-
provide: RdxPopoverArrowToken,
|
334
|
-
useExisting: forwardRef(() => RdxPopoverArrowDirective)
|
335
|
-
}
|
336
|
-
]
|
337
|
-
}]
|
338
|
-
}], ctorParameters: () => [] });
|
339
|
-
|
340
|
-
class RdxPopoverCloseDirective {
|
341
|
-
constructor() {
|
342
|
-
/** @ignore */
|
343
|
-
this.popoverRoot = injectPopoverRoot();
|
344
|
-
/** @ignore */
|
345
|
-
this.elementRef = inject(ElementRef);
|
346
|
-
/** @ignore */
|
347
|
-
this.renderer = inject(Renderer2);
|
348
|
-
this.onIsControlledExternallyEffect();
|
349
|
-
}
|
350
|
-
/** @ignore */
|
351
|
-
onIsControlledExternallyEffect() {
|
352
|
-
effect(() => {
|
353
|
-
const isControlledExternally = this.popoverRoot.controlledExternally()();
|
354
|
-
untracked(() => {
|
355
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'display', isControlledExternally ? 'none' : null);
|
356
|
-
});
|
357
|
-
});
|
358
|
-
}
|
359
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverCloseDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
360
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.11", type: RdxPopoverCloseDirective, isStandalone: true, selector: "[rdxPopoverClose]", host: { attributes: { "type": "button" }, listeners: { "click": "popoverRoot.handleClose()" } }, ngImport: i0 }); }
|
361
|
-
}
|
362
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverCloseDirective, decorators: [{
|
363
|
-
type: Directive,
|
364
|
-
args: [{
|
365
|
-
selector: '[rdxPopoverClose]',
|
366
|
-
standalone: true,
|
367
|
-
host: {
|
368
|
-
type: 'button',
|
369
|
-
'(click)': 'popoverRoot.handleClose()'
|
370
|
-
}
|
371
|
-
}]
|
372
|
-
}], ctorParameters: () => [] });
|
373
|
-
|
374
248
|
class RdxPopoverContentDirective {
|
375
249
|
constructor() {
|
376
250
|
/** @ignore */
|
@@ -383,81 +257,56 @@ class RdxPopoverContentDirective {
|
|
383
257
|
this.destroyRef = inject(DestroyRef);
|
384
258
|
/** @ignore */
|
385
259
|
this.connectedOverlay = inject(CdkConnectedOverlay);
|
260
|
+
/** @ignore */
|
261
|
+
this.name = computed(() => `rdx-popover-trigger-${this.popoverRoot.uniqueId()}`);
|
386
262
|
/**
|
387
|
-
* The preferred side of the trigger to render against when open. Will be reversed when collisions occur and avoidCollisions is enabled.
|
263
|
+
* @description The preferred side of the trigger to render against when open. Will be reversed when collisions occur and avoidCollisions is enabled.
|
264
|
+
* @default top
|
388
265
|
*/
|
389
266
|
this.side = input(RdxPopoverSide.Top);
|
390
267
|
/**
|
391
|
-
* The distance in pixels from the trigger.
|
268
|
+
* @description The distance in pixels from the trigger.
|
269
|
+
* @default undefined
|
392
270
|
*/
|
393
271
|
this.sideOffset = input(void 0);
|
394
272
|
/**
|
395
|
-
* The preferred alignment against the trigger. May change when collisions occur.
|
273
|
+
* @description The preferred alignment against the trigger. May change when collisions occur.
|
274
|
+
* @default center
|
396
275
|
*/
|
397
276
|
this.align = input(RdxPopoverAlign.Center);
|
398
277
|
/**
|
399
|
-
* An offset in pixels from the "start" or "end" alignment options.
|
278
|
+
* @description An offset in pixels from the "start" or "end" alignment options.
|
279
|
+
* @default undefined
|
400
280
|
*/
|
401
281
|
this.alignOffset = input(void 0);
|
402
282
|
/**
|
403
|
-
* Whether to add some alternate positions of the content.
|
283
|
+
* @description Whether to add some alternate positions of the content.
|
284
|
+
* @default false
|
404
285
|
*/
|
405
286
|
this.disableAlternatePositions = input(false);
|
406
|
-
/** @ingore */
|
407
|
-
this.positions = computed(() => {
|
408
|
-
const greatestDimensionFromTheArrow = Math.max(this.popoverRoot.popoverArrowDirective()?.width() ?? 0, this.popoverRoot.popoverArrowDirective()?.height() ?? 0);
|
409
|
-
const offsets = {
|
410
|
-
sideOffset: this.sideOffset() ?? (greatestDimensionFromTheArrow || DEFAULTS.offsets.side),
|
411
|
-
alignOffset: this.alignOffset() ?? DEFAULTS.offsets.align
|
412
|
-
};
|
413
|
-
const basePosition = getContentPosition({
|
414
|
-
side: this.side(),
|
415
|
-
align: this.align(),
|
416
|
-
sideOffset: offsets.sideOffset,
|
417
|
-
alignOffset: offsets.alignOffset
|
418
|
-
});
|
419
|
-
const positions = [basePosition];
|
420
|
-
if (!this.disableAlternatePositions()) {
|
421
|
-
/**
|
422
|
-
* Alternate positions for better user experience along the X/Y axis (e.g. vertical/horizontal scrolling)
|
423
|
-
*/
|
424
|
-
const allPossibleConnectedPositions = getAllPossibleConnectedPositions();
|
425
|
-
allPossibleConnectedPositions.forEach((_, key) => {
|
426
|
-
const sideAndAlignArray = key.split('|');
|
427
|
-
if (sideAndAlignArray[0] !== this.side() ||
|
428
|
-
sideAndAlignArray[1] !== this.align()) {
|
429
|
-
positions.push(getContentPosition({
|
430
|
-
side: sideAndAlignArray[0],
|
431
|
-
align: sideAndAlignArray[1],
|
432
|
-
sideOffset: offsets.sideOffset,
|
433
|
-
alignOffset: offsets.alignOffset
|
434
|
-
}));
|
435
|
-
}
|
436
|
-
});
|
437
|
-
}
|
438
|
-
return positions;
|
439
|
-
});
|
440
287
|
/**
|
441
|
-
* Event handler called when the escape key is down. It can be prevented by calling event.preventDefault.
|
288
|
+
* @description Event handler called when the escape key is down. It can be prevented by calling event.preventDefault.
|
442
289
|
*/
|
443
290
|
this.onEscapeKeyDown = output();
|
444
291
|
/**
|
445
|
-
* Event handler called when a pointer event occurs outside the bounds of the component. It can be prevented by calling event.preventDefault.
|
292
|
+
* @description Event handler called when a pointer event occurs outside the bounds of the component. It can be prevented by calling event.preventDefault.
|
446
293
|
*/
|
447
|
-
this.
|
294
|
+
this.onOutsideClick = output();
|
448
295
|
/**
|
449
|
-
* Event handler called
|
296
|
+
* @description Event handler called after the overlay is open
|
450
297
|
*/
|
451
|
-
this.
|
298
|
+
this.onOpen = output();
|
452
299
|
/**
|
453
|
-
* Event handler called
|
300
|
+
* @description Event handler called after the overlay is closed
|
454
301
|
*/
|
455
|
-
this.
|
302
|
+
this.onClosed = output();
|
303
|
+
/** @ingore */
|
304
|
+
this.positions = computed(() => this.computePositions());
|
305
|
+
this.onOriginChangeEffect();
|
456
306
|
this.onPositionChangeEffect();
|
457
307
|
}
|
458
308
|
/** @ignore */
|
459
309
|
ngOnInit() {
|
460
|
-
this.setOrigin();
|
461
310
|
this.setScrollStrategy();
|
462
311
|
this.setDisableClose();
|
463
312
|
this.onAttach();
|
@@ -466,20 +315,22 @@ class RdxPopoverContentDirective {
|
|
466
315
|
this.connectOutsideClick();
|
467
316
|
}
|
468
317
|
/** @ignore */
|
469
|
-
|
318
|
+
open() {
|
319
|
+
if (this.connectedOverlay.open) {
|
320
|
+
return;
|
321
|
+
}
|
470
322
|
const prevOpen = this.connectedOverlay.open;
|
471
323
|
this.connectedOverlay.open = true;
|
472
|
-
|
473
|
-
this.connectedOverlay.ngOnChanges({ open: new SimpleChange(prevOpen, true, false) });
|
474
|
-
}
|
324
|
+
this.fireOverlayNgOnChanges('open', this.connectedOverlay.open, prevOpen);
|
475
325
|
}
|
476
326
|
/** @ignore */
|
477
|
-
|
327
|
+
close() {
|
328
|
+
if (!this.connectedOverlay.open) {
|
329
|
+
return;
|
330
|
+
}
|
478
331
|
const prevOpen = this.connectedOverlay.open;
|
479
332
|
this.connectedOverlay.open = false;
|
480
|
-
|
481
|
-
this.connectedOverlay.ngOnChanges({ open: new SimpleChange(prevOpen, false, false) });
|
482
|
-
}
|
333
|
+
this.fireOverlayNgOnChanges('open', this.connectedOverlay.open, prevOpen);
|
483
334
|
}
|
484
335
|
/** @ignore */
|
485
336
|
positionChange() {
|
@@ -491,9 +342,8 @@ class RdxPopoverContentDirective {
|
|
491
342
|
.asObservable()
|
492
343
|
.pipe(filter((event) => event.key === 'Escape'), tap((event) => {
|
493
344
|
this.onEscapeKeyDown.emit(event);
|
494
|
-
|
495
|
-
|
496
|
-
}
|
345
|
+
}), filter((event) => !event.defaultPrevented && !this.popoverRoot.firstDefaultOpen()), tap(() => {
|
346
|
+
this.popoverRoot.handleClose();
|
497
347
|
}), takeUntilDestroyed(this.destroyRef))
|
498
348
|
.subscribe();
|
499
349
|
}
|
@@ -501,11 +351,20 @@ class RdxPopoverContentDirective {
|
|
501
351
|
connectOutsideClick() {
|
502
352
|
this.connectedOverlay.overlayOutsideClick
|
503
353
|
.asObservable()
|
504
|
-
.pipe(
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
354
|
+
.pipe(
|
355
|
+
/**
|
356
|
+
* Handle the situation when an anchor is added and the anchor becomes the origin of the overlay
|
357
|
+
* hence the trigger will be considered the outside element
|
358
|
+
*/
|
359
|
+
filter((event) => {
|
360
|
+
return (!this.popoverRoot.popoverAnchorDirective() ||
|
361
|
+
!this.popoverRoot
|
362
|
+
.popoverTriggerDirective()
|
363
|
+
.elementRef.nativeElement.contains(event.target));
|
364
|
+
}), tap((event) => {
|
365
|
+
this.onOutsideClick.emit(event);
|
366
|
+
}), filter((event) => !event.defaultPrevented && !this.popoverRoot.firstDefaultOpen()), tap(() => {
|
367
|
+
this.popoverRoot.handleClose();
|
509
368
|
}), takeUntilDestroyed(this.destroyRef))
|
510
369
|
.subscribe();
|
511
370
|
}
|
@@ -514,7 +373,10 @@ class RdxPopoverContentDirective {
|
|
514
373
|
this.connectedOverlay.attach
|
515
374
|
.asObservable()
|
516
375
|
.pipe(tap(() => {
|
517
|
-
|
376
|
+
/**
|
377
|
+
* `this.onOpen.emit();` is being delegated to the root directive due to the opening animation
|
378
|
+
*/
|
379
|
+
this.popoverRoot.attachDetachEvent.set(RdxPopoverAttachDetachEvent.ATTACH);
|
518
380
|
}), takeUntilDestroyed(this.destroyRef))
|
519
381
|
.subscribe();
|
520
382
|
}
|
@@ -523,7 +385,10 @@ class RdxPopoverContentDirective {
|
|
523
385
|
this.connectedOverlay.detach
|
524
386
|
.asObservable()
|
525
387
|
.pipe(tap(() => {
|
526
|
-
|
388
|
+
/**
|
389
|
+
* `this.onClosed.emit();` is being delegated to the root directive due to the closing animation
|
390
|
+
*/
|
391
|
+
this.popoverRoot.attachDetachEvent.set(RdxPopoverAttachDetachEvent.DETACH);
|
527
392
|
}), takeUntilDestroyed(this.destroyRef))
|
528
393
|
.subscribe();
|
529
394
|
}
|
@@ -531,24 +396,68 @@ class RdxPopoverContentDirective {
|
|
531
396
|
setScrollStrategy() {
|
532
397
|
const prevScrollStrategy = this.connectedOverlay.scrollStrategy;
|
533
398
|
this.connectedOverlay.scrollStrategy = this.overlay.scrollStrategies.reposition();
|
534
|
-
this.connectedOverlay.
|
535
|
-
scrollStrategy: new SimpleChange(prevScrollStrategy, this.connectedOverlay.scrollStrategy, false)
|
536
|
-
});
|
399
|
+
this.fireOverlayNgOnChanges('scrollStrategy', this.connectedOverlay.scrollStrategy, prevScrollStrategy);
|
537
400
|
}
|
538
401
|
/** @ignore */
|
539
402
|
setDisableClose() {
|
540
403
|
const prevDisableClose = this.connectedOverlay.disableClose;
|
541
404
|
this.connectedOverlay.disableClose = true;
|
542
|
-
this.connectedOverlay.
|
543
|
-
disableClose: new SimpleChange(prevDisableClose, this.connectedOverlay.disableClose, false)
|
544
|
-
});
|
405
|
+
this.fireOverlayNgOnChanges('disableClose', this.connectedOverlay.disableClose, prevDisableClose);
|
545
406
|
}
|
546
407
|
/** @ignore */
|
547
|
-
setOrigin() {
|
408
|
+
setOrigin(origin) {
|
548
409
|
const prevOrigin = this.connectedOverlay.origin;
|
549
|
-
this.connectedOverlay.origin =
|
550
|
-
this.connectedOverlay.
|
551
|
-
|
410
|
+
this.connectedOverlay.origin = origin;
|
411
|
+
this.fireOverlayNgOnChanges('origin', this.connectedOverlay.origin, prevOrigin);
|
412
|
+
}
|
413
|
+
/** @ignore */
|
414
|
+
setPositions(positions) {
|
415
|
+
const prevPositions = this.connectedOverlay.positions;
|
416
|
+
this.connectedOverlay.positions = positions;
|
417
|
+
this.fireOverlayNgOnChanges('positions', this.connectedOverlay.positions, prevPositions);
|
418
|
+
this.connectedOverlay.overlayRef?.updatePosition();
|
419
|
+
}
|
420
|
+
/** @ignore */
|
421
|
+
computePositions() {
|
422
|
+
const greatestDimensionFromTheArrow = Math.max(this.popoverRoot.popoverArrowDirective()?.width() ?? 0, this.popoverRoot.popoverArrowDirective()?.height() ?? 0);
|
423
|
+
const offsets = {
|
424
|
+
sideOffset: this.sideOffset() ?? (greatestDimensionFromTheArrow || DEFAULTS.offsets.side),
|
425
|
+
alignOffset: this.alignOffset() ?? DEFAULTS.offsets.align
|
426
|
+
};
|
427
|
+
const basePosition = getContentPosition({
|
428
|
+
side: this.side(),
|
429
|
+
align: this.align(),
|
430
|
+
sideOffset: offsets.sideOffset,
|
431
|
+
alignOffset: offsets.alignOffset
|
432
|
+
});
|
433
|
+
const positions = [basePosition];
|
434
|
+
if (!this.disableAlternatePositions()) {
|
435
|
+
/**
|
436
|
+
* Alternate positions for better user experience along the X/Y axis (e.g. vertical/horizontal scrolling)
|
437
|
+
*/
|
438
|
+
const allPossibleConnectedPositions = getAllPossibleConnectedPositions();
|
439
|
+
allPossibleConnectedPositions.forEach((_, key) => {
|
440
|
+
const sideAndAlignArray = key.split('|');
|
441
|
+
if (sideAndAlignArray[0] !== this.side() ||
|
442
|
+
sideAndAlignArray[1] !== this.align()) {
|
443
|
+
positions.push(getContentPosition({
|
444
|
+
side: sideAndAlignArray[0],
|
445
|
+
align: sideAndAlignArray[1],
|
446
|
+
sideOffset: offsets.sideOffset,
|
447
|
+
alignOffset: offsets.alignOffset
|
448
|
+
}));
|
449
|
+
}
|
450
|
+
});
|
451
|
+
}
|
452
|
+
return positions;
|
453
|
+
}
|
454
|
+
onOriginChangeEffect() {
|
455
|
+
effect(() => {
|
456
|
+
const origin = (this.popoverRoot.popoverAnchorDirective() ?? this.popoverRoot.popoverTriggerDirective())
|
457
|
+
.overlayOrigin;
|
458
|
+
untracked(() => {
|
459
|
+
this.setOrigin(origin);
|
460
|
+
});
|
552
461
|
});
|
553
462
|
}
|
554
463
|
/** @ignore */
|
@@ -557,17 +466,18 @@ class RdxPopoverContentDirective {
|
|
557
466
|
const positions = this.positions();
|
558
467
|
this.disableAlternatePositions();
|
559
468
|
untracked(() => {
|
560
|
-
|
561
|
-
this.connectedOverlay.positions = positions;
|
562
|
-
this.connectedOverlay.ngOnChanges({
|
563
|
-
positions: new SimpleChange(prevPositions, this.connectedOverlay.positions, false)
|
564
|
-
});
|
565
|
-
this.connectedOverlay.overlayRef?.updatePosition();
|
469
|
+
this.setPositions(positions);
|
566
470
|
});
|
567
471
|
});
|
568
472
|
}
|
473
|
+
/** @ignore */
|
474
|
+
fireOverlayNgOnChanges(input, currentValue, previousValue, firstChange = false) {
|
475
|
+
this.connectedOverlay.ngOnChanges({
|
476
|
+
[input]: new SimpleChange(previousValue, currentValue, firstChange)
|
477
|
+
});
|
478
|
+
}
|
569
479
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
570
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.11", type: RdxPopoverContentDirective, isStandalone: true, selector: "[rdxPopoverContent]", inputs: { side: { classPropertyName: "side", publicName: "side", isSignal: true, isRequired: false, transformFunction: null }, sideOffset: { classPropertyName: "sideOffset", publicName: "sideOffset", isSignal: true, isRequired: false, transformFunction: null }, align: { classPropertyName: "align", publicName: "align", isSignal: true, isRequired: false, transformFunction: null }, alignOffset: { classPropertyName: "alignOffset", publicName: "alignOffset", isSignal: true, isRequired: false, transformFunction: null }, disableAlternatePositions: { classPropertyName: "disableAlternatePositions", publicName: "disableAlternatePositions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onEscapeKeyDown: "onEscapeKeyDown",
|
480
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.11", type: RdxPopoverContentDirective, isStandalone: true, selector: "[rdxPopoverContent]", inputs: { side: { classPropertyName: "side", publicName: "side", isSignal: true, isRequired: false, transformFunction: null }, sideOffset: { classPropertyName: "sideOffset", publicName: "sideOffset", isSignal: true, isRequired: false, transformFunction: null }, align: { classPropertyName: "align", publicName: "align", isSignal: true, isRequired: false, transformFunction: null }, alignOffset: { classPropertyName: "alignOffset", publicName: "alignOffset", isSignal: true, isRequired: false, transformFunction: null }, disableAlternatePositions: { classPropertyName: "disableAlternatePositions", publicName: "disableAlternatePositions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onEscapeKeyDown: "onEscapeKeyDown", onOutsideClick: "onOutsideClick", onOpen: "onOpen", onClosed: "onClosed" }, hostDirectives: [{ directive: i1.CdkConnectedOverlay }], ngImport: i0 }); }
|
571
481
|
}
|
572
482
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverContentDirective, decorators: [{
|
573
483
|
type: Directive,
|
@@ -590,15 +500,13 @@ class RdxPopoverTriggerDirective {
|
|
590
500
|
this.overlayOrigin = inject(CdkOverlayOrigin);
|
591
501
|
/** @ignore */
|
592
502
|
this.name = computed(() => `rdx-popover-trigger-${this.popoverRoot.uniqueId()}`);
|
593
|
-
/** @ignore */
|
594
|
-
this.controlsId = computed(() => `rdx-popover-trigger-controls-${this.popoverRoot.uniqueId()}`);
|
595
503
|
}
|
596
504
|
/** @ignore */
|
597
|
-
|
505
|
+
click() {
|
598
506
|
this.popoverRoot.handleToggle();
|
599
507
|
}
|
600
508
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
601
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.11", type: RdxPopoverTriggerDirective, isStandalone: true, selector: "[rdxPopoverTrigger]", host: { attributes: { "type": "button" }, listeners: { "click": "
|
509
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.11", type: RdxPopoverTriggerDirective, isStandalone: true, selector: "[rdxPopoverTrigger]", host: { attributes: { "type": "button" }, listeners: { "click": "click()" }, properties: { "attr.id": "name()", "attr.aria-haspopup": "\"dialog\"", "attr.aria-expanded": "popoverRoot.isOpen()", "attr.aria-controls": "popoverRoot.popoverContentDirective().name()", "attr.data-state": "popoverRoot.state()" } }, hostDirectives: [{ directive: i1.CdkOverlayOrigin }], ngImport: i0 }); }
|
602
510
|
}
|
603
511
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverTriggerDirective, decorators: [{
|
604
512
|
type: Directive,
|
@@ -611,9 +519,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
|
|
611
519
|
'[attr.id]': 'name()',
|
612
520
|
'[attr.aria-haspopup]': '"dialog"',
|
613
521
|
'[attr.aria-expanded]': 'popoverRoot.isOpen()',
|
614
|
-
'[attr.aria-controls]': '
|
522
|
+
'[attr.aria-controls]': 'popoverRoot.popoverContentDirective().name()',
|
615
523
|
'[attr.data-state]': 'popoverRoot.state()',
|
616
|
-
'(click)': '
|
524
|
+
'(click)': 'click()'
|
617
525
|
}
|
618
526
|
}]
|
619
527
|
}] });
|
@@ -621,20 +529,47 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
|
|
621
529
|
let nextId = 0;
|
622
530
|
class RdxPopoverRootDirective {
|
623
531
|
constructor() {
|
532
|
+
/** @ignore */
|
624
533
|
this.uniqueId = signal(++nextId);
|
534
|
+
/** @ignore */
|
625
535
|
this.name = computed(() => `rdx-popover-root-${this.uniqueId()}`);
|
626
536
|
/**
|
627
|
-
* The
|
537
|
+
* @description The anchor directive that comes form outside the popover root
|
538
|
+
* @default undefined
|
539
|
+
*/
|
540
|
+
this.anchor = input(void 0);
|
541
|
+
/**
|
542
|
+
* @description The open state of the popover when it is initially rendered. Use when you do not need to control its open state.
|
543
|
+
* @default false
|
628
544
|
*/
|
629
545
|
this.defaultOpen = input(false);
|
630
546
|
/**
|
631
|
-
* The controlled
|
547
|
+
* @description The controlled state of the popover. `open` input take precedence of `defaultOpen` input.
|
548
|
+
* @default undefined
|
549
|
+
*/
|
550
|
+
this.open = input(void 0);
|
551
|
+
/**
|
552
|
+
* @description Whether to control the state of the popover from external. Use in conjunction with `open` input.
|
553
|
+
* @default undefined
|
632
554
|
*/
|
633
|
-
this.
|
555
|
+
this.externalControl = input(void 0);
|
634
556
|
/**
|
635
|
-
*
|
557
|
+
* @description Whether to take into account CSS opening/closing animations.
|
558
|
+
* @default false
|
636
559
|
*/
|
637
|
-
this.
|
560
|
+
this.cssAnimation = input(false, { transform: booleanAttribute });
|
561
|
+
/**
|
562
|
+
* @description Whether to take into account CSS opening animations. `cssAnimation` input must be set to 'true'
|
563
|
+
* @default false
|
564
|
+
*/
|
565
|
+
this.cssOpeningAnimation = input(false, { transform: booleanAttribute });
|
566
|
+
/**
|
567
|
+
* @description Whether to take into account CSS closing animations. `cssAnimation` input must be set to 'true'
|
568
|
+
* @default false
|
569
|
+
*/
|
570
|
+
this.cssClosingAnimation = input(false, { transform: booleanAttribute });
|
571
|
+
/** @ignore */
|
572
|
+
this.cssAnimationStatus = signal(null);
|
638
573
|
/** @ignore */
|
639
574
|
this.popoverContentDirective = contentChild.required(RdxPopoverContentDirective);
|
640
575
|
/** @ignore */
|
@@ -642,128 +577,558 @@ class RdxPopoverRootDirective {
|
|
642
577
|
/** @ignore */
|
643
578
|
this.popoverArrowDirective = contentChild(RdxPopoverArrowToken);
|
644
579
|
/** @ignore */
|
580
|
+
this.popoverCloseDirective = contentChild(RdxPopoverCloseToken);
|
581
|
+
/** @ignore */
|
582
|
+
this.popoverContentAttributesComponent = contentChild(RdxPopoverContentAttributesToken);
|
583
|
+
/** @ignore */
|
584
|
+
this.internalPopoverAnchorDirective = contentChild(RdxPopoverAnchorToken);
|
585
|
+
/** @ignore */
|
645
586
|
this.viewContainerRef = inject(ViewContainerRef);
|
646
587
|
/** @ignore */
|
647
|
-
this.
|
588
|
+
this.destroyRef = inject(DestroyRef);
|
648
589
|
/** @ignore */
|
649
|
-
this.
|
590
|
+
this.state = signal(RdxPopoverState.CLOSED);
|
650
591
|
/** @ignore */
|
651
|
-
this.
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
return 'closed';
|
657
|
-
});
|
592
|
+
this.attachDetachEvent = signal(RdxPopoverAttachDetachEvent.DETACH);
|
593
|
+
/** @ignore */
|
594
|
+
this.isFirstDefaultOpen = signal(false);
|
595
|
+
/** @ignore */
|
596
|
+
this.popoverAnchorDirective = computed(() => this.internalPopoverAnchorDirective() ?? this.anchor());
|
658
597
|
/** @ignore */
|
659
|
-
this.
|
598
|
+
this.onAnchorChangeEffect = () => {
|
599
|
+
effect(() => {
|
600
|
+
const anchor = this.anchor();
|
601
|
+
untracked(() => {
|
602
|
+
if (anchor) {
|
603
|
+
anchor.setPopoverRoot(this);
|
604
|
+
}
|
605
|
+
});
|
606
|
+
});
|
607
|
+
};
|
608
|
+
this.onStateChangeEffect();
|
609
|
+
this.onCssAnimationStatusChangeChangeEffect();
|
660
610
|
this.onOpenChangeEffect();
|
661
|
-
this.
|
611
|
+
this.onIsFirstDefaultOpenChangeEffect();
|
612
|
+
this.onAnchorChangeEffect();
|
613
|
+
this.emitOpenOrClosedEventEffect();
|
614
|
+
afterNextRender({
|
615
|
+
write: () => {
|
616
|
+
if (this.defaultOpen() && !this.open()) {
|
617
|
+
this.isFirstDefaultOpen.set(true);
|
618
|
+
}
|
619
|
+
}
|
620
|
+
});
|
662
621
|
}
|
663
622
|
/** @ignore */
|
664
|
-
|
665
|
-
|
666
|
-
this.
|
667
|
-
|
623
|
+
getAnimationParamsSnapshot() {
|
624
|
+
return {
|
625
|
+
cssAnimation: this.cssAnimation(),
|
626
|
+
cssOpeningAnimation: this.cssOpeningAnimation(),
|
627
|
+
cssClosingAnimation: this.cssClosingAnimation(),
|
628
|
+
cssAnimationStatus: this.cssAnimationStatus(),
|
629
|
+
attachDetachEvent: this.attachDetachEvent(),
|
630
|
+
state: this.state(),
|
631
|
+
canEmitOnOpenOrOnClosed: this.canEmitOnOpenOrOnClosed()
|
632
|
+
};
|
668
633
|
}
|
669
634
|
/** @ignore */
|
670
635
|
controlledExternally() {
|
671
|
-
return this.
|
636
|
+
return this.externalControl;
|
637
|
+
}
|
638
|
+
/** @ignore */
|
639
|
+
firstDefaultOpen() {
|
640
|
+
return this.isFirstDefaultOpen();
|
672
641
|
}
|
673
642
|
/** @ignore */
|
674
643
|
handleOpen() {
|
675
|
-
if (this.
|
644
|
+
if (this.externalControl()) {
|
676
645
|
return;
|
677
646
|
}
|
678
|
-
this.
|
647
|
+
this.setState(RdxPopoverState.OPEN);
|
679
648
|
}
|
680
649
|
/** @ignore */
|
681
650
|
handleClose() {
|
682
|
-
if (this.
|
651
|
+
if (this.isFirstDefaultOpen()) {
|
652
|
+
this.isFirstDefaultOpen.set(false);
|
653
|
+
}
|
654
|
+
if (this.externalControl()) {
|
683
655
|
return;
|
684
656
|
}
|
685
|
-
this.
|
657
|
+
this.setState(RdxPopoverState.CLOSED);
|
686
658
|
}
|
687
659
|
/** @ignore */
|
688
660
|
handleToggle() {
|
689
|
-
if (this.
|
661
|
+
if (this.externalControl()) {
|
690
662
|
return;
|
691
663
|
}
|
692
664
|
this.isOpen() ? this.handleClose() : this.handleOpen();
|
693
665
|
}
|
694
666
|
/** @ignore */
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
667
|
+
isOpen(state) {
|
668
|
+
return (state ?? this.state()) === RdxPopoverState.OPEN;
|
669
|
+
}
|
670
|
+
/** @ignore */
|
671
|
+
setState(state = RdxPopoverState.CLOSED) {
|
672
|
+
if (state === this.state()) {
|
673
|
+
return;
|
674
|
+
}
|
675
|
+
this.state.set(state);
|
676
|
+
}
|
677
|
+
/** @ignore */
|
678
|
+
openContent() {
|
679
|
+
this.popoverContentDirective().open();
|
680
|
+
if (!this.cssAnimation() || !this.cssOpeningAnimation()) {
|
681
|
+
this.cssAnimationStatus.set(null);
|
682
|
+
}
|
683
|
+
}
|
684
|
+
/** @ignore */
|
685
|
+
closeContent() {
|
686
|
+
this.popoverContentDirective().close();
|
687
|
+
if (!this.cssAnimation() || !this.cssClosingAnimation()) {
|
688
|
+
this.cssAnimationStatus.set(null);
|
689
|
+
}
|
690
|
+
}
|
691
|
+
/** @ignore */
|
692
|
+
emitOnOpen() {
|
693
|
+
this.popoverContentDirective().onOpen.emit();
|
694
|
+
}
|
695
|
+
/** @ignore */
|
696
|
+
emitOnClosed() {
|
697
|
+
this.popoverContentDirective().onClosed.emit();
|
698
|
+
}
|
699
|
+
/** @ignore */
|
700
|
+
ifOpenOrCloseWithoutAnimations(state) {
|
701
|
+
return (!this.popoverContentAttributesComponent() ||
|
702
|
+
!this.cssAnimation() ||
|
703
|
+
(this.cssAnimation() && !this.cssClosingAnimation() && state === RdxPopoverState.CLOSED) ||
|
704
|
+
(this.cssAnimation() && !this.cssOpeningAnimation() && state === RdxPopoverState.OPEN) ||
|
705
|
+
// !this.cssAnimationStatus() ||
|
706
|
+
(this.cssOpeningAnimation() &&
|
707
|
+
state === RdxPopoverState.OPEN &&
|
708
|
+
[RdxPopoverAnimationStatus.OPEN_STARTED].includes(this.cssAnimationStatus())) ||
|
709
|
+
(this.cssClosingAnimation() &&
|
710
|
+
state === RdxPopoverState.CLOSED &&
|
711
|
+
[RdxPopoverAnimationStatus.CLOSED_STARTED].includes(this.cssAnimationStatus())));
|
712
|
+
}
|
713
|
+
/** @ignore */
|
714
|
+
ifOpenOrCloseWithAnimations(cssAnimationStatus) {
|
715
|
+
return (this.popoverContentAttributesComponent() &&
|
716
|
+
this.cssAnimation() &&
|
717
|
+
cssAnimationStatus &&
|
718
|
+
((this.cssOpeningAnimation() &&
|
719
|
+
this.state() === RdxPopoverState.OPEN &&
|
720
|
+
[RdxPopoverAnimationStatus.OPEN_ENDED].includes(cssAnimationStatus)) ||
|
721
|
+
(this.cssClosingAnimation() &&
|
722
|
+
this.state() === RdxPopoverState.CLOSED &&
|
723
|
+
[RdxPopoverAnimationStatus.CLOSED_ENDED].includes(cssAnimationStatus))));
|
724
|
+
}
|
725
|
+
/** @ignore */
|
726
|
+
openOrClose(state) {
|
727
|
+
const isOpen = this.isOpen(state);
|
728
|
+
isOpen ? this.openContent() : this.closeContent();
|
703
729
|
}
|
704
730
|
/** @ignore */
|
705
|
-
|
706
|
-
this.
|
731
|
+
emitOnOpenOrOnClosed(state) {
|
732
|
+
this.isOpen(state)
|
733
|
+
? this.attachDetachEvent() === RdxPopoverAttachDetachEvent.ATTACH && this.emitOnOpen()
|
734
|
+
: this.attachDetachEvent() === RdxPopoverAttachDetachEvent.DETACH && this.emitOnClosed();
|
707
735
|
}
|
708
736
|
/** @ignore */
|
709
|
-
|
710
|
-
this.
|
737
|
+
canEmitOnOpenOrOnClosed() {
|
738
|
+
return (!this.cssAnimation() ||
|
739
|
+
(!this.cssOpeningAnimation() && this.state() === RdxPopoverState.OPEN) ||
|
740
|
+
(this.cssOpeningAnimation() &&
|
741
|
+
this.state() === RdxPopoverState.OPEN &&
|
742
|
+
this.cssAnimationStatus() === RdxPopoverAnimationStatus.OPEN_ENDED) ||
|
743
|
+
(!this.cssClosingAnimation() && this.state() === RdxPopoverState.CLOSED) ||
|
744
|
+
(this.cssClosingAnimation() &&
|
745
|
+
this.state() === RdxPopoverState.CLOSED &&
|
746
|
+
this.cssAnimationStatus() === RdxPopoverAnimationStatus.CLOSED_ENDED));
|
711
747
|
}
|
712
748
|
/** @ignore */
|
713
|
-
|
749
|
+
onStateChangeEffect() {
|
750
|
+
let isFirst = true;
|
714
751
|
effect(() => {
|
715
|
-
const
|
752
|
+
const state = this.state();
|
716
753
|
untracked(() => {
|
717
|
-
if (
|
718
|
-
|
754
|
+
if (isFirst) {
|
755
|
+
isFirst = false;
|
756
|
+
return;
|
757
|
+
}
|
758
|
+
if (!this.ifOpenOrCloseWithoutAnimations(state)) {
|
759
|
+
return;
|
760
|
+
}
|
761
|
+
this.openOrClose(state);
|
762
|
+
});
|
763
|
+
}, {});
|
764
|
+
}
|
765
|
+
/** @ignore */
|
766
|
+
onCssAnimationStatusChangeChangeEffect() {
|
767
|
+
let isFirst = true;
|
768
|
+
effect(() => {
|
769
|
+
const cssAnimationStatus = this.cssAnimationStatus();
|
770
|
+
untracked(() => {
|
771
|
+
if (isFirst) {
|
772
|
+
isFirst = false;
|
773
|
+
return;
|
774
|
+
}
|
775
|
+
if (!this.ifOpenOrCloseWithAnimations(cssAnimationStatus)) {
|
776
|
+
return;
|
777
|
+
}
|
778
|
+
this.openOrClose(this.state());
|
779
|
+
});
|
780
|
+
});
|
781
|
+
}
|
782
|
+
/** @ignore */
|
783
|
+
emitOpenOrClosedEventEffect() {
|
784
|
+
let isFirst = true;
|
785
|
+
effect(() => {
|
786
|
+
this.attachDetachEvent();
|
787
|
+
this.cssAnimationStatus();
|
788
|
+
untracked(() => {
|
789
|
+
if (isFirst) {
|
790
|
+
isFirst = false;
|
791
|
+
return;
|
719
792
|
}
|
720
|
-
|
721
|
-
|
793
|
+
const canEmitOpenClose = untracked(() => this.canEmitOnOpenOrOnClosed());
|
794
|
+
if (!canEmitOpenClose) {
|
795
|
+
return;
|
722
796
|
}
|
797
|
+
this.emitOnOpenOrOnClosed(this.state());
|
723
798
|
});
|
724
799
|
});
|
725
800
|
}
|
726
801
|
/** @ignore */
|
727
802
|
onOpenChangeEffect() {
|
728
803
|
effect(() => {
|
729
|
-
const
|
804
|
+
const open = this.open();
|
730
805
|
untracked(() => {
|
731
|
-
this.
|
732
|
-
|
733
|
-
|
806
|
+
this.setState(open ? RdxPopoverState.OPEN : RdxPopoverState.CLOSED);
|
807
|
+
});
|
808
|
+
});
|
809
|
+
}
|
810
|
+
/** @ignore */
|
811
|
+
onIsFirstDefaultOpenChangeEffect() {
|
812
|
+
const effectRef = effect(() => {
|
813
|
+
const defaultOpen = this.defaultOpen();
|
814
|
+
untracked(() => {
|
815
|
+
if (!defaultOpen || this.open()) {
|
816
|
+
effectRef.destroy();
|
817
|
+
return;
|
734
818
|
}
|
819
|
+
this.handleOpen();
|
735
820
|
});
|
736
821
|
});
|
737
822
|
}
|
738
823
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverRootDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
739
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "18.2.11", type: RdxPopoverRootDirective, isStandalone: true, selector: "[rdxPopoverRoot]", inputs: { defaultOpen: { classPropertyName: "defaultOpen", publicName: "defaultOpen", isSignal: true, isRequired: false, transformFunction: null }, open: { classPropertyName: "open", publicName: "open", isSignal: true, isRequired: false, transformFunction: null } },
|
740
|
-
{
|
741
|
-
provide: RdxPopoverRootToken,
|
742
|
-
useExisting: forwardRef(() => RdxPopoverRootDirective)
|
743
|
-
}
|
744
|
-
], queries: [{ propertyName: "popoverContentDirective", first: true, predicate: RdxPopoverContentDirective, descendants: true, isSignal: true }, { propertyName: "popoverTriggerDirective", first: true, predicate: RdxPopoverTriggerDirective, descendants: true, isSignal: true }, { propertyName: "popoverArrowDirective", first: true, predicate: RdxPopoverArrowToken, descendants: true, isSignal: true }], exportAs: ["rdxPopoverRoot"], ngImport: i0 }); }
|
824
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "18.2.11", type: RdxPopoverRootDirective, isStandalone: true, selector: "[rdxPopoverRoot]", inputs: { anchor: { classPropertyName: "anchor", publicName: "anchor", isSignal: true, isRequired: false, transformFunction: null }, defaultOpen: { classPropertyName: "defaultOpen", publicName: "defaultOpen", isSignal: true, isRequired: false, transformFunction: null }, open: { classPropertyName: "open", publicName: "open", isSignal: true, isRequired: false, transformFunction: null }, externalControl: { classPropertyName: "externalControl", publicName: "externalControl", isSignal: true, isRequired: false, transformFunction: null }, cssAnimation: { classPropertyName: "cssAnimation", publicName: "cssAnimation", isSignal: true, isRequired: false, transformFunction: null }, cssOpeningAnimation: { classPropertyName: "cssOpeningAnimation", publicName: "cssOpeningAnimation", isSignal: true, isRequired: false, transformFunction: null }, cssClosingAnimation: { classPropertyName: "cssClosingAnimation", publicName: "cssClosingAnimation", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "popoverContentDirective", first: true, predicate: RdxPopoverContentDirective, descendants: true, isSignal: true }, { propertyName: "popoverTriggerDirective", first: true, predicate: RdxPopoverTriggerDirective, descendants: true, isSignal: true }, { propertyName: "popoverArrowDirective", first: true, predicate: RdxPopoverArrowToken, descendants: true, isSignal: true }, { propertyName: "popoverCloseDirective", first: true, predicate: RdxPopoverCloseToken, descendants: true, isSignal: true }, { propertyName: "popoverContentAttributesComponent", first: true, predicate: RdxPopoverContentAttributesToken, descendants: true, isSignal: true }, { propertyName: "internalPopoverAnchorDirective", first: true, predicate: RdxPopoverAnchorToken, descendants: true, isSignal: true }], exportAs: ["rdxPopoverRoot"], ngImport: i0 }); }
|
745
825
|
}
|
746
826
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverRootDirective, decorators: [{
|
747
827
|
type: Directive,
|
748
828
|
args: [{
|
749
829
|
selector: '[rdxPopoverRoot]',
|
750
830
|
standalone: true,
|
831
|
+
exportAs: 'rdxPopoverRoot'
|
832
|
+
}]
|
833
|
+
}], ctorParameters: () => [] });
|
834
|
+
|
835
|
+
function injectPopoverRoot(optional = false) {
|
836
|
+
isDevMode() && assertInInjectionContext(injectPopoverRoot);
|
837
|
+
return inject(RdxPopoverRootDirective, { optional });
|
838
|
+
}
|
839
|
+
|
840
|
+
class RdxPopoverAnchorDirective {
|
841
|
+
constructor() {
|
842
|
+
/**
|
843
|
+
* @ignore
|
844
|
+
* If outside the root then null, otherwise the root directive - with optional `true` passed in as the first param.
|
845
|
+
* If outside the root and non-null value that means the html structure is wrong - popover inside popover.
|
846
|
+
* */
|
847
|
+
this.popoverRoot = injectPopoverRoot(true);
|
848
|
+
/** @ignore */
|
849
|
+
this.elementRef = inject(ElementRef);
|
850
|
+
/** @ignore */
|
851
|
+
this.overlayOrigin = inject(CdkOverlayOrigin);
|
852
|
+
/** @ignore */
|
853
|
+
this.document = inject(DOCUMENT);
|
854
|
+
/** @ignore */
|
855
|
+
this.name = computed(() => `rdx-popover-external-anchor-${this.popoverRoot?.uniqueId()}`);
|
856
|
+
}
|
857
|
+
/** @ignore */
|
858
|
+
click() {
|
859
|
+
this.emitOutsideClick();
|
860
|
+
}
|
861
|
+
/** @ignore */
|
862
|
+
setPopoverRoot(popoverRoot) {
|
863
|
+
this.popoverRoot = popoverRoot;
|
864
|
+
}
|
865
|
+
emitOutsideClick() {
|
866
|
+
const clickEvent = new MouseEvent('click', {
|
867
|
+
view: this.document.defaultView,
|
868
|
+
bubbles: true,
|
869
|
+
cancelable: true
|
870
|
+
});
|
871
|
+
this.document.body.dispatchEvent(clickEvent);
|
872
|
+
}
|
873
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverAnchorDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
874
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.11", type: RdxPopoverAnchorDirective, isStandalone: true, selector: "[rdxPopoverAnchor]", host: { attributes: { "type": "button" }, listeners: { "click": "click()" }, properties: { "attr.id": "name()", "attr.aria-haspopup": "\"dialog\"" } }, providers: [
|
875
|
+
{
|
876
|
+
provide: RdxPopoverAnchorToken,
|
877
|
+
useExisting: forwardRef(() => RdxPopoverAnchorDirective)
|
878
|
+
}
|
879
|
+
], exportAs: ["rdxPopoverAnchor"], hostDirectives: [{ directive: i1.CdkOverlayOrigin }], ngImport: i0 }); }
|
880
|
+
}
|
881
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverAnchorDirective, decorators: [{
|
882
|
+
type: Directive,
|
883
|
+
args: [{
|
884
|
+
selector: '[rdxPopoverAnchor]',
|
885
|
+
standalone: true,
|
886
|
+
exportAs: 'rdxPopoverAnchor',
|
887
|
+
hostDirectives: [CdkOverlayOrigin],
|
888
|
+
host: {
|
889
|
+
type: 'button',
|
890
|
+
'[attr.id]': 'name()',
|
891
|
+
'[attr.aria-haspopup]': '"dialog"',
|
892
|
+
'(click)': 'click()'
|
893
|
+
},
|
751
894
|
providers: [
|
752
895
|
{
|
753
|
-
provide:
|
754
|
-
useExisting: forwardRef(() =>
|
896
|
+
provide: RdxPopoverAnchorToken,
|
897
|
+
useExisting: forwardRef(() => RdxPopoverAnchorDirective)
|
755
898
|
}
|
756
|
-
]
|
757
|
-
|
899
|
+
]
|
900
|
+
}]
|
901
|
+
}] });
|
902
|
+
|
903
|
+
class RdxPopoverArrowDirective {
|
904
|
+
constructor() {
|
905
|
+
/** @ignore */
|
906
|
+
this.renderer = inject(Renderer2);
|
907
|
+
/** @ignore */
|
908
|
+
this.popoverRoot = injectPopoverRoot();
|
909
|
+
/** @ignore */
|
910
|
+
this.elementRef = inject(ElementRef);
|
911
|
+
/**
|
912
|
+
* @description The width of the arrow in pixels.
|
913
|
+
* @default 10
|
914
|
+
*/
|
915
|
+
this.width = input(10);
|
916
|
+
/**
|
917
|
+
* @description The height of the arrow in pixels.
|
918
|
+
* @default 5
|
919
|
+
*/
|
920
|
+
this.height = input(5);
|
921
|
+
/** @ignore */
|
922
|
+
this.arrowSvgElement = computed(() => {
|
923
|
+
const width = this.width();
|
924
|
+
const height = this.height();
|
925
|
+
const svgElement = this.renderer.createElement('svg', 'svg');
|
926
|
+
this.renderer.setAttribute(svgElement, 'viewBox', '0 0 30 10');
|
927
|
+
this.renderer.setAttribute(svgElement, 'width', String(width));
|
928
|
+
this.renderer.setAttribute(svgElement, 'height', String(height));
|
929
|
+
const polygonElement = this.renderer.createElement('polygon', 'svg');
|
930
|
+
this.renderer.setAttribute(polygonElement, 'points', '0,0 30,0 15,10');
|
931
|
+
this.renderer.setAttribute(svgElement, 'preserveAspectRatio', 'none');
|
932
|
+
this.renderer.appendChild(svgElement, polygonElement);
|
933
|
+
return svgElement;
|
934
|
+
});
|
935
|
+
/** @ignore */
|
936
|
+
this.currentArrowSvgElement = signal(void 0);
|
937
|
+
/** @ignore */
|
938
|
+
this.position = toSignal(this.popoverRoot.popoverContentDirective().positionChange());
|
939
|
+
this.onArrowSvgElementChangeEffect();
|
940
|
+
this.onContentPositionChangeEffect();
|
941
|
+
}
|
942
|
+
/** @ignore */
|
943
|
+
ngAfterViewInit() {
|
944
|
+
if (this.elementRef.nativeElement.parentElement) {
|
945
|
+
this.renderer.setStyle(this.elementRef.nativeElement.parentElement, 'position', 'relative');
|
946
|
+
}
|
947
|
+
this.renderer.setStyle(this.elementRef.nativeElement, 'position', 'absolute');
|
948
|
+
this.renderer.setStyle(this.elementRef.nativeElement, 'boxSizing', '');
|
949
|
+
this.renderer.setStyle(this.elementRef.nativeElement, 'fontSize', '0px');
|
950
|
+
}
|
951
|
+
setAnchorOrTriggerRect() {
|
952
|
+
this.anchorOrTriggerRect = (this.popoverRoot.popoverAnchorDirective() ?? this.popoverRoot.popoverTriggerDirective()).elementRef.nativeElement.getBoundingClientRect();
|
953
|
+
}
|
954
|
+
/** @ignore */
|
955
|
+
setPosition(position) {
|
956
|
+
this.setAnchorOrTriggerRect();
|
957
|
+
const posParams = getArrowPositionParams(getSideAndAlignFromAllPossibleConnectedPositions(position.connectionPair), { width: this.width(), height: this.height() }, { width: this.anchorOrTriggerRect.width, height: this.anchorOrTriggerRect.height });
|
958
|
+
this.renderer.setStyle(this.elementRef.nativeElement, 'top', posParams.top);
|
959
|
+
this.renderer.setStyle(this.elementRef.nativeElement, 'bottom', '');
|
960
|
+
this.renderer.setStyle(this.elementRef.nativeElement, 'left', posParams.left);
|
961
|
+
this.renderer.setStyle(this.elementRef.nativeElement, 'right', '');
|
962
|
+
this.renderer.setStyle(this.elementRef.nativeElement, 'transform', posParams.transform);
|
963
|
+
}
|
964
|
+
/** @ignore */
|
965
|
+
onArrowSvgElementChangeEffect() {
|
966
|
+
effect(() => {
|
967
|
+
const arrowElement = this.arrowSvgElement();
|
968
|
+
untracked(() => {
|
969
|
+
const currentArrowSvgElement = this.currentArrowSvgElement();
|
970
|
+
if (currentArrowSvgElement) {
|
971
|
+
this.renderer.removeChild(this.elementRef.nativeElement, currentArrowSvgElement);
|
972
|
+
}
|
973
|
+
this.currentArrowSvgElement.set(arrowElement);
|
974
|
+
this.renderer.setStyle(this.elementRef.nativeElement, 'width', `${this.width()}px`);
|
975
|
+
this.renderer.setStyle(this.elementRef.nativeElement, 'height', `${this.height()}px`);
|
976
|
+
this.renderer.appendChild(this.elementRef.nativeElement, this.currentArrowSvgElement());
|
977
|
+
});
|
978
|
+
});
|
979
|
+
}
|
980
|
+
/** @ignore */
|
981
|
+
onContentPositionChangeEffect() {
|
982
|
+
effect(() => {
|
983
|
+
const position = this.position();
|
984
|
+
untracked(() => {
|
985
|
+
if (!position) {
|
986
|
+
return;
|
987
|
+
}
|
988
|
+
this.setPosition(position);
|
989
|
+
});
|
990
|
+
});
|
991
|
+
}
|
992
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverArrowDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
993
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.11", type: RdxPopoverArrowDirective, isStandalone: true, selector: "[rdxPopoverArrow]", inputs: { width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
994
|
+
{
|
995
|
+
provide: RdxPopoverArrowToken,
|
996
|
+
useExisting: forwardRef(() => RdxPopoverArrowDirective)
|
997
|
+
}
|
998
|
+
], ngImport: i0 }); }
|
999
|
+
}
|
1000
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverArrowDirective, decorators: [{
|
1001
|
+
type: Directive,
|
1002
|
+
args: [{
|
1003
|
+
selector: '[rdxPopoverArrow]',
|
1004
|
+
standalone: true,
|
1005
|
+
providers: [
|
1006
|
+
{
|
1007
|
+
provide: RdxPopoverArrowToken,
|
1008
|
+
useExisting: forwardRef(() => RdxPopoverArrowDirective)
|
1009
|
+
}
|
1010
|
+
]
|
1011
|
+
}]
|
1012
|
+
}], ctorParameters: () => [] });
|
1013
|
+
|
1014
|
+
class RdxPopoverCloseDirective {
|
1015
|
+
constructor() {
|
1016
|
+
/** @ignore */
|
1017
|
+
this.popoverRoot = injectPopoverRoot();
|
1018
|
+
/** @ignore */
|
1019
|
+
this.elementRef = inject(ElementRef);
|
1020
|
+
/** @ignore */
|
1021
|
+
this.renderer = inject(Renderer2);
|
1022
|
+
this.onIsControlledExternallyEffect();
|
1023
|
+
}
|
1024
|
+
/** @ignore */
|
1025
|
+
onIsControlledExternallyEffect() {
|
1026
|
+
effect(() => {
|
1027
|
+
const isControlledExternally = this.popoverRoot.controlledExternally()();
|
1028
|
+
untracked(() => {
|
1029
|
+
this.renderer.setStyle(this.elementRef.nativeElement, 'display', isControlledExternally ? 'none' : null);
|
1030
|
+
});
|
1031
|
+
});
|
1032
|
+
}
|
1033
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverCloseDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
1034
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.11", type: RdxPopoverCloseDirective, isStandalone: true, selector: "[rdxPopoverClose]", host: { attributes: { "type": "button" }, listeners: { "click": "popoverRoot.handleClose()" } }, providers: [
|
1035
|
+
{
|
1036
|
+
provide: RdxPopoverCloseToken,
|
1037
|
+
useExisting: forwardRef(() => RdxPopoverCloseDirective)
|
1038
|
+
}
|
1039
|
+
], ngImport: i0 }); }
|
1040
|
+
}
|
1041
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverCloseDirective, decorators: [{
|
1042
|
+
type: Directive,
|
1043
|
+
args: [{
|
1044
|
+
selector: '[rdxPopoverClose]',
|
1045
|
+
standalone: true,
|
1046
|
+
host: {
|
1047
|
+
type: 'button',
|
1048
|
+
'(click)': 'popoverRoot.handleClose()'
|
1049
|
+
},
|
1050
|
+
providers: [
|
1051
|
+
{
|
1052
|
+
provide: RdxPopoverCloseToken,
|
1053
|
+
useExisting: forwardRef(() => RdxPopoverCloseDirective)
|
1054
|
+
}
|
1055
|
+
]
|
758
1056
|
}]
|
759
1057
|
}], ctorParameters: () => [] });
|
760
1058
|
|
1059
|
+
class RdxPopoverContentAttributesComponent {
|
1060
|
+
constructor() {
|
1061
|
+
/** @ignore */
|
1062
|
+
this.popoverRoot = injectPopoverRoot();
|
1063
|
+
/** @ignore */
|
1064
|
+
this.name = computed(() => `rdx-popover-content-attributes-${this.popoverRoot.uniqueId()}`);
|
1065
|
+
/** @ignore */
|
1066
|
+
this.disableAnimation = computed(() => !this.canAnimate());
|
1067
|
+
}
|
1068
|
+
/** @ignore */
|
1069
|
+
onAnimationStart(_) {
|
1070
|
+
this.popoverRoot.cssAnimationStatus.set(this.popoverRoot.state() === RdxPopoverState.OPEN
|
1071
|
+
? RdxPopoverAnimationStatus.OPEN_STARTED
|
1072
|
+
: RdxPopoverAnimationStatus.CLOSED_STARTED);
|
1073
|
+
}
|
1074
|
+
/** @ignore */
|
1075
|
+
onAnimationEnd(_) {
|
1076
|
+
this.popoverRoot.cssAnimationStatus.set(this.popoverRoot.state() === RdxPopoverState.OPEN
|
1077
|
+
? RdxPopoverAnimationStatus.OPEN_ENDED
|
1078
|
+
: RdxPopoverAnimationStatus.CLOSED_ENDED);
|
1079
|
+
}
|
1080
|
+
/** @ignore */
|
1081
|
+
canAnimate() {
|
1082
|
+
return (this.popoverRoot.cssAnimation() &&
|
1083
|
+
((this.popoverRoot.cssOpeningAnimation() && this.popoverRoot.state() === RdxPopoverState.OPEN) ||
|
1084
|
+
(this.popoverRoot.cssClosingAnimation() && this.popoverRoot.state() === RdxPopoverState.CLOSED)));
|
1085
|
+
}
|
1086
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverContentAttributesComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
1087
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.11", type: RdxPopoverContentAttributesComponent, isStandalone: true, selector: "[rdxPopoverContentAttributes]", host: { listeners: { "animationstart": "onAnimationStart($event)", "animationend": "onAnimationEnd($event)" }, properties: { "attr.role": "\"dialog\"", "attr.id": "name()", "attr.data-state": "popoverRoot.state()", "attr.data-side": "popoverRoot.popoverContentDirective().side()", "attr.data-align": "popoverRoot.popoverContentDirective().align()", "style": "disableAnimation() ? {animation: \"none !important\"} : null" } }, providers: [
|
1088
|
+
{
|
1089
|
+
provide: RdxPopoverContentAttributesToken,
|
1090
|
+
useExisting: forwardRef(() => RdxPopoverContentAttributesComponent)
|
1091
|
+
}
|
1092
|
+
], ngImport: i0, template: `
|
1093
|
+
<ng-content />
|
1094
|
+
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
1095
|
+
}
|
1096
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverContentAttributesComponent, decorators: [{
|
1097
|
+
type: Component,
|
1098
|
+
args: [{
|
1099
|
+
selector: '[rdxPopoverContentAttributes]',
|
1100
|
+
standalone: true,
|
1101
|
+
template: `
|
1102
|
+
<ng-content />
|
1103
|
+
`,
|
1104
|
+
host: {
|
1105
|
+
'[attr.role]': '"dialog"',
|
1106
|
+
'[attr.id]': 'name()',
|
1107
|
+
'[attr.data-state]': 'popoverRoot.state()',
|
1108
|
+
'[attr.data-side]': 'popoverRoot.popoverContentDirective().side()',
|
1109
|
+
'[attr.data-align]': 'popoverRoot.popoverContentDirective().align()',
|
1110
|
+
'[style]': 'disableAnimation() ? {animation: "none !important"} : null',
|
1111
|
+
'(animationstart)': 'onAnimationStart($event)',
|
1112
|
+
'(animationend)': 'onAnimationEnd($event)'
|
1113
|
+
},
|
1114
|
+
providers: [
|
1115
|
+
{
|
1116
|
+
provide: RdxPopoverContentAttributesToken,
|
1117
|
+
useExisting: forwardRef(() => RdxPopoverContentAttributesComponent)
|
1118
|
+
}
|
1119
|
+
],
|
1120
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
1121
|
+
}]
|
1122
|
+
}] });
|
1123
|
+
|
761
1124
|
const _imports = [
|
762
1125
|
RdxPopoverArrowDirective,
|
763
1126
|
RdxPopoverCloseDirective,
|
764
1127
|
RdxPopoverContentDirective,
|
765
1128
|
RdxPopoverTriggerDirective,
|
766
|
-
RdxPopoverRootDirective
|
1129
|
+
RdxPopoverRootDirective,
|
1130
|
+
RdxPopoverAnchorDirective,
|
1131
|
+
RdxPopoverContentAttributesComponent
|
767
1132
|
];
|
768
1133
|
class RdxPopoverModule {
|
769
1134
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
@@ -771,11 +1136,15 @@ class RdxPopoverModule {
|
|
771
1136
|
RdxPopoverCloseDirective,
|
772
1137
|
RdxPopoverContentDirective,
|
773
1138
|
RdxPopoverTriggerDirective,
|
774
|
-
RdxPopoverRootDirective
|
1139
|
+
RdxPopoverRootDirective,
|
1140
|
+
RdxPopoverAnchorDirective,
|
1141
|
+
RdxPopoverContentAttributesComponent], exports: [RdxPopoverArrowDirective,
|
775
1142
|
RdxPopoverCloseDirective,
|
776
1143
|
RdxPopoverContentDirective,
|
777
1144
|
RdxPopoverTriggerDirective,
|
778
|
-
RdxPopoverRootDirective
|
1145
|
+
RdxPopoverRootDirective,
|
1146
|
+
RdxPopoverAnchorDirective,
|
1147
|
+
RdxPopoverContentAttributesComponent] }); }
|
779
1148
|
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverModule }); }
|
780
1149
|
}
|
781
1150
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverModule, decorators: [{
|
@@ -790,5 +1159,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
|
|
790
1159
|
* Generated bundle index. Do not edit.
|
791
1160
|
*/
|
792
1161
|
|
793
|
-
export { RdxPopoverAlign, RdxPopoverArrowDirective, RdxPopoverCloseDirective, RdxPopoverContentDirective, RdxPopoverModule, RdxPopoverRootDirective, RdxPopoverSide, RdxPopoverTriggerDirective };
|
1162
|
+
export { RdxPopoverAlign, RdxPopoverAnchorDirective, RdxPopoverAnimationStatus, RdxPopoverArrowDirective, RdxPopoverAttachDetachEvent, RdxPopoverCloseDirective, RdxPopoverContentAttributesComponent, RdxPopoverContentDirective, RdxPopoverModule, RdxPopoverRootDirective, RdxPopoverSide, RdxPopoverState, RdxPopoverTriggerDirective };
|
794
1163
|
//# sourceMappingURL=radix-ng-primitives-popover.mjs.map
|