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

vue-func-windows

v0.0.14

Published

Vue windows by function plugin

Downloads

8

Readme

Installation

npm install vue-func-windows

Usage

this.$windows.show(
    // window id
    "test-window-id",
    // inner component
    {
        componentInstance: () => import(`@/components/TestInnerComponent.vue`),
        events: {
            onTestClick: () => console.log('result test-click')
        },
        props: {
            text: 'Test text'
        },
    },
    // window options
    {
        title: 'TEST TITLE 1',
        top: 'middle',
        left: 'center',
        withoutHideButton: true,
        withoutCloseButton: true,
        withoutHead: true,
        backgroundClassList: ['class2'],
        movable: false,
        withBackground: false,
        events: {
            beforeCreate: (instance) => console.log('Test root beforeCreate event handler', instance),
            created: (instance) => console.log('Test root created event handler', instance),
            beforeShow: (instance) => console.log('Test root beforeShow event handler', instance),
            showed: (instance) => console.log('Test root showed event handler', instance),
            beforeHide: (instance) => console.log('Test root beforeHide event handler', instance),
            hidden: (instance) => console.log('Test root hidden event handler', instance),
            beforeClose: (instance) => console.log('Test root beforeClose event handler', instance),
            closed: (instance) => console.log('Test root closed event handler', instance),
        }
    })

Vue 3 plugin

  • main.js
import {createApp} from 'vue'
import App from './App.vue'
import plugin from "vue-func-windows";

const app = createApp(App)

app.use(plugin)
app.mount('#app')

Nuxt 3 plugin

  • plugins

    | -- windows{.client}.ts

import WindowsManager from 'vue-func-windows'

export default defineNuxtPlugin((nuxtApp) => {
    nuxtApp.vueApp.use(WindowsManager)
    return {
        provide: {
            windows: nuxtApp.vueApp.windows
        }
    }
})

Types

interface WindowsManagerOptionsInterface {
    appContext?: AppContext,
    id?: string | number
}
interface WindowComponentOptionsInterface {
    componentInstance: Promise<any>;
    events?: {
        [innerComponentEventName: string]: (...args: any) => any;
    };
    props?: {
        [innerComponentPropName: string]: any;
    };
}
interface WindowsManagerStateInterface {
    selectedWindowId: WindowInterface['id']
    lastSelectedWindowId: WindowInterface['id']
}
interface WindowsManagerInterface {
    readonly isShowAnyWindow: boolean;
    readonly topShift: number;
    readonly leftShift: number;
    readonly windowsCount: number;
    readonly lastZIndex: number;

    windows: {[windowId: string]: WindowInterface};

    readonly state: WindowsManagerStateInterface;

    show: (
        id: WindowInterface['id'],
        innerComponentOptions: WindowComponentOptionsInterface,
        newWindowOptions?: WindowOptionsInterface
    ) => void;

    hide: (id: WindowInterface['id']) => void
    close: (id: WindowInterface['id']) => void
    removeWindow: (id: WindowInterface['id']) => void
}

type WindowEventType = 'beforeCreate' | 'created' | 'beforeShow' | 'showed' | 'beforeHide' | 'hidden' | 'beforeClose' | 'closed';

type WindowEventsInterface = { [key in WindowEventType]?: (...args: any[]) => any; } // args: this

interface ControlButtonOptionsInterface {
    symbol?: string;
    bgColor?: string;
    symbolColor?: string;
    classList?: string | string[] | Object;
    tag?: string;
    events?: {[EventName: string]: (...args: any[]) => any};
}

interface ControlButtonInterface {
    onPress: (callback: (event: MouseEvent) => any) => any;
    readonly element: HTMLElement;
}

interface HideButtonOptionsInterface extends ControlButtonOptionsInterface  {
    startHidden?: boolean,
    hiddenSymbol?: string;
}
interface HideButtonInterface extends ControlButtonInterface {
    isHidden: boolean;
}

type ClassListType = string | string[] | Object;

// const STATIC_X = ['left', 'center', 'right'] as const;
type StaticXType = typeof STATIC_X[number];
// const STATIC_Y = ['top', 'middle', 'bottom'] as const;
type StaticYType = typeof STATIC_Y[number];
type StaticXYType = StaticXType | StaticYType;

// const POSITION_DEFINITIONS = ['top', 'bottom', 'left', 'right'] as const;
type PositionDefinitionType = typeof POSITION_DEFINITIONS[number];

interface WindowOptionsInterface {
    events?: WindowEventsInterface;
    title?: string;
    top?: StaticYType | `${number}${'px' | '%' | 'vh' | 'cm' | 'mm' | 'pt' | 'em'}`;
    left?: StaticXType | `${number}${'px' | '%' | 'vw' | 'cm' | 'mm' | 'pt' | 'ex'}`;
    withoutHideButton?: boolean;
    withoutCloseButton?: boolean;
    withoutHead?: boolean;
    withBackground?: boolean;
    hideButtonOptions?: HideButtonOptionsInterface;
    closeButtonOptions?: ControlButtonOptionsInterface;
    windowClassList?: ClassListType;
    backgroundClassList?: ClassListType;
    movable?: boolean;
}

type WindowPositionInterface = Partial<Record<PositionDefinitionType, string>>

interface WindowStateInterface {
    isHidden: boolean;
    width: number;
    height: number;
    position: WindowPositionInterface;
}

interface WindowStateWithExecuteInterface extends WindowStateInterface {
    _execute: {[prop in keyof WindowStateInterface]?: Array<(...args: any[]) => any>}
}
interface WindowInterface {
    readonly id: string | number;
    withTitle: () => WindowInterface,
    withHideButton: () => WindowInterface,
    withCloseButton: () => WindowInterface,
    withEvents: (events: WindowEventsInterface) => WindowInterface,
    withInnerComponent: (
        componentInstance: Promise<any> | any,
        {props, events, context}: { props?: {}, events?: {}, context?: {} }
    ) => WindowInterface,

    state: WindowStateInterface;

    readonly isHidden: WindowStateInterface['isHidden'];
    readonly withBackground: WindowOptionsInterface['withBackground'];
    readonly backgroundClassList: string[];
    readonly preparedTitleText: string;

    readonly element: HTMLDivElement;

    show: () => void;
    hide: () => void;
    close: () => void;
}