@skyux/popovers 5.9.3 → 5.9.4
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/bundles/skyux-popovers-testing.umd.js +12 -6
- package/bundles/skyux-popovers.umd.js +1531 -1536
- package/documentation.json +317 -284
- package/esm2015/lib/modules/dropdown/dropdown-item.component.js.map +1 -1
- package/esm2015/lib/modules/dropdown/dropdown-menu.component.js +1 -4
- package/esm2015/lib/modules/dropdown/dropdown-menu.component.js.map +1 -1
- package/esm2015/lib/modules/dropdown/dropdown.component.js +10 -7
- package/esm2015/lib/modules/dropdown/dropdown.component.js.map +1 -1
- package/esm2015/lib/modules/popover/popover-content.component.js +18 -34
- package/esm2015/lib/modules/popover/popover-content.component.js.map +1 -1
- package/esm2015/lib/modules/popover/popover.component.js +11 -2
- package/esm2015/lib/modules/popover/popover.component.js.map +1 -1
- package/esm2015/lib/modules/popover/popover.directive.js +0 -1
- package/esm2015/lib/modules/popover/popover.directive.js.map +1 -1
- package/esm2015/testing/dropdown/dropdown-fixture.js +7 -1
- package/esm2015/testing/dropdown/dropdown-fixture.js.map +1 -1
- package/esm2015/testing/dropdown/popovers-fixture-dropdown.js.map +1 -1
- package/esm2015/testing/popover/popover-fixture.js +8 -8
- package/esm2015/testing/popover/popover-fixture.js.map +1 -1
- package/fesm2015/skyux-popovers-testing.js +15 -9
- package/fesm2015/skyux-popovers-testing.js.map +1 -1
- package/fesm2015/skyux-popovers.js +40 -49
- package/fesm2015/skyux-popovers.js.map +1 -1
- package/lib/modules/dropdown/dropdown-item.component.d.ts +1 -1
- package/lib/modules/dropdown/dropdown-menu.component.d.ts +3 -3
- package/lib/modules/dropdown/dropdown.component.d.ts +12 -12
- package/lib/modules/popover/popover-content.component.d.ts +13 -12
- package/lib/modules/popover/popover.component.d.ts +6 -4
- package/lib/modules/popover/popover.directive.d.ts +3 -5
- package/package.json +6 -6
- package/testing/dropdown/dropdown-fixture.d.ts +7 -7
- package/testing/dropdown/popovers-fixture-dropdown.d.ts +2 -2
- package/testing/popover/popover-fixture.d.ts +6 -6
|
@@ -68,10 +68,19 @@ export class SkyPopoverComponent {
|
|
|
68
68
|
get placement() {
|
|
69
69
|
return this._placement || 'above';
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Specifies the type of popover.
|
|
73
|
+
* @default "info"
|
|
74
|
+
*/
|
|
75
|
+
set popoverType(value) {
|
|
76
|
+
this._popoverType = value;
|
|
77
|
+
}
|
|
78
|
+
get popoverType() {
|
|
79
|
+
return this._popoverType || 'info';
|
|
80
|
+
}
|
|
71
81
|
ngOnDestroy() {
|
|
72
82
|
this.ngUnsubscribe.next();
|
|
73
83
|
this.ngUnsubscribe.complete();
|
|
74
|
-
this.ngUnsubscribe = undefined;
|
|
75
84
|
if (this.overlay) {
|
|
76
85
|
this.overlayService.close(this.overlay);
|
|
77
86
|
this.overlay = undefined;
|
|
@@ -149,7 +158,7 @@ export class SkyPopoverComponent {
|
|
|
149
158
|
});
|
|
150
159
|
contentRef.closed.pipe(takeUntil(this.ngUnsubscribe)).subscribe(() => {
|
|
151
160
|
/*istanbul ignore else*/
|
|
152
|
-
if (this.isActive) {
|
|
161
|
+
if (this.isActive && this.overlay) {
|
|
153
162
|
this.overlayService.close(this.overlay);
|
|
154
163
|
this.overlay = undefined;
|
|
155
164
|
this.isActive = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.component.js","sourceRoot":"","sources":["../../../../../../../../libs/components/popovers/src/lib/modules/popover/popover.component.ts","../../../../../../../../libs/components/popovers/src/lib/modules/popover/popover.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAET,YAAY,EACZ,KAAK,EAEL,MAAM,EACN,WAAW,EACX,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAsB,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEpE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OA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UAAU,CAAC,YAAY;aACpB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;aACnC,SAAS,CAAC,CAAC,YAAY,EAAE,EAAE;YAC1B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;YACjC,IAAI,IAAI,CAAC,4BAA4B,EAAE;gBACrC,IAAI,CAAC,4BAA4B,GAAG,KAAK,CAAC;gBAC1C,IAAI,CAAC,KAAK,EAAE,CAAC;aACd;QACH,CAAC,CAAC,CAAC;QAEL,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;;iHAhOU,mBAAmB;qGAAnB,mBAAmB,6WAwFtB,WAAW,2CCjHrB,2EAGA;4FDsBa,mBAAmB;kBAJ/B,SAAS;mBAAC;oBACT,QAAQ,EAAE,aAAa;oBACvB,WAAW,EAAE,0BAA0B;iBACxC;wGAQY,SAAS;sBADnB,KAAK;gBAeK,aAAa;sBADvB,KAAK;gBAmBK,SAAS;sBADnB,KAAK;gBAaC,YAAY;sBADlB,KAAK;gBAQC,WAAW;sBADjB,KAAK;gBAOC,aAAa;sBADnB,MAAM;gBAOA,aAAa;sBADnB,MAAM;gBAsBC,WAAW;sBAJlB,SAAS;uBAAC,aAAa,EAAE;wBACxB,IAAI,EAAE,WAAW;wBACjB,MAAM,EAAE,IAAI;qBACb","sourcesContent":["import {\n Component,\n ElementRef,\n EventEmitter,\n Input,\n OnDestroy,\n Output,\n TemplateRef,\n ViewChild,\n} from '@angular/core';\nimport { SkyOverlayInstance, SkyOverlayService } from '@skyux/core';\n\nimport { Subject } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\nimport { SkyPopoverContentComponent } from './popover-content.component';\nimport { SkyPopoverContext } from './popover-context';\nimport { SkyPopoverAlignment } from './types/popover-alignment';\nimport { SkyPopoverPlacement } from './types/popover-placement';\nimport { SkyPopoverType } from './types/popover-type';\n\n@Component({\n selector: 'sky-popover',\n templateUrl: './popover.component.html',\n})\nexport class SkyPopoverComponent implements OnDestroy {\n /**\n * Specifies the horizontal alignment of the popover in relation to the trigger element.\n * The `skyPopoverAlignment` property on the popover directive takes precedence over this property when specified.\n * @default \"center\"\n */\n @Input()\n public set alignment(value: SkyPopoverAlignment) {\n this._alignment = value;\n }\n\n public get alignment(): SkyPopoverAlignment {\n return this._alignment || 'center';\n }\n\n /**\n * Indicates whether to close the popover when it loses focus.\n * To require users to click a trigger button to close the popover, set this input to false.\n * @default true\n */\n @Input()\n public set dismissOnBlur(value: boolean) {\n this._dismissOnBlur = value;\n }\n\n public get dismissOnBlur(): boolean {\n if (this._dismissOnBlur === undefined) {\n return true;\n }\n\n return this._dismissOnBlur;\n }\n\n /**\n * Specifies the placement of the popover in relation to the trigger element.\n * The `skyPopoverPlacement` property on the popover directive takes precedence over this property when specified.\n * @default \"above\"\n */\n @Input()\n public set placement(value: SkyPopoverPlacement) {\n this._placement = value;\n }\n\n public get placement(): SkyPopoverPlacement {\n return this._placement || 'above';\n }\n\n /**\n * Specifies a title for the popover.\n */\n @Input()\n public popoverTitle: string;\n\n /**\n * Specifies the type of popover.\n * @default \"info\"\n */\n @Input()\n public popoverType: SkyPopoverType;\n\n /**\n * Fires when users close the popover.\n */\n @Output()\n public popoverClosed = new EventEmitter<SkyPopoverComponent>();\n\n /**\n * Fires when users open the popover.\n */\n @Output()\n public popoverOpened = new EventEmitter<SkyPopoverComponent>();\n\n /**\n * Indicates that the popover is in the process of being opened or closed.\n * @internal\n */\n public isActive = false;\n\n /**\n * Used by unit tests to disable animations since the component is injected at the bottom of the\n * document body.\n * @internal\n */\n public enableAnimations = true;\n\n public isMouseEnter = false;\n\n @ViewChild('templateRef', {\n read: TemplateRef,\n static: true,\n })\n private templateRef: TemplateRef<unknown>;\n\n private contentRef: SkyPopoverContentComponent;\n\n private isMarkedForCloseOnMouseLeave = false;\n\n private ngUnsubscribe = new Subject<void>();\n\n private overlay: SkyOverlayInstance;\n\n private _alignment: SkyPopoverAlignment;\n\n private _dismissOnBlur: boolean;\n\n private _placement: SkyPopoverPlacement;\n\n constructor(private overlayService: SkyOverlayService) {}\n\n public ngOnDestroy(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n this.ngUnsubscribe = undefined;\n\n if (this.overlay) {\n this.overlayService.close(this.overlay);\n this.overlay = undefined;\n }\n }\n\n /**\n * Positions the popover next to a given caller element.\n * @param caller The element that opened the popover.\n * @param placement The placement of the popover.\n * @param alignment The horizontal alignment of the popover.\n * @internal\n */\n public positionNextTo(\n caller: ElementRef,\n placement?: SkyPopoverPlacement,\n alignment?: SkyPopoverAlignment\n ): void {\n if (!this.overlay) {\n this.setupOverlay();\n }\n\n this.placement = placement ?? this.placement;\n this.alignment = alignment ?? this.alignment;\n this.isActive = true;\n\n this.contentRef.open(caller, {\n dismissOnBlur: this.dismissOnBlur,\n enableAnimations: this.enableAnimations,\n horizontalAlignment: this.alignment,\n isStatic: false,\n placement: this.placement,\n popoverTitle: this.popoverTitle,\n popoverType: this.popoverType,\n });\n }\n\n /**\n * Closes the popover.\n * @internal\n */\n public close(): void {\n /*istanbul ignore next*/\n this.contentRef?.close();\n }\n\n /**\n * Brings focus to the popover element if its open.\n * @internal\n */\n public applyFocus(): void {\n /*istanbul ignore next*/\n this.contentRef?.applyFocus();\n }\n\n /**\n * Adds a flag to the popover to close when the mouse leaves the popover's bounds.\n * @internal\n */\n public markForCloseOnMouseLeave(): void {\n this.isMarkedForCloseOnMouseLeave = true;\n }\n\n private setupOverlay(): void {\n const overlay = this.overlayService.create({\n enableScroll: true,\n enablePointerEvents: true,\n });\n\n overlay.backdropClick.pipe(takeUntil(this.ngUnsubscribe)).subscribe(() => {\n if (this.dismissOnBlur) {\n this.close();\n }\n });\n\n const contentRef = overlay.attachComponent(SkyPopoverContentComponent, [\n {\n provide: SkyPopoverContext,\n useValue: new SkyPopoverContext({\n contentTemplateRef: this.templateRef,\n }),\n },\n ]);\n\n contentRef.opened.pipe(takeUntil(this.ngUnsubscribe)).subscribe(() => {\n this.popoverOpened.emit(this);\n });\n\n contentRef.closed.pipe(takeUntil(this.ngUnsubscribe)).subscribe(() => {\n /*istanbul ignore else*/\n if (this.isActive) {\n this.overlayService.close(this.overlay);\n this.overlay = undefined;\n this.isActive = false;\n this.popoverClosed.emit(this);\n }\n });\n\n contentRef.isMouseEnter\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe((isMouseEnter) => {\n this.isMouseEnter = isMouseEnter;\n if (this.isMarkedForCloseOnMouseLeave) {\n this.isMarkedForCloseOnMouseLeave = false;\n this.close();\n }\n });\n\n this.overlay = overlay;\n this.contentRef = contentRef;\n }\n}\n","<ng-template #templateRef>\n <ng-content></ng-content>\n</ng-template>\n"]}
|
|
1
|
+
{"version":3,"file":"popover.component.js","sourceRoot":"","sources":["../../../../../../../../libs/components/popovers/src/lib/modules/popover/popover.component.ts","../../../../../../../../libs/components/popovers/src/lib/modules/popover/popover.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAET,YAAY,EACZ,KAAK,EAEL,MAAM,EACN,WAAW,EACX,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAsB,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEpE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;;;AAStD,MAAM,OAAO,mBAAmB;IAmH9B,YAAoB,cAAiC;QAAjC,mBAAc,GAAd,cAAc,CAAmB;QAjDrD;;WAEG;QAEI,kBAAa,GAAG,IAAI,YAAY,EAAuB,CAAC;QAE/D;;WAEG;QAEI,kBAAa,GAAG,IAAI,YAAY,EAAuB,CAAC;QAE/D;;;WAGG;QACI,aAAQ,GAAG,KAAK,CAAC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CAAC;gBAC1C,IAAI,CAAC,KAAK,EAAE,CAAC;aACd;QACH,CAAC,CAAC,CAAC;QAEL,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;;iHAvOU,mBAAmB;qGAAnB,mBAAmB,6WA8FtB,WAAW,2CCvHrB,2EAGA;4FDsBa,mBAAmB;kBAJ/B,SAAS;mBAAC;oBACT,QAAQ,EAAE,aAAa;oBACvB,WAAW,EAAE,0BAA0B;iBACxC;wGAQY,SAAS;sBADnB,KAAK;gBAeK,aAAa;sBADvB,KAAK;gBAmBK,SAAS;sBADnB,KAAK;gBAaC,YAAY;sBADlB,KAAK;gBAQK,WAAW;sBADrB,KAAK;gBAaC,aAAa;sBADnB,MAAM;gBAOA,aAAa;sBADnB,MAAM;gBAsBC,WAAW;sBAJlB,SAAS;uBAAC,aAAa,EAAE;wBACxB,IAAI,EAAE,WAAW;wBACjB,MAAM,EAAE,IAAI;qBACb","sourcesContent":["import {\n Component,\n ElementRef,\n EventEmitter,\n Input,\n OnDestroy,\n Output,\n TemplateRef,\n ViewChild,\n} from '@angular/core';\nimport { SkyOverlayInstance, SkyOverlayService } from '@skyux/core';\n\nimport { Subject } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\nimport { SkyPopoverContentComponent } from './popover-content.component';\nimport { SkyPopoverContext } from './popover-context';\nimport { SkyPopoverAlignment } from './types/popover-alignment';\nimport { SkyPopoverPlacement } from './types/popover-placement';\nimport { SkyPopoverType } from './types/popover-type';\n\n@Component({\n selector: 'sky-popover',\n templateUrl: './popover.component.html',\n})\nexport class SkyPopoverComponent implements OnDestroy {\n /**\n * Specifies the horizontal alignment of the popover in relation to the trigger element.\n * The `skyPopoverAlignment` property on the popover directive takes precedence over this property when specified.\n * @default \"center\"\n */\n @Input()\n public set alignment(value: SkyPopoverAlignment | undefined) {\n this._alignment = value;\n }\n\n public get alignment(): SkyPopoverAlignment {\n return this._alignment || 'center';\n }\n\n /**\n * Indicates whether to close the popover when it loses focus.\n * To require users to click a trigger button to close the popover, set this input to false.\n * @default true\n */\n @Input()\n public set dismissOnBlur(value: boolean | undefined) {\n this._dismissOnBlur = value;\n }\n\n public get dismissOnBlur(): boolean {\n if (this._dismissOnBlur === undefined) {\n return true;\n }\n\n return this._dismissOnBlur;\n }\n\n /**\n * Specifies the placement of the popover in relation to the trigger element.\n * The `skyPopoverPlacement` property on the popover directive takes precedence over this property when specified.\n * @default \"above\"\n */\n @Input()\n public set placement(value: SkyPopoverPlacement) {\n this._placement = value;\n }\n\n public get placement(): SkyPopoverPlacement {\n return this._placement || 'above';\n }\n\n /**\n * Specifies a title for the popover.\n */\n @Input()\n public popoverTitle: string | undefined;\n\n /**\n * Specifies the type of popover.\n * @default \"info\"\n */\n @Input()\n public set popoverType(value: SkyPopoverType | undefined) {\n this._popoverType = value;\n }\n\n public get popoverType(): SkyPopoverType {\n return this._popoverType || 'info';\n }\n\n /**\n * Fires when users close the popover.\n */\n @Output()\n public popoverClosed = new EventEmitter<SkyPopoverComponent>();\n\n /**\n * Fires when users open the popover.\n */\n @Output()\n public popoverOpened = new EventEmitter<SkyPopoverComponent>();\n\n /**\n * Indicates that the popover is in the process of being opened or closed.\n * @internal\n */\n public isActive = false;\n\n /**\n * Used by unit tests to disable animations since the component is injected at the bottom of the\n * document body.\n * @internal\n */\n public enableAnimations = true;\n\n public isMouseEnter = false;\n\n @ViewChild('templateRef', {\n read: TemplateRef,\n static: true,\n })\n private templateRef!: TemplateRef<unknown>;\n\n private contentRef!: SkyPopoverContentComponent;\n\n private isMarkedForCloseOnMouseLeave = false;\n\n private ngUnsubscribe = new Subject<void>();\n\n private overlay: SkyOverlayInstance | undefined;\n\n private _alignment: SkyPopoverAlignment | undefined;\n\n private _dismissOnBlur: boolean | undefined;\n\n private _placement: SkyPopoverPlacement | undefined;\n\n private _popoverType: SkyPopoverType | undefined;\n\n constructor(private overlayService: SkyOverlayService) {}\n\n public ngOnDestroy(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n\n if (this.overlay) {\n this.overlayService.close(this.overlay);\n this.overlay = undefined;\n }\n }\n\n /**\n * Positions the popover next to a given caller element.\n * @param caller The element that opened the popover.\n * @param placement The placement of the popover.\n * @param alignment The horizontal alignment of the popover.\n * @internal\n */\n public positionNextTo(\n caller: ElementRef,\n placement?: SkyPopoverPlacement,\n alignment?: SkyPopoverAlignment\n ): void {\n if (!this.overlay) {\n this.setupOverlay();\n }\n\n this.placement = placement ?? this.placement;\n this.alignment = alignment ?? this.alignment;\n this.isActive = true;\n\n this.contentRef.open(caller, {\n dismissOnBlur: this.dismissOnBlur,\n enableAnimations: this.enableAnimations,\n horizontalAlignment: this.alignment,\n isStatic: false,\n placement: this.placement,\n popoverTitle: this.popoverTitle,\n popoverType: this.popoverType,\n });\n }\n\n /**\n * Closes the popover.\n * @internal\n */\n public close(): void {\n /*istanbul ignore next*/\n this.contentRef?.close();\n }\n\n /**\n * Brings focus to the popover element if its open.\n * @internal\n */\n public applyFocus(): void {\n /*istanbul ignore next*/\n this.contentRef?.applyFocus();\n }\n\n /**\n * Adds a flag to the popover to close when the mouse leaves the popover's bounds.\n * @internal\n */\n public markForCloseOnMouseLeave(): void {\n this.isMarkedForCloseOnMouseLeave = true;\n }\n\n private setupOverlay(): void {\n const overlay = this.overlayService.create({\n enableScroll: true,\n enablePointerEvents: true,\n });\n\n overlay.backdropClick.pipe(takeUntil(this.ngUnsubscribe)).subscribe(() => {\n if (this.dismissOnBlur) {\n this.close();\n }\n });\n\n const contentRef = overlay.attachComponent(SkyPopoverContentComponent, [\n {\n provide: SkyPopoverContext,\n useValue: new SkyPopoverContext({\n contentTemplateRef: this.templateRef,\n }),\n },\n ]);\n\n contentRef.opened.pipe(takeUntil(this.ngUnsubscribe)).subscribe(() => {\n this.popoverOpened.emit(this);\n });\n\n contentRef.closed.pipe(takeUntil(this.ngUnsubscribe)).subscribe(() => {\n /*istanbul ignore else*/\n if (this.isActive && this.overlay) {\n this.overlayService.close(this.overlay);\n this.overlay = undefined;\n this.isActive = false;\n this.popoverClosed.emit(this);\n }\n });\n\n contentRef.isMouseEnter\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe((isMouseEnter) => {\n this.isMouseEnter = isMouseEnter;\n if (this.isMarkedForCloseOnMouseLeave) {\n this.isMarkedForCloseOnMouseLeave = false;\n this.close();\n }\n });\n\n this.overlay = overlay;\n this.contentRef = contentRef;\n }\n}\n","<ng-template #templateRef>\n <ng-content></ng-content>\n</ng-template>\n"]}
|
|
@@ -133,7 +133,6 @@ export class SkyPopoverDirective {
|
|
|
133
133
|
removeEventListeners() {
|
|
134
134
|
this.ngUnsubscribe.next();
|
|
135
135
|
this.ngUnsubscribe.complete();
|
|
136
|
-
this.ngUnsubscribe = undefined;
|
|
137
136
|
}
|
|
138
137
|
handleIncomingMessages(message) {
|
|
139
138
|
/* tslint:disable-next-line:switch-default */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.directive.js","sourceRoot":"","sources":["../../../../../../../../libs/components/popovers/src/lib/modules/popover/popover.directive.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAqB,MAAM,eAAe,CAAC;AAEhF,OAAO,EAAE,OAAO,EAAgB,SAAS,IAAI,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;;AAOrE,MAAM,OAAO,mBAAmB;IAyD9B,YAAoB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QA3BlC,6BAAwB,GAAG,IAAI,OAAO,EAAqB,CAAC;QAEpE,wDAA4C;QAqBpC,kBAAa,GAAG,IAAI,OAAO,EAAQ,CAAC;QAK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cAAc;iBACzB;iGAOQ,UAAU;sBADhB,KAAK;gBAQC,mBAAmB;sBADzB,KAAK;gBAOK,uBAAuB;sBADjC,KAAK;gBAqBC,mBAAmB;sBADzB,KAAK;gBAOK,iBAAiB;sBAD3B,KAAK","sourcesContent":["import { Directive, ElementRef, Input, OnDestroy, OnInit } from '@angular/core';\n\nimport { Subject, Subscription, fromEvent as observableFromEvent } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\nimport { SkyPopoverComponent } from './popover.component';\nimport { SkyPopoverAlignment } from './types/popover-alignment';\nimport { SkyPopoverMessage } from './types/popover-message';\nimport { SkyPopoverMessageType } from './types/popover-message-type';\nimport { SkyPopoverPlacement } from './types/popover-placement';\nimport { SkyPopoverTrigger } from './types/popover-trigger';\n\n@Directive({\n selector: '[skyPopover]',\n})\nexport class SkyPopoverDirective implements OnInit, OnDestroy {\n /**\n * References the popover component to display. Add this directive to the trigger element that opens the popover.\n * @required\n */\n @Input()\n public skyPopover: SkyPopoverComponent;\n\n /**\n * Specifies the horizontal alignment of the popover in relation to the trigger element.\n * @default \"center\"\n */\n @Input()\n public skyPopoverAlignment: SkyPopoverAlignment;\n\n /**\n * Provides an RxJS `Subject` to send commands to the popover that respect the `SkyPopoverMessage` type.\n */\n @Input()\n public set skyPopoverMessageStream(\n value: Subject<SkyPopoverMessage> | undefined\n ) {\n this._skyPopoverMessageStream = value ?? new Subject<SkyPopoverMessage>();\n this.subscribeMessageStream();\n }\n\n public get skyPopoverMessageStream(): Subject<SkyPopoverMessage> {\n return this._skyPopoverMessageStream;\n }\n\n private _skyPopoverMessageStream = new Subject<SkyPopoverMessage>();\n\n #messageStreamSub: Subscription | undefined;\n\n /**\n * Specifies the placement of the popover in relation to the trigger element.\n * @default \"above\"\n */\n @Input()\n public skyPopoverPlacement: SkyPopoverPlacement;\n\n /**\n * Specifies the user action that displays the popover.\n */\n @Input()\n public set skyPopoverTrigger(value: SkyPopoverTrigger) {\n this._trigger = value;\n }\n\n public get skyPopoverTrigger(): SkyPopoverTrigger {\n return this._trigger || 'click';\n }\n\n private ngUnsubscribe = new Subject<void>();\n\n private _trigger: SkyPopoverTrigger;\n\n constructor(private elementRef: ElementRef) {\n this.subscribeMessageStream();\n }\n\n public ngOnInit(): void {\n this.addEventListeners();\n }\n\n public ngOnDestroy(): void {\n this.removeEventListeners();\n this.unsubscribeMessageStream();\n }\n\n public togglePopover(): void {\n if (this.skyPopover.isActive) {\n this.sendMessage(SkyPopoverMessageType.Close);\n return;\n }\n\n this.sendMessage(SkyPopoverMessageType.Open);\n }\n\n private positionPopover(): void {\n this.skyPopover.positionNextTo(\n this.elementRef,\n this.skyPopoverPlacement,\n this.skyPopoverAlignment\n );\n }\n\n private closePopover(): void {\n this.skyPopover.close();\n }\n\n private closePopoverOrMarkForClose(): void {\n if (this.skyPopover.isMouseEnter) {\n this.skyPopover.markForCloseOnMouseLeave();\n } else {\n this.sendMessage(SkyPopoverMessageType.Close);\n }\n }\n\n private addEventListeners(): void {\n const element = this.elementRef.nativeElement;\n\n observableFromEvent(element, 'keydown')\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe((event: KeyboardEvent) => {\n if (!this.skyPopover.isActive) {\n return;\n }\n\n const key = event.key.toLowerCase();\n\n /* tslint:disable-next-line:switch-default */\n switch (key) {\n case 'escape':\n this.sendMessage(SkyPopoverMessageType.Close);\n event.preventDefault();\n event.stopPropagation();\n break;\n\n case 'tab':\n if (this.skyPopover.dismissOnBlur) {\n this.sendMessage(SkyPopoverMessageType.Close);\n }\n break;\n\n case 'arrowdown':\n case 'arrowleft':\n case 'arrowright':\n case 'arrowup':\n case 'down':\n case 'left':\n case 'right':\n case 'up':\n this.sendMessage(SkyPopoverMessageType.Focus);\n event.stopPropagation();\n event.preventDefault();\n break;\n }\n });\n\n observableFromEvent(element, 'click')\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe(() => {\n if (this.skyPopover) {\n this.togglePopover();\n }\n });\n\n observableFromEvent(element, 'mouseenter')\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe(() => {\n if (this.skyPopover) {\n this.skyPopover.isMouseEnter = true;\n if (\n !this.skyPopover.isActive &&\n this.skyPopoverTrigger === 'mouseenter'\n ) {\n this.sendMessage(SkyPopoverMessageType.Open);\n }\n }\n });\n\n observableFromEvent(element, 'mouseleave')\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe(() => {\n if (this.skyPopover) {\n this.skyPopover.isMouseEnter = false;\n if (\n this.skyPopover.isActive &&\n this.skyPopoverTrigger === 'mouseenter'\n ) {\n // Give the popover a chance to set its isMouseEnter flag before checking to see\n // if it should be closed.\n setTimeout(() => {\n this.closePopoverOrMarkForClose();\n });\n }\n }\n });\n }\n\n private removeEventListeners(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n this.ngUnsubscribe = undefined;\n }\n\n private handleIncomingMessages(message: SkyPopoverMessage): void {\n /* tslint:disable-next-line:switch-default */\n switch (message.type) {\n case SkyPopoverMessageType.Open:\n this.positionPopover();\n break;\n\n case SkyPopoverMessageType.Close:\n /*istanbul ignore else*/\n if (this.skyPopover.isActive) {\n this.closePopover();\n }\n break;\n\n case SkyPopoverMessageType.Reposition:\n // Only reposition the popover if it is already open.\n if (this.skyPopover.isActive) {\n this.positionPopover();\n }\n break;\n\n case SkyPopoverMessageType.Focus:\n this.skyPopover.applyFocus();\n break;\n }\n }\n\n private sendMessage(messageType: SkyPopoverMessageType): void {\n this.skyPopoverMessageStream.next({ type: messageType });\n }\n\n private subscribeMessageStream(): void {\n this.unsubscribeMessageStream();\n\n this.#messageStreamSub = this.skyPopoverMessageStream.subscribe(\n (message) => {\n this.handleIncomingMessages(message);\n }\n );\n }\n\n private unsubscribeMessageStream(): void {\n if (this.#messageStreamSub) {\n this.#messageStreamSub.unsubscribe();\n this.#messageStreamSub = undefined;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"popover.directive.js","sourceRoot":"","sources":["../../../../../../../../libs/components/popovers/src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C;IAEO,sBAAsB;QAC5B,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAEhC,uBAAA,IAAI,yCAAqB,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAC7D,CAAC,OAAO,EAAE,EAAE;YACV,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC,CACF,MAAA,CAAC;IACJ,CAAC;IAEO,wBAAwB;QAC9B,IAAI,uBAAA,IAAI,6CAAkB,EAAE;YAC1B,uBAAA,IAAI,6CAAkB,CAAC,WAAW,EAAE,CAAC;YACrC,uBAAA,IAAI,yCAAqB,SAAS,MAAA,CAAC;SACpC;IACH,CAAC;;;iHAtOU,mBAAmB;qGAAnB,mBAAmB;4FAAnB,mBAAmB;kBAH/B,SAAS;mBAAC;oBACT,QAAQ,EAAE,cAAc;iBACzB;iGAOQ,UAAU;sBADhB,KAAK;gBAOC,mBAAmB;sBADzB,KAAK;gBAOK,uBAAuB;sBADjC,KAAK;gBAoBC,mBAAmB;sBADzB,KAAK;gBAOK,iBAAiB;sBAD3B,KAAK","sourcesContent":["import { Directive, ElementRef, Input, OnDestroy, OnInit } from '@angular/core';\n\nimport { Subject, Subscription, fromEvent as observableFromEvent } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\nimport { SkyPopoverComponent } from './popover.component';\nimport { SkyPopoverAlignment } from './types/popover-alignment';\nimport { SkyPopoverMessage } from './types/popover-message';\nimport { SkyPopoverMessageType } from './types/popover-message-type';\nimport { SkyPopoverPlacement } from './types/popover-placement';\nimport { SkyPopoverTrigger } from './types/popover-trigger';\n\n@Directive({\n selector: '[skyPopover]',\n})\nexport class SkyPopoverDirective implements OnInit, OnDestroy {\n /**\n * References the popover component to display. Add this directive to the trigger element that opens the popover.\n * @required\n */\n @Input()\n public skyPopover!: SkyPopoverComponent;\n\n /**\n * Specifies the horizontal alignment of the popover in relation to the trigger element.\n */\n @Input()\n public skyPopoverAlignment: SkyPopoverAlignment | undefined;\n\n /**\n * Provides an RxJS `Subject` to send commands to the popover that respect the `SkyPopoverMessage` type.\n */\n @Input()\n public set skyPopoverMessageStream(\n value: Subject<SkyPopoverMessage> | undefined\n ) {\n this._skyPopoverMessageStream = value ?? new Subject<SkyPopoverMessage>();\n this.subscribeMessageStream();\n }\n\n public get skyPopoverMessageStream(): Subject<SkyPopoverMessage> {\n return this._skyPopoverMessageStream;\n }\n\n private _skyPopoverMessageStream = new Subject<SkyPopoverMessage>();\n\n #messageStreamSub: Subscription | undefined;\n\n /**\n * Specifies the placement of the popover in relation to the trigger element.\n */\n @Input()\n public skyPopoverPlacement: SkyPopoverPlacement | undefined;\n\n /**\n * Specifies the user action that displays the popover.\n */\n @Input()\n public set skyPopoverTrigger(value: SkyPopoverTrigger | undefined) {\n this._trigger = value;\n }\n\n public get skyPopoverTrigger(): SkyPopoverTrigger {\n return this._trigger || 'click';\n }\n\n private ngUnsubscribe = new Subject<void>();\n\n private _trigger: SkyPopoverTrigger | undefined;\n\n constructor(private elementRef: ElementRef) {\n this.subscribeMessageStream();\n }\n\n public ngOnInit(): void {\n this.addEventListeners();\n }\n\n public ngOnDestroy(): void {\n this.removeEventListeners();\n this.unsubscribeMessageStream();\n }\n\n public togglePopover(): void {\n if (this.skyPopover.isActive) {\n this.sendMessage(SkyPopoverMessageType.Close);\n return;\n }\n\n this.sendMessage(SkyPopoverMessageType.Open);\n }\n\n private positionPopover(): void {\n this.skyPopover.positionNextTo(\n this.elementRef,\n this.skyPopoverPlacement,\n this.skyPopoverAlignment\n );\n }\n\n private closePopover(): void {\n this.skyPopover.close();\n }\n\n private closePopoverOrMarkForClose(): void {\n if (this.skyPopover.isMouseEnter) {\n this.skyPopover.markForCloseOnMouseLeave();\n } else {\n this.sendMessage(SkyPopoverMessageType.Close);\n }\n }\n\n private addEventListeners(): void {\n const element = this.elementRef.nativeElement;\n\n observableFromEvent<KeyboardEvent>(element, 'keydown')\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe((event) => {\n if (!this.skyPopover.isActive) {\n return;\n }\n\n const key = event.key.toLowerCase();\n\n /* tslint:disable-next-line:switch-default */\n switch (key) {\n case 'escape':\n this.sendMessage(SkyPopoverMessageType.Close);\n event.preventDefault();\n event.stopPropagation();\n break;\n\n case 'tab':\n if (this.skyPopover.dismissOnBlur) {\n this.sendMessage(SkyPopoverMessageType.Close);\n }\n break;\n\n case 'arrowdown':\n case 'arrowleft':\n case 'arrowright':\n case 'arrowup':\n case 'down':\n case 'left':\n case 'right':\n case 'up':\n this.sendMessage(SkyPopoverMessageType.Focus);\n event.stopPropagation();\n event.preventDefault();\n break;\n }\n });\n\n observableFromEvent(element, 'click')\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe(() => {\n if (this.skyPopover) {\n this.togglePopover();\n }\n });\n\n observableFromEvent(element, 'mouseenter')\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe(() => {\n if (this.skyPopover) {\n this.skyPopover.isMouseEnter = true;\n if (\n !this.skyPopover.isActive &&\n this.skyPopoverTrigger === 'mouseenter'\n ) {\n this.sendMessage(SkyPopoverMessageType.Open);\n }\n }\n });\n\n observableFromEvent(element, 'mouseleave')\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe(() => {\n if (this.skyPopover) {\n this.skyPopover.isMouseEnter = false;\n if (\n this.skyPopover.isActive &&\n this.skyPopoverTrigger === 'mouseenter'\n ) {\n // Give the popover a chance to set its isMouseEnter flag before checking to see\n // if it should be closed.\n setTimeout(() => {\n this.closePopoverOrMarkForClose();\n });\n }\n }\n });\n }\n\n private removeEventListeners(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n }\n\n private handleIncomingMessages(message: SkyPopoverMessage): void {\n /* tslint:disable-next-line:switch-default */\n switch (message.type) {\n case SkyPopoverMessageType.Open:\n this.positionPopover();\n break;\n\n case SkyPopoverMessageType.Close:\n /*istanbul ignore else*/\n if (this.skyPopover.isActive) {\n this.closePopover();\n }\n break;\n\n case SkyPopoverMessageType.Reposition:\n // Only reposition the popover if it is already open.\n if (this.skyPopover.isActive) {\n this.positionPopover();\n }\n break;\n\n case SkyPopoverMessageType.Focus:\n this.skyPopover.applyFocus();\n break;\n }\n }\n\n private sendMessage(messageType: SkyPopoverMessageType): void {\n this.skyPopoverMessageStream.next({ type: messageType });\n }\n\n private subscribeMessageStream(): void {\n this.unsubscribeMessageStream();\n\n this.#messageStreamSub = this.skyPopoverMessageStream.subscribe(\n (message) => {\n this.handleIncomingMessages(message);\n }\n );\n }\n\n private unsubscribeMessageStream(): void {\n if (this.#messageStreamSub) {\n this.#messageStreamSub.unsubscribe();\n this.#messageStreamSub = undefined;\n }\n }\n}\n"]}
|
|
@@ -71,6 +71,9 @@ export class SkyDropdownFixture {
|
|
|
71
71
|
clickDropdownItem(index) {
|
|
72
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
73
|
const itemEls = this.getDropdownItemEls();
|
|
74
|
+
if (!itemEls) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
74
77
|
if (index >= itemEls.length) {
|
|
75
78
|
throw new Error(`There is no dropdown item at index ${index}.`);
|
|
76
79
|
}
|
|
@@ -84,6 +87,9 @@ export class SkyDropdownFixture {
|
|
|
84
87
|
*/
|
|
85
88
|
getDropdownItem(index) {
|
|
86
89
|
const itemEls = this.getDropdownItemEls();
|
|
90
|
+
if (!itemEls) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
87
93
|
if (index >= itemEls.length) {
|
|
88
94
|
throw new Error(`There is no dropdown item at index ${index}.`);
|
|
89
95
|
}
|
|
@@ -125,7 +131,7 @@ export class SkyDropdownFixture {
|
|
|
125
131
|
}
|
|
126
132
|
getButtonType(classNames) {
|
|
127
133
|
const prefix = 'sky-dropdown-button-type-';
|
|
128
|
-
for (
|
|
134
|
+
for (const i in classNames) {
|
|
129
135
|
if (classNames[i]) {
|
|
130
136
|
if (i.indexOf(prefix) > -1) {
|
|
131
137
|
return i.replace(prefix, '');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown-fixture.js","sourceRoot":"","sources":["../../../../../../../libs/components/popovers/testing/src/dropdown/dropdown-fixture.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAMvD;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IAuD7B,YAAoB,
|
|
1
|
+
{"version":3,"file":"dropdown-fixture.js","sourceRoot":"","sources":["../../../../../../../libs/components/popovers/testing/src/dropdown/dropdown-fixture.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAMvD;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IAuD7B,YAAoB,OAAkC,EAAE,SAAiB;QAArD,YAAO,GAAP,OAAO,CAA2B;QACpD,IAAI,CAAC,OAAO,GAAG,iBAAiB,CAAC,uBAAuB,CACtD,OAAO,EACP,SAAS,EACT,cAAc,CACf,CAAC;IACJ,CAAC;IA5DD;;OAEG;IACH,IAAW,QAAQ;QACjB,MAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC;QAEvC,IAAI,CAAC,MAAM,EAAE;YACX,OAAO;SACR;QAED,OAAO;YACL,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;YAChD,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC;YAC9C,QAAQ,EAAE,MAAM,CAAC,aAAa,CAAC,QAAQ;YACvC,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,YAAY,CAAC;YACtD,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC;SAClD,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,IAAW,kBAAkB;QAC3B,OAAO,i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,EAAE;YAC1B,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE;gBACjB,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;oBAC1B,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;iBAC9B;aACF;SACF;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { DebugElement } from '@angular/core';\nimport { ComponentFixture } from '@angular/core/testing';\nimport { By } from '@angular/platform-browser';\nimport { SkyAppTestUtility } from '@skyux-sdk/testing';\n\nimport { SkyPopoversFixtureDropdown } from './popovers-fixture-dropdown';\nimport { SkyPopoversFixtureDropdownItem } from './popovers-fixture-dropdown-item';\nimport { SkyPopoversFixtureDropdownMenu } from './popovers-fixture-dropdown-menu';\n\n/**\n * Provides information for and interaction with a SKY UX dropdown component.\n * By using the fixture API, a test insulates itself against updates to the internals\n * of a component, such as changing its DOM structure.\n */\nexport class SkyDropdownFixture {\n /**\n * Returns information about the dropdown component.\n */\n public get dropdown(): SkyPopoversFixtureDropdown | undefined {\n const button = this.buttonDebugElement;\n\n if (!button) {\n return;\n }\n\n return {\n buttonStyle: this.getButtonStyle(button.classes),\n buttonType: this.getButtonType(button.classes),\n disabled: button.nativeElement.disabled,\n label: button.nativeElement.getAttribute('aria-label'),\n title: button.nativeElement.getAttribute('title'),\n };\n }\n\n /**\n * Returns the dropdown button's text.\n */\n public get dropdownButtonText(): string | undefined {\n return SkyAppTestUtility.getText(this.buttonDebugElement.nativeElement);\n }\n\n /**\n * Returns information about the dropdown menu component.\n */\n public get dropdownMenu(): SkyPopoversFixtureDropdownMenu | undefined {\n const menu = this.getDropdownMenuContent();\n if (!menu) {\n return;\n }\n\n return {\n ariaLabelledBy: menu.getAttribute('aria-labelledby'),\n ariaRole: menu.getAttribute('role'),\n };\n }\n\n /**\n * Indicates if the dropdown menu is open and visible.\n */\n public get dropdownMenuIsVisible(): boolean {\n return this.getDropdownMenuContent() !== undefined;\n }\n\n private get buttonDebugElement(): DebugElement {\n return this.debugEl.query(By.css('.sky-dropdown-button'));\n }\n\n private debugEl: DebugElement;\n\n constructor(private fixture: ComponentFixture<unknown>, skyTestId: string) {\n this.debugEl = SkyAppTestUtility.getDebugElementByTestId(\n fixture,\n skyTestId,\n 'sky-dropdown'\n );\n }\n\n /**\n * Click the dropdown button to open or close the dropdown menu.\n */\n public async clickDropdownButton(): Promise<unknown> {\n this.buttonDebugElement.nativeElement.click();\n this.fixture.detectChanges();\n return this.fixture.whenStable();\n }\n\n /**\n * Click the dropdown item at the provided index.\n */\n public async clickDropdownItem(index: number): Promise<unknown> {\n const itemEls = this.getDropdownItemEls();\n\n if (!itemEls) {\n return;\n }\n\n if (index >= itemEls.length) {\n throw new Error(`There is no dropdown item at index ${index}.`);\n }\n\n itemEls[index].querySelector('button,a').click();\n\n this.fixture.detectChanges();\n return this.fixture.whenStable();\n }\n\n /**\n * Returns information about the dropdown item at the provided index.\n */\n public getDropdownItem(\n index: number\n ): SkyPopoversFixtureDropdownItem | undefined {\n const itemEls = this.getDropdownItemEls();\n\n if (!itemEls) {\n return;\n }\n\n if (index >= itemEls.length) {\n throw new Error(`There is no dropdown item at index ${index}.`);\n }\n\n const item = itemEls[index];\n if (!item) {\n return;\n }\n\n return {\n ariaRole: item.getAttribute('role'),\n };\n }\n\n /**\n * Returns the contents of the dropdown menu.\n */\n public getDropdownMenuContent(): any {\n const overlay = this.getOverlay();\n if (!overlay) {\n return;\n }\n\n return overlay.querySelector('.sky-dropdown-menu');\n }\n\n private getDropdownItemEls(): NodeListOf<any> | undefined {\n const overlay = this.getOverlay();\n\n if (!overlay) {\n return;\n }\n\n return overlay.querySelectorAll('.sky-dropdown-item');\n }\n\n private getOverlay(): HTMLElement | null {\n return document.querySelector('sky-overlay');\n }\n\n private getButtonStyle(classNames: {\n [key: string]: boolean;\n }): string | undefined {\n if (classNames['sky-btn-primary']) {\n return 'primary';\n }\n if (classNames['sky-btn-default']) {\n return 'default';\n }\n }\n\n private getButtonType(classNames: {\n [key: string]: boolean;\n }): string | undefined {\n const prefix = 'sky-dropdown-button-type-';\n\n for (const i in classNames) {\n if (classNames[i]) {\n if (i.indexOf(prefix) > -1) {\n return i.replace(prefix, '');\n }\n }\n }\n\n return undefined;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popovers-fixture-dropdown.js","sourceRoot":"","sources":["../../../../../../../libs/components/popovers/testing/src/dropdown/popovers-fixture-dropdown.ts"],"names":[],"mappings":"","sourcesContent":["export interface SkyPopoversFixtureDropdown {\n buttonStyle
|
|
1
|
+
{"version":3,"file":"popovers-fixture-dropdown.js","sourceRoot":"","sources":["../../../../../../../libs/components/popovers/testing/src/dropdown/popovers-fixture-dropdown.ts"],"names":[],"mappings":"","sourcesContent":["export interface SkyPopoversFixtureDropdown {\n buttonStyle?: string;\n buttonType?: string;\n disabled: boolean;\n label: string;\n title: string;\n}\n"]}
|
|
@@ -49,23 +49,23 @@ export class SkyPopoverFixture {
|
|
|
49
49
|
}
|
|
50
50
|
//#region helpers
|
|
51
51
|
get contentElement() {
|
|
52
|
-
return this.queryOverlay('sky-popover-content');
|
|
52
|
+
return this.queryOverlay('sky-popover-content') || undefined;
|
|
53
53
|
}
|
|
54
54
|
get containerElement() {
|
|
55
|
-
return this.queryOverlay('.sky-popover-container');
|
|
55
|
+
return this.queryOverlay('.sky-popover-container') || undefined;
|
|
56
56
|
}
|
|
57
57
|
get titleElement() {
|
|
58
|
-
return this.queryOverlay('.sky-popover-title');
|
|
58
|
+
return this.queryOverlay('.sky-popover-title') || undefined;
|
|
59
59
|
}
|
|
60
60
|
get bodyElement() {
|
|
61
|
-
return this.queryOverlay('.sky-popover-body');
|
|
61
|
+
return this.queryOverlay('.sky-popover-body') || undefined;
|
|
62
62
|
}
|
|
63
63
|
getOverlay() {
|
|
64
|
-
return document.querySelector('sky-overlay');
|
|
64
|
+
return document.querySelector('sky-overlay') || undefined;
|
|
65
65
|
}
|
|
66
66
|
queryOverlay(query) {
|
|
67
67
|
const overlay = this.getOverlay();
|
|
68
|
-
return !overlay ?
|
|
68
|
+
return !overlay ? null : overlay.querySelector(query);
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Searches the element's class names for a class which matches a given prefix.
|
|
@@ -78,8 +78,8 @@ export class SkyPopoverFixture {
|
|
|
78
78
|
* @param prefix
|
|
79
79
|
*/
|
|
80
80
|
getClassSuffixByClassPrefix(element, prefix) {
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
const containerClasses = element === null || element === void 0 ? void 0 : element.className.split(' ');
|
|
82
|
+
const prefixedClass = containerClasses === null || containerClasses === void 0 ? void 0 : containerClasses.find((x) => x.startsWith(prefix));
|
|
83
83
|
return !prefixedClass ? undefined : prefixedClass.slice(prefix.length);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover-fixture.js","sourceRoot":"","sources":["../../../../../../../libs/components/popovers/testing/src/popover/popover-fixture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IA0C5B,YAAoB,
|
|
1
|
+
{"version":3,"file":"popover-fixture.js","sourceRoot":"","sources":["../../../../../../../libs/components/popovers/testing/src/popover/popover-fixture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IA0C5B,YAAoB,OAAkC;QAAlC,YAAO,GAAP,OAAO,CAA2B;IAAG,CAAC;IAzC1D;;OAEG;IACH,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,2BAA2B,CACrC,IAAI,CAAC,gBAAgB,EACrB,wBAAwB,CACzB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACb,OAAO,IAAI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,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC;IAED;;;;;;;;;OASG;IACK,2BAA2B,CACjC,OAAgC,EAChC,MAAc;QAEd,MAAM,gBAAgB,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvD,MAAM,aAAa,GAAG,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QAE1E,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzE,CAAC;CAEF","sourcesContent":["import { ComponentFixture } from '@angular/core/testing';\nimport { SkyAppTestUtility } from '@skyux-sdk/testing';\n\n/**\n * Provides information for and interaction with a SKY UX popover component.\n * By using the fixture API, a test insulates itself against updates to the internals\n * of a component, such as changing its DOM structure.\n */\nexport class SkyPopoverFixture {\n /**\n * Returns the popover alignment if the popover is open, otherwise undefined.\n */\n public get alignment(): string | undefined {\n return this.getClassSuffixByClassPrefix(\n this.containerElement,\n 'sky-popover-alignment-'\n );\n }\n\n /**\n * Returns the popover body element if the popover is open, otherwise undefined.\n */\n public get body(): HTMLElement | undefined {\n return this.bodyElement;\n }\n\n /**\n * Returns the popover position if the popover is open, otherwise undefined.\n */\n public get placement(): string | undefined {\n return this.getClassSuffixByClassPrefix(\n this.containerElement,\n 'sky-popover-placement-'\n );\n }\n\n /**\n * Returns the popover title text if the popover is open, otherwise undefined.\n */\n public get popoverTitle(): string | undefined {\n return SkyAppTestUtility.getText(this.titleElement);\n }\n\n /**\n * Indicates if the popover is open and visible.\n */\n public get popoverIsVisible(): boolean {\n return this.contentElement !== undefined;\n }\n\n constructor(private fixture: ComponentFixture<unknown>) {}\n\n /**\n * Triggers the blur event for the popover.\n */\n public blur(): Promise<unknown> {\n // close the popover by changing focus to the body element\n SkyAppTestUtility.fireDomEvent(window.document.body, 'click');\n\n this.fixture.detectChanges();\n return this.fixture.whenStable();\n }\n\n //#region helpers\n private get contentElement(): HTMLElement | undefined {\n return this.queryOverlay('sky-popover-content') || undefined;\n }\n\n private get containerElement(): HTMLElement | undefined {\n return this.queryOverlay('.sky-popover-container') || undefined;\n }\n\n private get titleElement(): HTMLElement | undefined {\n return this.queryOverlay('.sky-popover-title') || undefined;\n }\n\n private get bodyElement(): HTMLElement | undefined {\n return this.queryOverlay('.sky-popover-body') || undefined;\n }\n\n private getOverlay(): Element | undefined {\n return document.querySelector('sky-overlay') || undefined;\n }\n\n private queryOverlay(query: string): HTMLElement | null {\n const overlay = this.getOverlay();\n\n return !overlay ? null : overlay.querySelector(query);\n }\n\n /**\n * Searches the element's class names for a class which matches a given prefix.\n * If a match is found, the prefix is trimmed from the class name and the suffix is returned.\n * If no class matching the prefix is found, undefined is returned.\n *\n * Example:\n * For a class 'sky-popover-placement-right', passing the prefix 'sky-popover-placement-'\n * should return the value 'right'.\n * @param prefix\n */\n private getClassSuffixByClassPrefix(\n element: HTMLElement | undefined,\n prefix: string\n ): string | undefined {\n const containerClasses = element?.className.split(' ');\n const prefixedClass = containerClasses?.find((x) => x.startsWith(prefix));\n\n return !prefixedClass ? undefined : prefixedClass.slice(prefix.length);\n }\n //#endregion\n}\n"]}
|
|
@@ -89,6 +89,9 @@ class SkyDropdownFixture {
|
|
|
89
89
|
clickDropdownItem(index) {
|
|
90
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
91
|
const itemEls = this.getDropdownItemEls();
|
|
92
|
+
if (!itemEls) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
92
95
|
if (index >= itemEls.length) {
|
|
93
96
|
throw new Error(`There is no dropdown item at index ${index}.`);
|
|
94
97
|
}
|
|
@@ -102,6 +105,9 @@ class SkyDropdownFixture {
|
|
|
102
105
|
*/
|
|
103
106
|
getDropdownItem(index) {
|
|
104
107
|
const itemEls = this.getDropdownItemEls();
|
|
108
|
+
if (!itemEls) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
105
111
|
if (index >= itemEls.length) {
|
|
106
112
|
throw new Error(`There is no dropdown item at index ${index}.`);
|
|
107
113
|
}
|
|
@@ -143,7 +149,7 @@ class SkyDropdownFixture {
|
|
|
143
149
|
}
|
|
144
150
|
getButtonType(classNames) {
|
|
145
151
|
const prefix = 'sky-dropdown-button-type-';
|
|
146
|
-
for (
|
|
152
|
+
for (const i in classNames) {
|
|
147
153
|
if (classNames[i]) {
|
|
148
154
|
if (i.indexOf(prefix) > -1) {
|
|
149
155
|
return i.replace(prefix, '');
|
|
@@ -228,23 +234,23 @@ class SkyPopoverFixture {
|
|
|
228
234
|
}
|
|
229
235
|
//#region helpers
|
|
230
236
|
get contentElement() {
|
|
231
|
-
return this.queryOverlay('sky-popover-content');
|
|
237
|
+
return this.queryOverlay('sky-popover-content') || undefined;
|
|
232
238
|
}
|
|
233
239
|
get containerElement() {
|
|
234
|
-
return this.queryOverlay('.sky-popover-container');
|
|
240
|
+
return this.queryOverlay('.sky-popover-container') || undefined;
|
|
235
241
|
}
|
|
236
242
|
get titleElement() {
|
|
237
|
-
return this.queryOverlay('.sky-popover-title');
|
|
243
|
+
return this.queryOverlay('.sky-popover-title') || undefined;
|
|
238
244
|
}
|
|
239
245
|
get bodyElement() {
|
|
240
|
-
return this.queryOverlay('.sky-popover-body');
|
|
246
|
+
return this.queryOverlay('.sky-popover-body') || undefined;
|
|
241
247
|
}
|
|
242
248
|
getOverlay() {
|
|
243
|
-
return document.querySelector('sky-overlay');
|
|
249
|
+
return document.querySelector('sky-overlay') || undefined;
|
|
244
250
|
}
|
|
245
251
|
queryOverlay(query) {
|
|
246
252
|
const overlay = this.getOverlay();
|
|
247
|
-
return !overlay ?
|
|
253
|
+
return !overlay ? null : overlay.querySelector(query);
|
|
248
254
|
}
|
|
249
255
|
/**
|
|
250
256
|
* Searches the element's class names for a class which matches a given prefix.
|
|
@@ -257,8 +263,8 @@ class SkyPopoverFixture {
|
|
|
257
263
|
* @param prefix
|
|
258
264
|
*/
|
|
259
265
|
getClassSuffixByClassPrefix(element, prefix) {
|
|
260
|
-
|
|
261
|
-
|
|
266
|
+
const containerClasses = element === null || element === void 0 ? void 0 : element.className.split(' ');
|
|
267
|
+
const prefixedClass = containerClasses === null || containerClasses === void 0 ? void 0 : containerClasses.find((x) => x.startsWith(prefix));
|
|
262
268
|
return !prefixedClass ? undefined : prefixedClass.slice(prefix.length);
|
|
263
269
|
}
|
|
264
270
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skyux-popovers-testing.js","sources":["../../../../../libs/components/popovers/testing/src/dropdown/dropdown-testing.module.ts","../../../../../libs/components/popovers/testing/src/dropdown/dropdown-fixture.ts","../../../../../libs/components/popovers/testing/src/popover/popover-testing.module.ts","../../../../../libs/components/popovers/testing/src/popover/popover-fixture.ts","../../../../../libs/components/popovers/testing/src/skyux-popovers-testing.ts"],"sourcesContent":["import { NgModule } from '@angular/core';\nimport { SkyDropdownModule } from '@skyux/popovers';\n\n@NgModule({\n exports: [SkyDropdownModule],\n})\nexport class SkyDropdownTestingModule {}\n","import { DebugElement } from '@angular/core';\nimport { ComponentFixture } from '@angular/core/testing';\nimport { By } from '@angular/platform-browser';\nimport { SkyAppTestUtility } from '@skyux-sdk/testing';\n\nimport { SkyPopoversFixtureDropdown } from './popovers-fixture-dropdown';\nimport { SkyPopoversFixtureDropdownItem } from './popovers-fixture-dropdown-item';\nimport { SkyPopoversFixtureDropdownMenu } from './popovers-fixture-dropdown-menu';\n\n/**\n * Provides information for and interaction with a SKY UX dropdown component.\n * By using the fixture API, a test insulates itself against updates to the internals\n * of a component, such as changing its DOM structure.\n */\nexport class SkyDropdownFixture {\n /**\n * Returns information about the dropdown component.\n */\n public get dropdown(): SkyPopoversFixtureDropdown {\n const button = this.buttonDebugElement;\n\n if (!button) {\n return;\n }\n\n return {\n buttonStyle: this.getButtonStyle(button.classes),\n buttonType: this.getButtonType(button.classes),\n disabled: button.nativeElement.disabled,\n label: button.nativeElement.getAttribute('aria-label'),\n title: button.nativeElement.getAttribute('title'),\n };\n }\n\n /**\n * Returns the dropdown button's text.\n */\n public get dropdownButtonText(): string {\n return SkyAppTestUtility.getText(this.buttonDebugElement.nativeElement);\n }\n\n /**\n * Returns information about the dropdown menu component.\n */\n public get dropdownMenu(): SkyPopoversFixtureDropdownMenu {\n const menu = this.getDropdownMenuContent();\n if (!menu) {\n return;\n }\n\n return {\n ariaLabelledBy: menu.getAttribute('aria-labelledby'),\n ariaRole: menu.getAttribute('role'),\n };\n }\n\n /**\n * Indicates if the dropdown menu is open and visible.\n */\n public get dropdownMenuIsVisible(): boolean {\n return this.getDropdownMenuContent() !== undefined;\n }\n\n private get buttonDebugElement(): DebugElement {\n return this.debugEl.query(By.css('.sky-dropdown-button'));\n }\n\n private debugEl: DebugElement;\n\n constructor(private fixture: ComponentFixture<any>, skyTestId: string) {\n this.debugEl = SkyAppTestUtility.getDebugElementByTestId(\n fixture,\n skyTestId,\n 'sky-dropdown'\n );\n }\n\n /**\n * Click the dropdown button to open or close the dropdown menu.\n */\n public async clickDropdownButton(): Promise<any> {\n this.buttonDebugElement.nativeElement.click();\n this.fixture.detectChanges();\n return this.fixture.whenStable();\n }\n\n /**\n * Click the dropdown item at the provided index.\n */\n public async clickDropdownItem(index: number): Promise<any> {\n const itemEls = this.getDropdownItemEls();\n if (index >= itemEls.length) {\n throw new Error(`There is no dropdown item at index ${index}.`);\n }\n\n itemEls[index].querySelector('button,a').click();\n\n this.fixture.detectChanges();\n return this.fixture.whenStable();\n }\n\n /**\n * Returns information about the dropdown item at the provided index.\n */\n public getDropdownItem(index: number): SkyPopoversFixtureDropdownItem {\n const itemEls = this.getDropdownItemEls();\n if (index >= itemEls.length) {\n throw new Error(`There is no dropdown item at index ${index}.`);\n }\n\n const item = itemEls[index];\n if (!item) {\n return;\n }\n\n return {\n ariaRole: item.getAttribute('role'),\n };\n }\n\n /**\n * Returns the contents of the dropdown menu.\n */\n public getDropdownMenuContent(): any {\n const overlay = this.getOverlay();\n if (!overlay) {\n return;\n }\n\n return overlay.querySelector('.sky-dropdown-menu');\n }\n\n private getDropdownItemEls(): NodeListOf<any> {\n const overlay = this.getOverlay();\n\n if (!overlay) {\n return;\n }\n\n return overlay.querySelectorAll('.sky-dropdown-item');\n }\n\n private getOverlay(): HTMLElement {\n return document.querySelector('sky-overlay');\n }\n\n private getButtonStyle(classNames: { [key: string]: boolean }): string {\n if (classNames['sky-btn-primary']) {\n return 'primary';\n }\n if (classNames['sky-btn-default']) {\n return 'default';\n }\n }\n\n private getButtonType(classNames: { [key: string]: boolean }): string {\n const prefix = 'sky-dropdown-button-type-';\n\n for (let i in classNames) {\n if (classNames[i]) {\n if (i.indexOf(prefix) > -1) {\n return i.replace(prefix, '');\n }\n }\n }\n\n return undefined;\n }\n}\n","import { NgModule } from '@angular/core';\nimport { NoopAnimationsModule } from '@angular/platform-browser/animations';\nimport { SkyPopoverModule } from '@skyux/popovers';\nimport { SkyThemeModule } from '@skyux/theme';\n\n@NgModule({\n exports: [\n SkyPopoverModule,\n\n // The noop animations module needs to be loaded last to avoid\n // subsequent modules adding animations and overriding this.\n NoopAnimationsModule,\n ],\n imports: [SkyThemeModule],\n})\nexport class SkyPopoverTestingModule {}\n","import { ComponentFixture } from '@angular/core/testing';\nimport { SkyAppTestUtility } from '@skyux-sdk/testing';\n\n/**\n * Provides information for and interaction with a SKY UX popover component.\n * By using the fixture API, a test insulates itself against updates to the internals\n * of a component, such as changing its DOM structure.\n */\nexport class SkyPopoverFixture {\n /**\n * Returns the popover alignment if the popover is open, otherwise undefined.\n */\n public get alignment(): string {\n return this.getClassSuffixByClassPrefix(\n this.containerElement,\n 'sky-popover-alignment-'\n );\n }\n\n /**\n * Returns the popover body element if the popover is open, otherwise undefined.\n */\n public get body(): HTMLElement {\n return this.bodyElement;\n }\n\n /**\n * Returns the popover position if the popover is open, otherwise undefined.\n */\n public get placement(): string {\n return this.getClassSuffixByClassPrefix(\n this.containerElement,\n 'sky-popover-placement-'\n );\n }\n\n /**\n * Returns the popover title text if the popover is open, otherwise undefined.\n */\n public get popoverTitle(): string {\n return SkyAppTestUtility.getText(this.titleElement);\n }\n\n /**\n * Indicates if the popover is open and visible.\n */\n public get popoverIsVisible(): boolean {\n return this.contentElement !== undefined;\n }\n\n constructor(private fixture: ComponentFixture<any>) {}\n\n /**\n * Triggers the blur event for the popover.\n */\n public blur(): Promise<any> {\n // close the popover by changing focus to the body element\n SkyAppTestUtility.fireDomEvent(window.document.body, 'click');\n\n this.fixture.detectChanges();\n return this.fixture.whenStable();\n }\n\n //#region helpers\n private get contentElement(): HTMLElement {\n return this.queryOverlay('sky-popover-content');\n }\n\n private get containerElement(): HTMLElement {\n return this.queryOverlay('.sky-popover-container');\n }\n\n private get titleElement(): HTMLElement {\n return this.queryOverlay('.sky-popover-title');\n }\n\n private get bodyElement(): HTMLElement {\n return this.queryOverlay('.sky-popover-body');\n }\n\n private getOverlay(): HTMLElement {\n return document.querySelector('sky-overlay');\n }\n\n private queryOverlay(query: string): HTMLElement {\n const overlay = this.getOverlay();\n\n return !overlay ? undefined : overlay.querySelector(query);\n }\n\n /**\n * Searches the element's class names for a class which matches a given prefix.\n * If a match is found, the prefix is trimmed from the class name and the suffix is returned.\n * If no class matching the prefix is found, undefined is returned.\n *\n * Example:\n * For a class 'sky-popover-placement-right', passing the prefix 'sky-popover-placement-'\n * should return the value 'right'.\n * @param prefix\n */\n private getClassSuffixByClassPrefix(\n element: HTMLElement,\n prefix: string\n ): string {\n let containerClasses = element?.className.split(' ');\n let prefixedClass = containerClasses?.find((x) => x.startsWith(prefix));\n\n return !prefixedClass ? undefined : prefixedClass.slice(prefix.length);\n }\n //#endregion\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],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AG,IAAI,CAAC,UAAU,EAAE,CAAC;QAElC,OAAO,CAAC,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;KAC5D;;;;;;;;;;;IAYO,2BAA2B,CACjC,OAAoB,EACpB,MAAc;QAEd,IAAI,gBAAgB,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrD,IAAI,aAAa,GAAG,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QAExE,OAAO,CAAC,aAAa,GAAG,SAAS,GAAG,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;KACxE;;;AC5GH;;;;;;"}
|
|
1
|
+
{"version":3,"file":"skyux-popovers-testing.js","sources":["../../../../../libs/components/popovers/testing/src/dropdown/dropdown-testing.module.ts","../../../../../libs/components/popovers/testing/src/dropdown/dropdown-fixture.ts","../../../../../libs/components/popovers/testing/src/popover/popover-testing.module.ts","../../../../../libs/components/popovers/testing/src/popover/popover-fixture.ts","../../../../../libs/components/popovers/testing/src/skyux-popovers-testing.ts"],"sourcesContent":["import { NgModule } from '@angular/core';\nimport { SkyDropdownModule } from '@skyux/popovers';\n\n@NgModule({\n exports: [SkyDropdownModule],\n})\nexport class SkyDropdownTestingModule {}\n","import { DebugElement } from '@angular/core';\nimport { ComponentFixture } from '@angular/core/testing';\nimport { By } from '@angular/platform-browser';\nimport { SkyAppTestUtility } from '@skyux-sdk/testing';\n\nimport { SkyPopoversFixtureDropdown } from './popovers-fixture-dropdown';\nimport { SkyPopoversFixtureDropdownItem } from './popovers-fixture-dropdown-item';\nimport { SkyPopoversFixtureDropdownMenu } from './popovers-fixture-dropdown-menu';\n\n/**\n * Provides information for and interaction with a SKY UX dropdown component.\n * By using the fixture API, a test insulates itself against updates to the internals\n * of a component, such as changing its DOM structure.\n */\nexport class SkyDropdownFixture {\n /**\n * Returns information about the dropdown component.\n */\n public get dropdown(): SkyPopoversFixtureDropdown | undefined {\n const button = this.buttonDebugElement;\n\n if (!button) {\n return;\n }\n\n return {\n buttonStyle: this.getButtonStyle(button.classes),\n buttonType: this.getButtonType(button.classes),\n disabled: button.nativeElement.disabled,\n label: button.nativeElement.getAttribute('aria-label'),\n title: button.nativeElement.getAttribute('title'),\n };\n }\n\n /**\n * Returns the dropdown button's text.\n */\n public get dropdownButtonText(): string | undefined {\n return SkyAppTestUtility.getText(this.buttonDebugElement.nativeElement);\n }\n\n /**\n * Returns information about the dropdown menu component.\n */\n public get dropdownMenu(): SkyPopoversFixtureDropdownMenu | undefined {\n const menu = this.getDropdownMenuContent();\n if (!menu) {\n return;\n }\n\n return {\n ariaLabelledBy: menu.getAttribute('aria-labelledby'),\n ariaRole: menu.getAttribute('role'),\n };\n }\n\n /**\n * Indicates if the dropdown menu is open and visible.\n */\n public get dropdownMenuIsVisible(): boolean {\n return this.getDropdownMenuContent() !== undefined;\n }\n\n private get buttonDebugElement(): DebugElement {\n return this.debugEl.query(By.css('.sky-dropdown-button'));\n }\n\n private debugEl: DebugElement;\n\n constructor(private fixture: ComponentFixture<unknown>, skyTestId: string) {\n this.debugEl = SkyAppTestUtility.getDebugElementByTestId(\n fixture,\n skyTestId,\n 'sky-dropdown'\n );\n }\n\n /**\n * Click the dropdown button to open or close the dropdown menu.\n */\n public async clickDropdownButton(): Promise<unknown> {\n this.buttonDebugElement.nativeElement.click();\n this.fixture.detectChanges();\n return this.fixture.whenStable();\n }\n\n /**\n * Click the dropdown item at the provided index.\n */\n public async clickDropdownItem(index: number): Promise<unknown> {\n const itemEls = this.getDropdownItemEls();\n\n if (!itemEls) {\n return;\n }\n\n if (index >= itemEls.length) {\n throw new Error(`There is no dropdown item at index ${index}.`);\n }\n\n itemEls[index].querySelector('button,a').click();\n\n this.fixture.detectChanges();\n return this.fixture.whenStable();\n }\n\n /**\n * Returns information about the dropdown item at the provided index.\n */\n public getDropdownItem(\n index: number\n ): SkyPopoversFixtureDropdownItem | undefined {\n const itemEls = this.getDropdownItemEls();\n\n if (!itemEls) {\n return;\n }\n\n if (index >= itemEls.length) {\n throw new Error(`There is no dropdown item at index ${index}.`);\n }\n\n const item = itemEls[index];\n if (!item) {\n return;\n }\n\n return {\n ariaRole: item.getAttribute('role'),\n };\n }\n\n /**\n * Returns the contents of the dropdown menu.\n */\n public getDropdownMenuContent(): any {\n const overlay = this.getOverlay();\n if (!overlay) {\n return;\n }\n\n return overlay.querySelector('.sky-dropdown-menu');\n }\n\n private getDropdownItemEls(): NodeListOf<any> | undefined {\n const overlay = this.getOverlay();\n\n if (!overlay) {\n return;\n }\n\n return overlay.querySelectorAll('.sky-dropdown-item');\n }\n\n private getOverlay(): HTMLElement | null {\n return document.querySelector('sky-overlay');\n }\n\n private getButtonStyle(classNames: {\n [key: string]: boolean;\n }): string | undefined {\n if (classNames['sky-btn-primary']) {\n return 'primary';\n }\n if (classNames['sky-btn-default']) {\n return 'default';\n }\n }\n\n private getButtonType(classNames: {\n [key: string]: boolean;\n }): string | undefined {\n const prefix = 'sky-dropdown-button-type-';\n\n for (const i in classNames) {\n if (classNames[i]) {\n if (i.indexOf(prefix) > -1) {\n return i.replace(prefix, '');\n }\n }\n }\n\n return undefined;\n }\n}\n","import { NgModule } from '@angular/core';\nimport { NoopAnimationsModule } from '@angular/platform-browser/animations';\nimport { SkyPopoverModule } from '@skyux/popovers';\nimport { SkyThemeModule } from '@skyux/theme';\n\n@NgModule({\n exports: [\n SkyPopoverModule,\n\n // The noop animations module needs to be loaded last to avoid\n // subsequent modules adding animations and overriding this.\n NoopAnimationsModule,\n ],\n imports: [SkyThemeModule],\n})\nexport class SkyPopoverTestingModule {}\n","import { ComponentFixture } from '@angular/core/testing';\nimport { SkyAppTestUtility } from '@skyux-sdk/testing';\n\n/**\n * Provides information for and interaction with a SKY UX popover component.\n * By using the fixture API, a test insulates itself against updates to the internals\n * of a component, such as changing its DOM structure.\n */\nexport class SkyPopoverFixture {\n /**\n * Returns the popover alignment if the popover is open, otherwise undefined.\n */\n public get alignment(): string | undefined {\n return this.getClassSuffixByClassPrefix(\n this.containerElement,\n 'sky-popover-alignment-'\n );\n }\n\n /**\n * Returns the popover body element if the popover is open, otherwise undefined.\n */\n public get body(): HTMLElement | undefined {\n return this.bodyElement;\n }\n\n /**\n * Returns the popover position if the popover is open, otherwise undefined.\n */\n public get placement(): string | undefined {\n return this.getClassSuffixByClassPrefix(\n this.containerElement,\n 'sky-popover-placement-'\n );\n }\n\n /**\n * Returns the popover title text if the popover is open, otherwise undefined.\n */\n public get popoverTitle(): string | undefined {\n return SkyAppTestUtility.getText(this.titleElement);\n }\n\n /**\n * Indicates if the popover is open and visible.\n */\n public get popoverIsVisible(): boolean {\n return this.contentElement !== undefined;\n }\n\n constructor(private fixture: ComponentFixture<unknown>) {}\n\n /**\n * Triggers the blur event for the popover.\n */\n public blur(): Promise<unknown> {\n // close the popover by changing focus to the body element\n SkyAppTestUtility.fireDomEvent(window.document.body, 'click');\n\n this.fixture.detectChanges();\n return this.fixture.whenStable();\n }\n\n //#region helpers\n private get contentElement(): HTMLElement | undefined {\n return this.queryOverlay('sky-popover-content') || undefined;\n }\n\n private get containerElement(): HTMLElement | undefined {\n return this.queryOverlay('.sky-popover-container') || undefined;\n }\n\n private get titleElement(): HTMLElement | undefined {\n return this.queryOverlay('.sky-popover-title') || undefined;\n }\n\n private get bodyElement(): HTMLElement | undefined {\n return this.queryOverlay('.sky-popover-body') || undefined;\n }\n\n private getOverlay(): Element | undefined {\n return document.querySelector('sky-overlay') || undefined;\n }\n\n private queryOverlay(query: string): HTMLElement | null {\n const overlay = this.getOverlay();\n\n return !overlay ? null : overlay.querySelector(query);\n }\n\n /**\n * Searches the element's class names for a class which matches a given prefix.\n * If a match is found, the prefix is trimmed from the class name and the suffix is returned.\n * If no class matching the prefix is found, undefined is returned.\n *\n * Example:\n * For a class 'sky-popover-placement-right', passing the prefix 'sky-popover-placement-'\n * should return the value 'right'.\n * @param prefix\n */\n private getClassSuffixByClassPrefix(\n element: HTMLElement | undefined,\n prefix: string\n ): string | undefined {\n const containerClasses = element?.className.split(' ');\n const prefixedClass = containerClasses?.find((x) => x.startsWith(prefix));\n\n return !prefixedClass ? undefined : prefixedClass.slice(prefix.length);\n }\n //#endregion\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;MAMa,wBAAwB;;sHAAxB,wBAAwB;uHAAxB,wBAAwB,YAFzB,iBAAiB;uHAEhB,wBAAwB,YAFzB,iBAAiB;4FAEhB,wBAAwB;kBAHpC,QAAQ;mBAAC;oBACR,OAAO,EAAE,CAAC,iBAAiB,CAAC;iBAC7B;;;ACID;;;;;MAKa,kBAAkB;IAuD7B,YAAoB,OAAkC,EAAE,SAAiB;QAArD,YAAO,GAAP,OAAO,CAA2B;QACpD,IAAI,CAAC,OAAO,GAAG,iBAAiB,CAAC,uBAAuB,CACtD,OAAO,EACP,SAAS,EACT,cAAc,CACf,CAAC;KACH;;;;IAzDD,IAAW,QAAQ;QACjB,MAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC;QAEvC,IAAI,CAAC,MAAM,EAAE;YACX,OAAO;SACR;QAED,OAAO;YACL,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;YAChD,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC;YAC9C,QAAQ,EAAE,MAAM,CAAC,aAAa,CAAC,QAAQ;YACvC,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,YAAY,CAAC;YACtD,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC;SAClD,CAAC;KACH;;;;IAKD,IAAW,kBAAkB;QAC3B,OAAO,iBAAiB,CAAC,OA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