3.0.0 • Published 2 years ago

vue-m-dialog v3.0.0

Weekly downloads
22
License
-
Repository
github
Last release
2 years ago

Dialog

A Modal component for Vue 3.x.

Please use the 2.x in Vue 2.x.

Live Demo

Preview

Usage

npm install vue-m-dialog
import MDialogPlugin from 'vue-m-dialog'
import 'vue-m-dialog/dist/style.css'

// will set global
// component `<m-dialog></m-dialog`
// method `this.$alert(...)`
// method `this.$confirm(...)`
Vue.use(MDialogPlugin)

// or reset
Vue.use(MDialogPlugin, {
  // <m-dialog></m-dialog>
  dialogName: 'm-dialog',
  // this.msg(...)
  alertName: 'msg',
  // this.confirm(...)
  confirmName: 'confirm',
  // Set default options for messageBox
  messageBoxDefaultOptions: {
    // ...
  },
})
<m-dialog
  v-model="show"
  title="Dialog Title"
  >
  <p>This is body...</p>
  <p>This is body...</p>
  <p>This is body...</p>
  <template v-slot:footer>
    <button class="m-dialog--cancel-btn" @click="show = false">Cancel</button>
    <button class="m-dialog--confirm-btn" @click="show = false">Okey !</button>
  </template>
</m-dialog>

Dialog Attributes

AttributeTypeDescriptionDefault
modelValue/v-modelbooleanVisibility of dialog
titlestringTitle
appendTostringAppend dialog itself to other container; use body, #<ID>, null'body'
classstringCustom class names for dialog
widthstringWidth of dialog'400px'
paddingstringPadding of dialog'25px'
topstringMargin top of dialog'50px'
zIndexstring/numberzIndex for dialog wrapper1000
isMiddlebooleanShow on middlefalse
hideHeaderbooleanHide headerfalse
hasMaskbooleanIt has masktrue
hideCloseButtonbooleanIt has close buttonfalse
canClickMaskClosebooleanWhether can be closed by clicking the maskfalse
draggablebooleanEnable dragging feature for dialogfalse
resetDragbooleanWhether to reset positon when displaying againfalse
isPointerEventsNonebooleanCan click outside dialog when hasMask=falsefalse
beforeClose(cb: (ok: boolean) => void) => voidCallback before closes, and it will prevent Dialog from closing

Dialog Slots

NameDescription
-Content of the dialog
titleContent of the dialog title
footerContent of the dialog footer

Use the defined footer style:

<template v-slot:footer>
  <button class="m-dialog--cancel-btn" @click="show = false">Cancel</button>
  <button class="m-dialog--confirm-btn" @click="show = false">Okey !</button>
</template>

Dialog Events

NameDescriptionParams
closeTriggers when the Dialog closes
openTriggers when the dialog opens

MessageBox

A messageBox mainly for alerting information, confirm operations.

MessageBox plugin base on Dialog component.

import { alert, confirm, createMessageBox, closeAll } from 'vue-m-dialog'

Interface of messageBox

import { AppContext } from 'vue';
export interface MessageBoxOptions {
    title?: string;
    message?: string | JSX.Element | (() => JSX.Element);
    class?: string;
    width?: string;
    padding?: string;
    top?: string;
    zIndex?: string | number;
    isMiddle?: boolean;
    hideHeader?: boolean;
    hasMask?: boolean;
    draggable?: boolean;
    isPointerEventsNone?: boolean;
    showCancelButton?: boolean;
    showConfirmButton?: boolean;
    disableCancelButton?: boolean;
    disableConfirmButton?: boolean;
    cancelButtonText?: string;
    confirmButtonText?: string;
    beforeClose?: (cb: (ok: boolean) => void) => void;
    onOpen?: () => void;
    onRemove?: () => void;
    [key: string]: any;
}
export declare function createMessageBox(options: MessageBoxOptions, context?: AppContext): Promise<{
    action: string;
    ok: boolean;
}>;
export declare const alert: (message: string, title?: string | undefined, options?: MessageBoxOptions | undefined, context?: AppContext | undefined) => Promise<{
    action: string;
    ok: boolean;
}>;
export declare const confirm: (message: string, title?: string | undefined, options?: MessageBoxOptions | undefined, context?: AppContext | undefined) => Promise<{
    action: string;
    ok: boolean;
}>;
export declare const closeAll: () => void;
export declare const setDefaultOptions: (opts?: MessageBoxOptions | undefined) => void;

LICENSE

MIT LICENSE

3.0.0

2 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago