@radix-ng/primitives 0.20.1 → 0.21.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 +6022 -1655
- 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 +17 -5
- 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 -92
- package/esm2022/popover/src/popover-root.directive.mjs +234 -61
- package/esm2022/popover/src/popover-root.inject.mjs +4 -4
- package/esm2022/popover/src/popover-trigger.directive.mjs +10 -11
- package/esm2022/popover/src/popover.constants.mjs +2 -2
- 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/toggle/index.mjs +2 -2
- package/esm2022/toggle/src/toggle-visually-hidden-input.directive.mjs +31 -0
- package/esm2022/toggle/src/toggle.directive.mjs +37 -8
- 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 +679 -312
- 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-toggle.mjs +45 -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 +2 -2
- 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 +35 -24
- package/popover/src/popover-root.directive.d.ts +91 -18
- package/popover/src/popover-root.inject.d.ts +2 -1
- package/popover/src/popover-trigger.directive.d.ts +5 -5
- package/popover/src/popover.constants.d.ts +1 -1
- 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/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 +19 -2
- package/esm2022/popover/src/popover-root.token.mjs +0 -3
- package/esm2022/toggle/src/toggle-input.directive.mjs +0 -30
- package/popover/src/popover-root.token.d.ts +0 -3
- 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]: {
|
@@ -114,7 +130,7 @@ const POPOVER_POSITIONS = {
|
|
114
130
|
const DEFAULTS = {
|
115
131
|
offsets: {
|
116
132
|
side: 10,
|
117
|
-
align:
|
133
|
+
align: 0
|
118
134
|
}
|
119
135
|
};
|
120
136
|
|
@@ -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,103 +257,80 @@ 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() ?? (greatestDimensionFromTheArrow || 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((value, 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
|
-
this.onControlledExternallyChangeEffect();
|
458
307
|
}
|
459
308
|
/** @ignore */
|
460
309
|
ngOnInit() {
|
461
|
-
this.setOrigin();
|
462
310
|
this.setScrollStrategy();
|
311
|
+
this.setDisableClose();
|
463
312
|
this.onAttach();
|
464
313
|
this.onDetach();
|
465
314
|
this.connectKeydownEscape();
|
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,8 +351,20 @@ class RdxPopoverContentDirective {
|
|
501
351
|
connectOutsideClick() {
|
502
352
|
this.connectedOverlay.overlayOutsideClick
|
503
353
|
.asObservable()
|
504
|
-
.pipe(
|
505
|
-
|
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();
|
506
368
|
}), takeUntilDestroyed(this.destroyRef))
|
507
369
|
.subscribe();
|
508
370
|
}
|
@@ -511,7 +373,10 @@ class RdxPopoverContentDirective {
|
|
511
373
|
this.connectedOverlay.attach
|
512
374
|
.asObservable()
|
513
375
|
.pipe(tap(() => {
|
514
|
-
|
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);
|
515
380
|
}), takeUntilDestroyed(this.destroyRef))
|
516
381
|
.subscribe();
|
517
382
|
}
|
@@ -520,7 +385,10 @@ class RdxPopoverContentDirective {
|
|
520
385
|
this.connectedOverlay.detach
|
521
386
|
.asObservable()
|
522
387
|
.pipe(tap(() => {
|
523
|
-
|
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);
|
524
392
|
}), takeUntilDestroyed(this.destroyRef))
|
525
393
|
.subscribe();
|
526
394
|
}
|
@@ -528,24 +396,68 @@ class RdxPopoverContentDirective {
|
|
528
396
|
setScrollStrategy() {
|
529
397
|
const prevScrollStrategy = this.connectedOverlay.scrollStrategy;
|
530
398
|
this.connectedOverlay.scrollStrategy = this.overlay.scrollStrategies.reposition();
|
531
|
-
this.connectedOverlay.
|
532
|
-
scrollStrategy: new SimpleChange(prevScrollStrategy, this.connectedOverlay.scrollStrategy, false)
|
533
|
-
});
|
399
|
+
this.fireOverlayNgOnChanges('scrollStrategy', this.connectedOverlay.scrollStrategy, prevScrollStrategy);
|
534
400
|
}
|
535
401
|
/** @ignore */
|
536
402
|
setDisableClose() {
|
537
403
|
const prevDisableClose = this.connectedOverlay.disableClose;
|
538
|
-
this.connectedOverlay.disableClose =
|
539
|
-
this.connectedOverlay.
|
540
|
-
disableClose: new SimpleChange(prevDisableClose, this.connectedOverlay.disableClose, false)
|
541
|
-
});
|
404
|
+
this.connectedOverlay.disableClose = true;
|
405
|
+
this.fireOverlayNgOnChanges('disableClose', this.connectedOverlay.disableClose, prevDisableClose);
|
542
406
|
}
|
543
407
|
/** @ignore */
|
544
|
-
setOrigin() {
|
408
|
+
setOrigin(origin) {
|
545
409
|
const prevOrigin = this.connectedOverlay.origin;
|
546
|
-
this.connectedOverlay.origin =
|
547
|
-
this.connectedOverlay.
|
548
|
-
|
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
|
+
});
|
549
461
|
});
|
550
462
|
}
|
551
463
|
/** @ignore */
|
@@ -554,26 +466,18 @@ class RdxPopoverContentDirective {
|
|
554
466
|
const positions = this.positions();
|
555
467
|
this.disableAlternatePositions();
|
556
468
|
untracked(() => {
|
557
|
-
|
558
|
-
this.connectedOverlay.positions = positions;
|
559
|
-
this.connectedOverlay.ngOnChanges({
|
560
|
-
positions: new SimpleChange(prevPositions, this.connectedOverlay.positions, false)
|
561
|
-
});
|
562
|
-
this.connectedOverlay.overlayRef?.updatePosition();
|
469
|
+
this.setPositions(positions);
|
563
470
|
});
|
564
471
|
});
|
565
472
|
}
|
566
473
|
/** @ignore */
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
untracked(() => {
|
571
|
-
this.setDisableClose();
|
572
|
-
});
|
474
|
+
fireOverlayNgOnChanges(input, currentValue, previousValue, firstChange = false) {
|
475
|
+
this.connectedOverlay.ngOnChanges({
|
476
|
+
[input]: new SimpleChange(previousValue, currentValue, firstChange)
|
573
477
|
});
|
574
478
|
}
|
575
479
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
576
|
-
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 }); }
|
577
481
|
}
|
578
482
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverContentDirective, decorators: [{
|
579
483
|
type: Directive,
|
@@ -581,31 +485,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
|
|
581
485
|
selector: '[rdxPopoverContent]',
|
582
486
|
standalone: true,
|
583
487
|
hostDirectives: [
|
584
|
-
|
585
|
-
directive: CdkConnectedOverlay
|
586
|
-
}
|
488
|
+
CdkConnectedOverlay
|
587
489
|
]
|
588
490
|
}]
|
589
491
|
}], ctorParameters: () => [] });
|
590
492
|
|
591
|
-
let nextId = 0;
|
592
493
|
class RdxPopoverTriggerDirective {
|
593
494
|
constructor() {
|
594
|
-
this.id = input(`rdx-popover-root-${nextId++}`);
|
595
|
-
this.popoverId = computed(() => `rdx-popover-${this.id()}`);
|
596
495
|
/** @ignore */
|
597
496
|
this.popoverRoot = injectPopoverRoot();
|
598
497
|
/** @ignore */
|
599
|
-
this.elementRef = inject(
|
498
|
+
this.elementRef = inject(ElementRef);
|
600
499
|
/** @ignore */
|
601
500
|
this.overlayOrigin = inject(CdkOverlayOrigin);
|
501
|
+
/** @ignore */
|
502
|
+
this.name = computed(() => `rdx-popover-trigger-${this.popoverRoot.uniqueId()}`);
|
602
503
|
}
|
603
504
|
/** @ignore */
|
604
|
-
|
505
|
+
click() {
|
605
506
|
this.popoverRoot.handleToggle();
|
606
507
|
}
|
607
508
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
608
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
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 }); }
|
609
510
|
}
|
610
511
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverTriggerDirective, decorators: [{
|
611
512
|
type: Directive,
|
@@ -615,30 +516,60 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
|
|
615
516
|
hostDirectives: [CdkOverlayOrigin],
|
616
517
|
host: {
|
617
518
|
type: 'button',
|
618
|
-
'[attr.id]': '
|
519
|
+
'[attr.id]': 'name()',
|
619
520
|
'[attr.aria-haspopup]': '"dialog"',
|
620
521
|
'[attr.aria-expanded]': 'popoverRoot.isOpen()',
|
621
|
-
'[attr.aria-controls]': '
|
522
|
+
'[attr.aria-controls]': 'popoverRoot.popoverContentDirective().name()',
|
622
523
|
'[attr.data-state]': 'popoverRoot.state()',
|
623
|
-
'(click)': '
|
524
|
+
'(click)': 'click()'
|
624
525
|
}
|
625
526
|
}]
|
626
527
|
}] });
|
627
528
|
|
529
|
+
let nextId = 0;
|
628
530
|
class RdxPopoverRootDirective {
|
629
531
|
constructor() {
|
532
|
+
/** @ignore */
|
533
|
+
this.uniqueId = signal(++nextId);
|
534
|
+
/** @ignore */
|
535
|
+
this.name = computed(() => `rdx-popover-root-${this.uniqueId()}`);
|
630
536
|
/**
|
631
|
-
* 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
|
632
544
|
*/
|
633
545
|
this.defaultOpen = input(false);
|
634
546
|
/**
|
635
|
-
* 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
|
636
554
|
*/
|
637
|
-
this.
|
555
|
+
this.externalControl = input(void 0);
|
638
556
|
/**
|
639
|
-
*
|
557
|
+
* @description Whether to take into account CSS opening/closing animations.
|
558
|
+
* @default false
|
640
559
|
*/
|
641
|
-
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);
|
642
573
|
/** @ignore */
|
643
574
|
this.popoverContentDirective = contentChild.required(RdxPopoverContentDirective);
|
644
575
|
/** @ignore */
|
@@ -646,126 +577,558 @@ class RdxPopoverRootDirective {
|
|
646
577
|
/** @ignore */
|
647
578
|
this.popoverArrowDirective = contentChild(RdxPopoverArrowToken);
|
648
579
|
/** @ignore */
|
580
|
+
this.popoverCloseDirective = contentChild(RdxPopoverCloseToken);
|
581
|
+
/** @ignore */
|
582
|
+
this.popoverContentAttributesComponent = contentChild(RdxPopoverContentAttributesToken);
|
583
|
+
/** @ignore */
|
584
|
+
this.internalPopoverAnchorDirective = contentChild(RdxPopoverAnchorToken);
|
585
|
+
/** @ignore */
|
649
586
|
this.viewContainerRef = inject(ViewContainerRef);
|
650
587
|
/** @ignore */
|
651
|
-
this.
|
588
|
+
this.destroyRef = inject(DestroyRef);
|
652
589
|
/** @ignore */
|
653
|
-
this.
|
590
|
+
this.state = signal(RdxPopoverState.CLOSED);
|
654
591
|
/** @ignore */
|
655
|
-
this.
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
return 'closed';
|
661
|
-
});
|
592
|
+
this.attachDetachEvent = signal(RdxPopoverAttachDetachEvent.DETACH);
|
593
|
+
/** @ignore */
|
594
|
+
this.isFirstDefaultOpen = signal(false);
|
595
|
+
/** @ignore */
|
596
|
+
this.popoverAnchorDirective = computed(() => this.internalPopoverAnchorDirective() ?? this.anchor());
|
662
597
|
/** @ignore */
|
663
|
-
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();
|
664
610
|
this.onOpenChangeEffect();
|
665
|
-
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
|
+
});
|
666
621
|
}
|
667
622
|
/** @ignore */
|
668
|
-
|
669
|
-
|
670
|
-
this.
|
671
|
-
|
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
|
+
};
|
672
633
|
}
|
673
634
|
/** @ignore */
|
674
635
|
controlledExternally() {
|
675
|
-
return this.
|
636
|
+
return this.externalControl;
|
637
|
+
}
|
638
|
+
/** @ignore */
|
639
|
+
firstDefaultOpen() {
|
640
|
+
return this.isFirstDefaultOpen();
|
676
641
|
}
|
677
642
|
/** @ignore */
|
678
643
|
handleOpen() {
|
679
|
-
if (this.
|
644
|
+
if (this.externalControl()) {
|
680
645
|
return;
|
681
646
|
}
|
682
|
-
this.
|
647
|
+
this.setState(RdxPopoverState.OPEN);
|
683
648
|
}
|
684
649
|
/** @ignore */
|
685
650
|
handleClose() {
|
686
|
-
if (this.
|
651
|
+
if (this.isFirstDefaultOpen()) {
|
652
|
+
this.isFirstDefaultOpen.set(false);
|
653
|
+
}
|
654
|
+
if (this.externalControl()) {
|
687
655
|
return;
|
688
656
|
}
|
689
|
-
this.
|
657
|
+
this.setState(RdxPopoverState.CLOSED);
|
690
658
|
}
|
691
659
|
/** @ignore */
|
692
660
|
handleToggle() {
|
693
|
-
if (this.
|
661
|
+
if (this.externalControl()) {
|
694
662
|
return;
|
695
663
|
}
|
696
664
|
this.isOpen() ? this.handleClose() : this.handleOpen();
|
697
665
|
}
|
698
666
|
/** @ignore */
|
699
|
-
|
700
|
-
|
701
|
-
|
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;
|
702
674
|
}
|
703
|
-
this.
|
704
|
-
|
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();
|
705
729
|
}
|
706
730
|
/** @ignore */
|
707
|
-
|
708
|
-
this.
|
731
|
+
emitOnOpenOrOnClosed(state) {
|
732
|
+
this.isOpen(state)
|
733
|
+
? this.attachDetachEvent() === RdxPopoverAttachDetachEvent.ATTACH && this.emitOnOpen()
|
734
|
+
: this.attachDetachEvent() === RdxPopoverAttachDetachEvent.DETACH && this.emitOnClosed();
|
709
735
|
}
|
710
736
|
/** @ignore */
|
711
|
-
|
712
|
-
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));
|
713
747
|
}
|
714
748
|
/** @ignore */
|
715
|
-
|
749
|
+
onStateChangeEffect() {
|
750
|
+
let isFirst = true;
|
716
751
|
effect(() => {
|
717
|
-
const
|
752
|
+
const state = this.state();
|
718
753
|
untracked(() => {
|
719
|
-
if (
|
720
|
-
|
754
|
+
if (isFirst) {
|
755
|
+
isFirst = false;
|
756
|
+
return;
|
721
757
|
}
|
722
|
-
|
723
|
-
|
758
|
+
if (!this.ifOpenOrCloseWithoutAnimations(state)) {
|
759
|
+
return;
|
724
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;
|
792
|
+
}
|
793
|
+
const canEmitOpenClose = untracked(() => this.canEmitOnOpenOrOnClosed());
|
794
|
+
if (!canEmitOpenClose) {
|
795
|
+
return;
|
796
|
+
}
|
797
|
+
this.emitOnOpenOrOnClosed(this.state());
|
725
798
|
});
|
726
799
|
});
|
727
800
|
}
|
728
801
|
/** @ignore */
|
729
802
|
onOpenChangeEffect() {
|
730
803
|
effect(() => {
|
731
|
-
const
|
804
|
+
const open = this.open();
|
732
805
|
untracked(() => {
|
733
|
-
this.
|
734
|
-
|
735
|
-
|
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;
|
736
818
|
}
|
819
|
+
this.handleOpen();
|
737
820
|
});
|
738
821
|
});
|
739
822
|
}
|
740
823
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverRootDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
741
|
-
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 } },
|
742
|
-
{
|
743
|
-
provide: RdxPopoverRootToken,
|
744
|
-
useExisting: forwardRef(() => RdxPopoverRootDirective)
|
745
|
-
}
|
746
|
-
], 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 }); }
|
747
825
|
}
|
748
826
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverRootDirective, decorators: [{
|
749
827
|
type: Directive,
|
750
828
|
args: [{
|
751
829
|
selector: '[rdxPopoverRoot]',
|
752
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
|
+
},
|
753
894
|
providers: [
|
754
895
|
{
|
755
|
-
provide:
|
756
|
-
useExisting: forwardRef(() =>
|
896
|
+
provide: RdxPopoverAnchorToken,
|
897
|
+
useExisting: forwardRef(() => RdxPopoverAnchorDirective)
|
757
898
|
}
|
758
|
-
]
|
759
|
-
|
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
|
+
]
|
760
1056
|
}]
|
761
1057
|
}], ctorParameters: () => [] });
|
762
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
|
+
|
763
1124
|
const _imports = [
|
764
1125
|
RdxPopoverArrowDirective,
|
765
1126
|
RdxPopoverCloseDirective,
|
766
1127
|
RdxPopoverContentDirective,
|
767
1128
|
RdxPopoverTriggerDirective,
|
768
|
-
RdxPopoverRootDirective
|
1129
|
+
RdxPopoverRootDirective,
|
1130
|
+
RdxPopoverAnchorDirective,
|
1131
|
+
RdxPopoverContentAttributesComponent
|
769
1132
|
];
|
770
1133
|
class RdxPopoverModule {
|
771
1134
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
@@ -773,11 +1136,15 @@ class RdxPopoverModule {
|
|
773
1136
|
RdxPopoverCloseDirective,
|
774
1137
|
RdxPopoverContentDirective,
|
775
1138
|
RdxPopoverTriggerDirective,
|
776
|
-
RdxPopoverRootDirective
|
1139
|
+
RdxPopoverRootDirective,
|
1140
|
+
RdxPopoverAnchorDirective,
|
1141
|
+
RdxPopoverContentAttributesComponent], exports: [RdxPopoverArrowDirective,
|
777
1142
|
RdxPopoverCloseDirective,
|
778
1143
|
RdxPopoverContentDirective,
|
779
1144
|
RdxPopoverTriggerDirective,
|
780
|
-
RdxPopoverRootDirective
|
1145
|
+
RdxPopoverRootDirective,
|
1146
|
+
RdxPopoverAnchorDirective,
|
1147
|
+
RdxPopoverContentAttributesComponent] }); }
|
781
1148
|
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverModule }); }
|
782
1149
|
}
|
783
1150
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxPopoverModule, decorators: [{
|
@@ -792,5 +1159,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
|
|
792
1159
|
* Generated bundle index. Do not edit.
|
793
1160
|
*/
|
794
1161
|
|
795
|
-
export { RdxPopoverAlign, RdxPopoverArrowDirective, RdxPopoverCloseDirective, RdxPopoverContentDirective, RdxPopoverModule, RdxPopoverRootDirective, RdxPopoverSide, RdxPopoverTriggerDirective };
|
1162
|
+
export { RdxPopoverAlign, RdxPopoverAnchorDirective, RdxPopoverAnimationStatus, RdxPopoverArrowDirective, RdxPopoverAttachDetachEvent, RdxPopoverCloseDirective, RdxPopoverContentAttributesComponent, RdxPopoverContentDirective, RdxPopoverModule, RdxPopoverRootDirective, RdxPopoverSide, RdxPopoverState, RdxPopoverTriggerDirective };
|
796
1163
|
//# sourceMappingURL=radix-ng-primitives-popover.mjs.map
|