mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-05-20 13:01:52 +00:00
629 lines
25 KiB
Vue
629 lines
25 KiB
Vue
<template>
|
|
<page-content page-title="Components - Dialog">
|
|
<docs-component>
|
|
<div slot="description">
|
|
<p>Dialogs inform users about a specific task and may contain critical information, require decisions, or involve multiple tasks.</p>
|
|
<p>The dialog component works with any plain html content. You can have tabs, all form components and more.</p>
|
|
<p>Alternativelly you can use three presets to build Alerts, Confirms and Prompt dialogs.</p>
|
|
<p>The preset component is created on top of <code><md-dialog></code>. You should provide the content or the HTML content at least.</p>
|
|
<p>All the pressets can use the same options and events from the <code><md-dialog></code> component.</p>
|
|
</div>
|
|
|
|
<div slot="api">
|
|
<api-table name="md-dialog">
|
|
<md-table slot="properties">
|
|
<md-table-header>
|
|
<md-table-row>
|
|
<md-table-head>Name</md-table-head>
|
|
<md-table-head>Type</md-table-head>
|
|
<md-table-head>Description</md-table-head>
|
|
</md-table-row>
|
|
</md-table-header>
|
|
|
|
<md-table-body>
|
|
<md-table-row>
|
|
<md-table-cell>md-click-outside-to-close</md-table-cell>
|
|
<md-table-cell><code>Boolean</code></md-table-cell>
|
|
<md-table-cell>Enable or disable click outside to close. Default: <code>true</code></md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-esc-to-close</md-table-cell>
|
|
<md-table-cell><code>Boolean</code></md-table-cell>
|
|
<md-table-cell>Enable or disable close on esc key. Default: <code>true</code></md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-backdrop</md-table-cell>
|
|
<md-table-cell><code>Boolean</code></md-table-cell>
|
|
<md-table-cell>Create an opaque backdrop behind the dialog. Default: <code>true</code></md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-open-from</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>The query selector of the element that is used to determine from which the Dialog will open.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-close-to</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>The query selector of the element that is used to determine from which the Dialog will close.</md-table-cell>
|
|
</md-table-row>
|
|
</md-table-body>
|
|
</md-table>
|
|
|
|
<md-table slot="events">
|
|
<md-table-header>
|
|
<md-table-row>
|
|
<md-table-head>Name</md-table-head>
|
|
<md-table-head>Value</md-table-head>
|
|
<md-table-head>Description</md-table-head>
|
|
</md-table-row>
|
|
</md-table-header>
|
|
|
|
<md-table-body>
|
|
<md-table-row>
|
|
<md-table-cell>open</md-table-cell>
|
|
<md-table-cell>Receive the state of the dialog: <code>ok</code>| <code>cancel</code> <br>Works only for Confirm and Prompt</md-table-cell>
|
|
<md-table-cell>Triggered when the dialog open.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>close</md-table-cell>
|
|
<md-table-cell>Receive the state of the dialog: <code>ok</code>| <code>cancel</code> <br>Works only for Confirm and Prompt</md-table-cell>
|
|
<md-table-cell>Triggered when the dialog closes.</md-table-cell>
|
|
</md-table-row>
|
|
</md-table-body>
|
|
</md-table>
|
|
|
|
<md-table slot="methods">
|
|
<md-table-header>
|
|
<md-table-row>
|
|
<md-table-head>Name</md-table-head>
|
|
<md-table-head>Description</md-table-head>
|
|
</md-table-row>
|
|
</md-table-header>
|
|
|
|
<md-table-body>
|
|
<md-table-row>
|
|
<md-table-cell>open</md-table-cell>
|
|
<md-table-cell>Open the dialog.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>close</md-table-cell>
|
|
<md-table-cell>Close the dialog.</md-table-cell>
|
|
</md-table-row>
|
|
</md-table-body>
|
|
</md-table>
|
|
</api-table>
|
|
|
|
<api-table name="md-dialog-title">
|
|
<p>Can display a title on the top of the Dialog.</p>
|
|
<p>No options available</p>
|
|
</api-table>
|
|
|
|
<api-table name="md-dialog-content">
|
|
<p>Used to display rich content inside the Dialog.</p>
|
|
<p>No options available</p>
|
|
</api-table>
|
|
|
|
<api-table name="md-dialog-actions">
|
|
<p>Hold the actions of a dialog and align them on the right. Here you can add <code><md-button></code> with or without icons.</p>
|
|
<p>No options available</p>
|
|
</api-table>
|
|
|
|
<api-table name="md-dialog-alert">
|
|
<div slot="properties">
|
|
<md-table>
|
|
<md-table-header>
|
|
<md-table-row>
|
|
<md-table-head>Name</md-table-head>
|
|
<md-table-head>Type</md-table-head>
|
|
<md-table-head>Description</md-table-head>
|
|
</md-table-row>
|
|
</md-table-header>
|
|
|
|
<md-table-body>
|
|
<md-table-row>
|
|
<md-table-cell>md-title</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>Sets the alert title. Optional.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-content</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>Sets the alert content.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-content-html</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>Sets the alert content with a custom html.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-ok-text</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>Sets the alert "Okay" button text.</md-table-cell>
|
|
</md-table-row>
|
|
</md-table-body>
|
|
</md-table>
|
|
</div>
|
|
</api-table>
|
|
|
|
<api-table name="md-dialog-confirm">
|
|
<div slot="properties">
|
|
<md-table>
|
|
<md-table-header>
|
|
<md-table-row>
|
|
<md-table-head>Name</md-table-head>
|
|
<md-table-head>Type</md-table-head>
|
|
<md-table-head>Description</md-table-head>
|
|
</md-table-row>
|
|
</md-table-header>
|
|
|
|
<md-table-body>
|
|
<md-table-row>
|
|
<md-table-cell>md-title</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>Sets the confirm title. Optional.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-content</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>Sets the confirm content.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-content-html</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>Sets the confirm content with a custom html.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-ok-text</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>Sets the confirm "Okay" button text.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-cancel-text</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>Sets the confirm "Cancel" button text.</md-table-cell>
|
|
</md-table-row>
|
|
</md-table-body>
|
|
</md-table>
|
|
</div>
|
|
</api-table>
|
|
|
|
<api-table name="md-dialog-prompt">
|
|
<div slot="properties">
|
|
<md-table>
|
|
<md-table-header>
|
|
<md-table-row>
|
|
<md-table-head>Name</md-table-head>
|
|
<md-table-head>Type</md-table-head>
|
|
<md-table-head>Description</md-table-head>
|
|
</md-table-row>
|
|
</md-table-header>
|
|
|
|
<md-table-body>
|
|
<md-table-row>
|
|
<md-table-cell>md-title</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>Sets the prompt title. Optional.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-content</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>Sets the prompt content.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-content-html</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>Sets the prompt content with a custom html.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-ok-text</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>Sets the prompt "Okay" button text.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-cancel-text</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>Sets the prompt "Cancel" button text.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>v-model</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>A required model object to be bind when the value is confirmed.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-input-id</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>Set the ID of the field inside the prompt dialog.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-input-name</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>Set the name of the field inside the prompt dialog.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-input-maxlength</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>Set the optional maxlength of the field inside the prompt dialog with the text count.</md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-input-placeholder</md-table-cell>
|
|
<md-table-cell><code>String</code></md-table-cell>
|
|
<md-table-cell>Set the optional placeholder of the field inside the prompt dialog.</md-table-cell>
|
|
</md-table-row>
|
|
</md-table-body>
|
|
</md-table>
|
|
</div>
|
|
</api-table>
|
|
</div>
|
|
|
|
<div slot="example">
|
|
<example-box card-title="Custom">
|
|
<div class="dialog-fab" slot="demo">
|
|
<md-dialog md-open-from="#custom" md-close-to="#custom" ref="dialog1">
|
|
<md-dialog-title>Lorem ipsum dolor sit amet</md-dialog-title>
|
|
|
|
<md-dialog-content>Nemo, nobis necessitatibus ut illo, ducimus ex.</md-dialog-content>
|
|
|
|
<md-dialog-actions>
|
|
<md-button class="md-primary" @click="closeDialog('dialog1')">Cancel</md-button>
|
|
<md-button class="md-primary" @click="closeDialog('dialog1')">Ok</md-button>
|
|
</md-dialog-actions>
|
|
</md-dialog>
|
|
|
|
<md-dialog md-open-from="#fab" md-close-to="#fab" ref="dialog2">
|
|
<md-dialog-title>Create new note</md-dialog-title>
|
|
|
|
<md-dialog-content>
|
|
<form>
|
|
<md-input-container>
|
|
<label>Note</label>
|
|
<md-textarea></md-textarea>
|
|
</md-input-container>
|
|
</form>
|
|
</md-dialog-content>
|
|
|
|
<md-dialog-actions>
|
|
<md-button class="md-primary" @click="closeDialog('dialog2')">Cancel</md-button>
|
|
<md-button class="md-primary" @click="closeDialog('dialog2')">Create</md-button>
|
|
</md-dialog-actions>
|
|
</md-dialog>
|
|
|
|
<md-button class="md-primary md-raised" id="custom" @click="openDialog('dialog1')">Custom</md-button>
|
|
<md-button class="md-fab md-fab-bottom-right" id="fab" @click="openDialog('dialog2')">
|
|
<md-icon>add</md-icon>
|
|
</md-button>
|
|
</div>
|
|
|
|
<div slot="code">
|
|
<code-block lang="xml">
|
|
<md-dialog md-open-from="#custom" md-close-to="#custom" ref="dialog1">
|
|
<md-dialog-title>Lorem ipsum dolor sit amet</md-dialog-title>
|
|
|
|
<md-dialog-content>Nemo, nobis necessitatibus ut illo, ducimus ex.</md-dialog-content>
|
|
|
|
<md-dialog-actions>
|
|
<md-button class="md-primary" @click="closeDialog('dialog1')">Cancel</md-button>
|
|
<md-button class="md-primary" @click="closeDialog('dialog1')">Ok</md-button>
|
|
</md-dialog-actions>
|
|
</md-dialog>
|
|
|
|
<md-dialog md-open-from="#fab" md-close-to="#fab" ref="dialog2">
|
|
<md-dialog-title>Create new note</md-dialog-title>
|
|
|
|
<md-dialog-content>
|
|
<form>
|
|
<md-input-container>
|
|
<label>Note</label>
|
|
<md-textarea></md-textarea>
|
|
</md-input-container>
|
|
</form>
|
|
</md-dialog-content>
|
|
|
|
<md-dialog-actions>
|
|
<md-button class="md-primary" @click="closeDialog('dialog2')">Cancel</md-button>
|
|
<md-button class="md-primary" @click="closeDialog('dialog2')">Create</md-button>
|
|
</md-dialog-actions>
|
|
</md-dialog>
|
|
|
|
<md-button class="md-primary md-raised" id="custom" @click="openDialog('dialog1')">Custom</md-button>
|
|
<md-button class="md-fab md-fab-bottom-right" id="fab" @click="openDialog('dialog2')">
|
|
<md-icon>add</md-icon>
|
|
</md-button>
|
|
</code-block>
|
|
|
|
<code-block lang="javascript">
|
|
export default {
|
|
methods: {
|
|
openDialog(ref) {
|
|
this.$refs[ref].open();
|
|
},
|
|
closeDialog(ref) {
|
|
this.$refs[ref].close();
|
|
},
|
|
onOpen() {
|
|
console.log('Opened');
|
|
},
|
|
onClose(type) {
|
|
console.log('Closed', type);
|
|
}
|
|
}
|
|
};
|
|
</code-block>
|
|
</div>
|
|
</example-box>
|
|
|
|
<example-box card-title="Alerts">
|
|
<div slot="demo">
|
|
<md-dialog-alert
|
|
:md-content="alert.content"
|
|
:md-ok-text="alert.ok"
|
|
@open="onOpen"
|
|
@close="onClose"
|
|
ref="dialog3">
|
|
</md-dialog-alert>
|
|
|
|
<md-dialog-alert
|
|
:md-title="alert2.title"
|
|
:md-content-html="alert2.contentHtml"
|
|
@open="onOpen"
|
|
@close="onClose"
|
|
ref="dialog4">
|
|
</md-dialog-alert>
|
|
|
|
<md-button class="md-primary md-raised" @click="openDialog('dialog3')">Alert</md-button>
|
|
<md-button class="md-primary md-raised" @click="openDialog('dialog4')">Alert with HTML</md-button>
|
|
</div>
|
|
|
|
<div slot="code">
|
|
<code-block lang="xml">
|
|
<md-dialog-alert
|
|
:md-content="alert.content"
|
|
:md-ok-text="alert.ok"
|
|
@open="onOpen"
|
|
@close="onClose"
|
|
ref="dialog3">
|
|
</md-dialog-alert>
|
|
|
|
<md-dialog-alert
|
|
:md-title="alert2.title"
|
|
:md-content-html="alert2.contentHtml"
|
|
@open="onOpen"
|
|
@close="onClose"
|
|
ref="dialog4">
|
|
</md-dialog-alert>
|
|
|
|
<md-button class="md-primary md-raised" @click="openDialog('dialog3')">Alert</md-button>
|
|
<md-button class="md-primary md-raised" @click="openDialog('dialog4')">Alert with HTML</md-button>
|
|
</code-block>
|
|
|
|
<code-block lang="javascript">
|
|
export default {
|
|
data: () => ({
|
|
alert: {
|
|
content: 'Your post has been deleted!',
|
|
ok: 'Cool!'
|
|
},
|
|
alert2: {
|
|
title: 'Post created!',
|
|
contentHtml: 'Your post <strong>Material Design is awesome</strong> has been created.'
|
|
}
|
|
}),
|
|
methods: {
|
|
openDialog(ref) {
|
|
this.$refs[ref].open();
|
|
},
|
|
closeDialog(ref) {
|
|
this.$refs[ref].close();
|
|
},
|
|
onOpen() {
|
|
console.log('Opened');
|
|
},
|
|
onClose(type) {
|
|
console.log('Closed', type);
|
|
}
|
|
}
|
|
};
|
|
</code-block>
|
|
</div>
|
|
</example-box>
|
|
|
|
<example-box card-title="Confirm">
|
|
<div slot="demo">
|
|
<md-dialog-confirm
|
|
:md-title="confirm.title"
|
|
:md-content-html="confirm.contentHtml"
|
|
:md-ok-text="confirm.ok"
|
|
:md-cancel-text="confirm.cancel"
|
|
@open="onOpen"
|
|
@close="onClose"
|
|
ref="dialog5">
|
|
</md-dialog-confirm>
|
|
|
|
<md-button class="md-primary md-raised" @click="openDialog('dialog5')">Confirm</md-button>
|
|
</div>
|
|
|
|
<div slot="code">
|
|
<code-block lang="xml">
|
|
<md-dialog-confirm
|
|
:md-title="confirm.title"
|
|
:md-content-html="confirm.contentHtml"
|
|
:md-ok-text="confirm.ok"
|
|
:md-cancel-text="confirm.cancel"
|
|
@open="onOpen"
|
|
@close="onClose"
|
|
ref="dialog5">
|
|
</md-dialog-confirm>
|
|
|
|
<md-button class="md-primary md-raised" @click="openDialog('dialog5')">Confirm</md-button>
|
|
</code-block>
|
|
|
|
<code-block lang="javascript">
|
|
export default {
|
|
data: () => ({
|
|
confirm: {
|
|
title: 'Use Google\'s location service?',
|
|
contentHtml: 'Let Google help apps determine location. <br> This means sending <strong>anonymous</strong> location data to Google, even when no apps are running.',
|
|
ok: 'Agree',
|
|
cancel: 'Disagree'
|
|
}
|
|
}),
|
|
methods: {
|
|
openDialog(ref) {
|
|
this.$refs[ref].open();
|
|
},
|
|
closeDialog(ref) {
|
|
this.$refs[ref].close();
|
|
},
|
|
onOpen() {
|
|
console.log('Opened');
|
|
},
|
|
onClose(type) {
|
|
console.log('Closed', type);
|
|
}
|
|
}
|
|
};
|
|
</code-block>
|
|
</div>
|
|
</example-box>
|
|
|
|
<example-box card-title="Prompt">
|
|
<div slot="demo">
|
|
<md-dialog-prompt
|
|
:md-title="prompt.title"
|
|
:md-ok-text="prompt.ok"
|
|
:md-cancel-text="prompt.cancel"
|
|
:md-input-id="prompt.id"
|
|
:md-input-name="prompt.name"
|
|
:md-input-maxlength="prompt.maxlength"
|
|
:md-input-placeholder="prompt.placeholder"
|
|
v-model="prompt.value"
|
|
@open="onOpen"
|
|
@close="onClose"
|
|
ref="dialog6">
|
|
</md-dialog-prompt>
|
|
|
|
<md-button class="md-primary md-raised" @click="openDialog('dialog6')">Prompt</md-button>
|
|
</div>
|
|
|
|
<div slot="code">
|
|
<code-block lang="xml">
|
|
<md-dialog-prompt
|
|
:md-title="prompt.title"
|
|
:md-ok-text="prompt.ok"
|
|
:md-cancel-text="prompt.cancel"
|
|
@open="onOpen"
|
|
@close="onClose"
|
|
ref="dialog6">
|
|
</md-dialog-prompt>
|
|
|
|
<md-button class="md-primary md-raised" @click="openDialog('dialog6')">Prompt</md-button>
|
|
</code-block>
|
|
|
|
<code-block lang="javascript">
|
|
export default {
|
|
data: () => ({
|
|
prompt: {
|
|
title: 'What\'s your name?',
|
|
ok: 'Done',
|
|
cancel: 'Cancel',
|
|
id: 'name',
|
|
name: 'name',
|
|
placeholder: 'Type your name...',
|
|
maxlength: 30,
|
|
value: ''
|
|
}
|
|
}),
|
|
methods: {
|
|
openDialog(ref) {
|
|
this.$refs[ref].open();
|
|
},
|
|
closeDialog(ref) {
|
|
this.$refs[ref].close();
|
|
},
|
|
onOpen() {
|
|
console.log('Opened');
|
|
},
|
|
onClose(type) {
|
|
console.log('Closed', type);
|
|
}
|
|
}
|
|
};
|
|
</code-block>
|
|
</div>
|
|
</example-box>
|
|
</div>
|
|
</docs-component>
|
|
</page-content>
|
|
</template>
|
|
|
|
<style lang="scss" scoped>
|
|
.dialog-fab {
|
|
height: 200px;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
export default {
|
|
data: () => ({
|
|
alert: {
|
|
content: 'Your post has been deleted!',
|
|
ok: 'Cool!'
|
|
},
|
|
alert2: {
|
|
title: 'Post created!',
|
|
contentHtml: 'Your post <strong>Material Design is awesome</strong> has been created.'
|
|
},
|
|
confirm: {
|
|
title: 'Use Google\'s location service?',
|
|
contentHtml: 'Let Google help apps determine location. <br> This means sending <strong>anonymous</strong> location data to Google, even when no apps are running.',
|
|
ok: 'Agree',
|
|
cancel: 'Disagree'
|
|
},
|
|
prompt: {
|
|
title: 'What\'s your name?',
|
|
ok: 'Done',
|
|
cancel: 'Cancel',
|
|
id: 'name',
|
|
name: 'name',
|
|
placeholder: 'Type your name...',
|
|
maxlength: 30,
|
|
value: ''
|
|
}
|
|
}),
|
|
methods: {
|
|
openDialog(ref) {
|
|
this.$refs[ref].open();
|
|
},
|
|
closeDialog(ref) {
|
|
this.$refs[ref].close();
|
|
},
|
|
onOpen() {
|
|
console.log('Opened');
|
|
},
|
|
onClose(type) {
|
|
console.log('Closed', type);
|
|
}
|
|
}
|
|
};
|
|
</script>
|