npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng2-window

v1.1.6

Published

A simple and easy-to-use Angular window component with powerful functions, supporting theme customization, and built-in multiple awesome themes.

Downloads

15

Readme

ng2-window

ng2-window is a powerful Angular window component, supports drag, resize, full screen, minimize, and various comprehensive window functions. It supports creation through declaration and service methods, complete window lifecycle management, and highly customizable styles.

screenshot

screenshot screenshot screenshot

Installation

To install ng2-window, simply run:

npm install ng2-window --save

Usage

Import ng2-window module in your Angular app:

import { Ng2WindowModule } from 'ng2-window';

Then add Ng2WindowModule to your app's module imports:

@NgModule({
  imports: [
      Ng2WindowModule
  ]
})
export class AppModule { }

Once the module is installed, you can use WindowService to create window dynamically:

import { Ng2WindowService } from 'ng2-window';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
export class AppComponent {
    constructor(private windowService: Ng2WindowService) { }

    windowManager = {
        tpl: {
            visible: false,
            instance: null,
        },
    };
    
    openWindow(ref: TemplateRef<any>) {
        this.windowService.create({
            title: 'Window 1',
            icon: '/assets/logo.png',
            width: 800,
            height: 500,
            content: ref,
            offsetX: 200,
            offsetY: 100,
            align: 'leftTop',
            bodyStyle: {
                lineHeight: '1.5',
            },
        }).then((win: Ng2WindowComponent) => {
            this.windowManager.tpl.instance = win;

            win.onClose.subscribe(() => {
                this.windowManager.tpl.visible = false;
                this.windowManager.tpl.instance = null;
            });
        });
    }
}

or use ng-window component in your Angular template:

<ng-window [title]="'My window'" [icon]="icon" [width]="800" [height]="600" [offsetX]="100" [offsetY]="100" align="leftTop">
    <ng-template #icon>
        <i class="fa fa-app"></i>
    </ng-template>
  <!-- Window content here -->
</ng-window>

Features

ng2-window supports the following features:

  • Dragging window to move
  • Resizing window to fit content
  • Toggling full screen mode
  • Minimizing window to task bar
  • Comprehensive window functions, such as minimize/maximize/close buttons
  • Complete window lifecycle management, including opening/closing, focusing, and activation tracking
  • Highly customizable styles, with support for customizing window appearance and behavior

API

ng2-window Component

Inputs

  • title (string/TemplateRef): Window title, can be a string or a template
  • icon (string/TemplateRef): Window icon, can be a string or a template
  • align ('leftTop'/'rightTop'/'leftBottom'/'rightBottom'): Window align
  • width (number): Window width
  • height (number): Window height
  • minWidth (number): Window minimum width
  • minHeight (number): Window minimum height
  • offsetX (number): Window offset x, when align is 'leftTop' or 'leftBottom', offsetX is the distance from the left side of the screen, when align is 'rightTop' or 'rightBottom', offsetX is the distance from the right side of the screen
  • offsetY (number): Window offset y, when align is 'leftTop' or 'rightTop', offsetY is the distance from the top of the screen, when align is 'leftBottom' or 'rightBottom', offsetY is the distance from the bottom of the screen
  • closable (boolean): Whether the window can be closed
  • maximizable (boolean): Whether the window can be maximized
  • minimizable (boolean): Whether the window can be minimized
  • outOfBounds (boolean): Whether the window can be dragged out of the screen. if outOfBounds is true and the offsetY < 0, after dragging the window, the offsetY will be set to 0
  • draggable (boolean): Whether the window can be dragged
  • resizable (boolean): Whether the window can be resized
  • loading (boolean): Whether the window is loading
  • loadingTip (string/TemplateRef): Window loading tip, can be a string or a template
  • content (string/TemplateRef): Window content, can be a string or a template
  • contentScrollable (boolean): Whether the window content is scrollable
  • theme ('light'/'dark'): Window theme, default is 'light'
  • zIndex (`number): Window z-index
  • bodyStyle (object): Window body style
  • closeOnNavigation (boolean): Whether to close the window when the route changes
  • language ('en'/'zh'): Window language, default is 'zh', set in WindowService
  • dockTheme ('light'/'dark'): Window dock theme, default is 'light', set in WindowService

Outputs

  • onReady: Emitted when the window is ready
  • onClose: Emitted when the window is closed
  • onResize: Emitted when the window is resized
  • onMaximize: Emitted when the window is maximized
  • onMaximizeRestore: Emitted when the window is restored
  • onMinimize: Emitted when the window is minimized
  • onMinimizeRestore: Emitted when the window is restored
  • onSelected: Emitted when the window is selected
  • onMove: Emitted when the window is moved

Development

To run the demo application:

  1. Clone the repository to your local machine.
  2. Install dependencies using npm install.
  3. Start the demo using npm run start.

Contribution

We welcome community contributions and pull requests. To contribute to ng2-window, please fork the repository and open a pull request.