7.0.0 • Published 11 months ago

@muntazir86/material-extended v7.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

Angular Popover

npm (scoped)

Links

Popover Demo | StackBlitz Template | Documentation | npm

Project status

Angular Popover is production ready.

This was originally created as an example for a @angular/material issue feature request. Issue can be found at angular/material2#2691

If you'd like to contribute please create an issue or pull request.

Version Compatibility

Angular VersionPackage Compatibility
18.x7.x
17.x6.x
16.x5.x

Examples

Material theme picker

Material theme picker

Standard popover

image

image

Google+ style popover

image

Installation

Install npm package using:

npm install @muntazir86/material-extended

Install required packages @angular/cdk

yarn add @angular/cdk or npm install @angular/cdk

Initial setup

The CDK overlays depend on a small set of structural styles to work correctly. If you're using Angular Material, these styles have been included together with the theme, otherwise if you're using the CDK on its own, you'll have to include the styles yourself. You can do so by importing the prebuilt styles in your global stylesheet:

@import '@angular/cdk/overlay-prebuilt.css';

Import module

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';


import { AppComponent } from './app.component';
import { MdePopoverModule } from '@muntazir86/material-extended';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    MdePopoverModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Usage

<mde-popover> is a floating panel containing html content.

By itself, the <mde-popover> element does not render anything. The popover is attached to and opened via application of the mdePopoverTriggerFor directive:

<mde-popover #appPopover="mdePopover">
  <button md-button> Settings </button>
  <button md-button> Help </button>
</mde-popover>

<button md-button [mdePopoverTriggerFor]="appPopover"
mdePopoverTriggerOn="click">
   <md-icon>more_vert</md-icon>
</button>

API reference

MdePopover

Selector: mde-popover
Exported as: mdePopover
Properties
NameDescription
@Input('mdePopoverPositionX') positionXPosition of the popover in the X axis. Type: string, Values: 'start' || 'end' || 'before' || 'after' || 'center', Default: 'after'.
@Input('mdePopoverPositionY') positionYPosition of the popover in the Y axis. Type: string, Values: 'start' || 'end' || 'above' || 'below' || 'center', Default: 'below'
@Input('mdePopoverTriggerOn') triggerEventEvent for triggering popover 'click', 'hover' and 'none'. Default: hover
@Input('mdePopoverEnterDelay') enterDelayDelay for popover before enters, Type: number, Default: 200
@Input('mdePopoverLeaveDelay') leaveDelayDelay for popover before leaves, Type: number, Default: 200
@Input('mdePopoverOverlapTrigger') overlapTriggerWhether the popover should overlap its trigger. Type: boolean, Default: true
@Input('mdePopoverOffsetX') targetOffsetXOffset position of the popover from target in the X axis. Type: number, Default: 0
@Input('mdePopoverOffsetY') targetOffsetYOffset position of the popover from target in the Y axis. Type: number, Default: 0
@Input('mdePopoverArrowOffsetX') arrowOffsetXOffset position of the popover arrow from the X axis. Type: number, Default: 0
@Input('mdePopoverArrowOffsetY') arrowOffsetYOffset position of the popover arrow from the Y axis. Type: number, Default: 0
@Input('mdePopoverArrowWidth') arrowWidthArrow width in pixels.
@Input('mdePopoverArrowColor') arrowColorArrow color, accepts CSS color values. Default: rgba(0, 0, 0, 0.12)
@Input('mdePopoverCloseOnClick') closeOnClickWhether the popover should close on click. Type: boolean, Default: true
@Input('mdeFocusTrapEnabled') focusTrapEnabledWhether the popover should focus trap. Type: boolean, Default: true
@Input('mdeFocusTrapAutoCaptureEnabled') focusTrapAutoCaptureEnabledWhether the popover should focus trap auto capture focus. Type: boolean, Default: true
@Input('class') classListThis method takes classes set on the host mde-popover element and applies them on the popover template that displays in the overlay container. Otherwise, it's difficult to style the containing popover from outside the component.
@Output() closeEvent emitted when the popover is closed.
Methods

setPositionClasses

It's necessary to set position-based classes to ensure the popover panel animation folds out from the correct direction.

Parameters
posX?
posY?

MdePopoverTrigger

This directive is intended to be used in conjunction with an mde-popover tag. It is responsible for toggling the display of the provided popover instance.

Selector: [mdePopoverTriggerFor]
Exported as: mdePopoverTrigger
NameDescription
@Input('mdePopoverTriggerFor') popoverReferences the popover instance that the trigger is associated with.
@Input('mdePopoverTargetAt') targetElementReferences the popover target instance that the popover positioning is associated with.
@Input('mdePopoverPositionX') positionXPosition of the popover in the X axis.
@Input('mdePopoverPositionY') positionYPosition of the popover in the Y axis.
@Input('mdePopoverTriggerOn') triggerEventEvent for triggering popover 'click', 'hover' and 'none'. Default: 'hover'
@Input('mdePopoverEnterDelay') enterDelayDelay for popover before enters, Type: number, Default: 200
@Input('mdePopoverLeaveDelay') leaveDelayDelay for popover before leaves, Type: number, Default: 200
@Input('mdePopoverOverlapTrigger') overlapTriggerWhether the popover should overlap its trigger. Type: boolean, Default: true
@Input('mdeDisablePopoverTrigger') disablePopoverTriggerDisables popover trigger. Type: boolean, Default: false
@Input('mdePopoverOffsetX') targetOffsetXOffset position of the popover from target in the X axis. Type: number, Default: 0
@Input('mdePopoverOffsetY') targetOffsetYOffset position of the popover from target in the Y axis. Type: number, Default: 0
@Input('mdePopoverArrowOffsetX') arrowOffsetXOffset position of the popover arrow from the X axis. Type: number, Default: 0
@Input('mdePopoverArrowOffsetY') arrowOffsetXOffset position of the popover arrow from the Y axis. Type: number, Default: 0
@Input('mdePopoverArrowWidth') arrowWidthArrow width in pixels. Type: number, Default: 8
@Input('mdePopoverArrowColor') arrowColorArrow color, accepts CSS color values. Default: rgba(0, 0, 0, 0.12)
@Input('mdePopoverCloseOnClick') closeOnClickWhether the popover should close on click. Type: boolean, Default: true.
@Input('mdePopoverCloseOnClickTrigger') closeOnClickTriggerWhether the popover should close on click of trigger when click event is 'click'. Type: boolean, Default: true.
@Input('mdePopoverBackdropCloseOnClick') backdropCloseOnClickWhether the popover should close on backdrop click. Type: boolean, Default: true.
@Output() openedEvent emitted when the associated popover is opened.
@Output() closedEvent emitted when the associated popover is closed.
Methods

togglePopover Toggles the popover between the open and closed states.

openPopover Opens the popover.

closePopover Closes the popover.

destroyPopover Removes the popover from the DOM.

Issues

Please report bugs and issues here.

License

MIT © Joe Jordan Brown

Angular Popover by UIXD

FOSSA Status

7.0.0

11 months ago

5.2.0

1 year ago

6.1.0

1 year ago

6.0.0

2 years ago

5.0.4

2 years ago

5.0.3

2 years ago

5.1.0

2 years ago

5.0.2

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago