first
This commit is contained in:
281
node_modules/vant/es/dialog/Dialog.js
generated
vendored
Normal file
281
node_modules/vant/es/dialog/Dialog.js
generated
vendored
Normal file
@ -0,0 +1,281 @@
|
||||
import _mergeJSXProps from "@vue/babel-helper-vue-jsx-merge-props";
|
||||
import { createNamespace, addUnit, noop } from '../utils';
|
||||
import { BORDER_TOP, BORDER_LEFT } from '../utils/constant';
|
||||
import { PopupMixin } from '../mixins/popup';
|
||||
import Button from '../button';
|
||||
import GoodsAction from '../goods-action';
|
||||
import GoodsActionButton from '../goods-action-button';
|
||||
|
||||
var _createNamespace = createNamespace('dialog'),
|
||||
createComponent = _createNamespace[0],
|
||||
bem = _createNamespace[1],
|
||||
t = _createNamespace[2];
|
||||
|
||||
export default createComponent({
|
||||
mixins: [PopupMixin()],
|
||||
props: {
|
||||
title: String,
|
||||
theme: String,
|
||||
width: [Number, String],
|
||||
message: String,
|
||||
className: null,
|
||||
callback: Function,
|
||||
beforeClose: Function,
|
||||
messageAlign: String,
|
||||
cancelButtonText: String,
|
||||
cancelButtonColor: String,
|
||||
confirmButtonText: String,
|
||||
confirmButtonColor: String,
|
||||
showCancelButton: Boolean,
|
||||
overlay: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
allowHtml: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
transition: {
|
||||
type: String,
|
||||
default: 'van-dialog-bounce'
|
||||
},
|
||||
showConfirmButton: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
closeOnPopstate: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
closeOnClickOverlay: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data: function data() {
|
||||
return {
|
||||
loading: {
|
||||
confirm: false,
|
||||
cancel: false
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onClickOverlay: function onClickOverlay() {
|
||||
this.handleAction('overlay');
|
||||
},
|
||||
handleAction: function handleAction(action) {
|
||||
var _this = this;
|
||||
|
||||
this.$emit(action); // show not trigger close event when hidden
|
||||
|
||||
if (!this.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.beforeClose) {
|
||||
this.loading[action] = true;
|
||||
this.beforeClose(action, function (state) {
|
||||
if (state !== false && _this.loading[action]) {
|
||||
_this.onClose(action);
|
||||
}
|
||||
|
||||
_this.loading.confirm = false;
|
||||
_this.loading.cancel = false;
|
||||
});
|
||||
} else {
|
||||
this.onClose(action);
|
||||
}
|
||||
},
|
||||
onClose: function onClose(action) {
|
||||
this.close();
|
||||
|
||||
if (this.callback) {
|
||||
this.callback(action);
|
||||
}
|
||||
},
|
||||
onOpened: function onOpened() {
|
||||
var _this2 = this;
|
||||
|
||||
this.$emit('opened');
|
||||
this.$nextTick(function () {
|
||||
var _this2$$refs$dialog;
|
||||
|
||||
(_this2$$refs$dialog = _this2.$refs.dialog) == null ? void 0 : _this2$$refs$dialog.focus();
|
||||
});
|
||||
},
|
||||
onClosed: function onClosed() {
|
||||
this.$emit('closed');
|
||||
},
|
||||
onKeydown: function onKeydown(event) {
|
||||
var _this3 = this;
|
||||
|
||||
if (event.key === 'Escape' || event.key === 'Enter') {
|
||||
// skip keyboard events of child elements
|
||||
if (event.target !== this.$refs.dialog) {
|
||||
return;
|
||||
}
|
||||
|
||||
var onEventType = {
|
||||
Enter: this.showConfirmButton ? function () {
|
||||
return _this3.handleAction('confirm');
|
||||
} : noop,
|
||||
Escape: this.showCancelButton ? function () {
|
||||
return _this3.handleAction('cancel');
|
||||
} : noop
|
||||
};
|
||||
onEventType[event.key]();
|
||||
this.$emit('keydown', event);
|
||||
}
|
||||
},
|
||||
genRoundButtons: function genRoundButtons() {
|
||||
var _this4 = this;
|
||||
|
||||
var h = this.$createElement;
|
||||
return h(GoodsAction, {
|
||||
"class": bem('footer')
|
||||
}, [this.showCancelButton && h(GoodsActionButton, {
|
||||
"attrs": {
|
||||
"size": "large",
|
||||
"type": "warning",
|
||||
"text": this.cancelButtonText || t('cancel'),
|
||||
"color": this.cancelButtonColor,
|
||||
"loading": this.loading.cancel
|
||||
},
|
||||
"class": bem('cancel'),
|
||||
"on": {
|
||||
"click": function click() {
|
||||
_this4.handleAction('cancel');
|
||||
}
|
||||
}
|
||||
}), this.showConfirmButton && h(GoodsActionButton, {
|
||||
"attrs": {
|
||||
"size": "large",
|
||||
"type": "danger",
|
||||
"text": this.confirmButtonText || t('confirm'),
|
||||
"color": this.confirmButtonColor,
|
||||
"loading": this.loading.confirm
|
||||
},
|
||||
"class": bem('confirm'),
|
||||
"on": {
|
||||
"click": function click() {
|
||||
_this4.handleAction('confirm');
|
||||
}
|
||||
}
|
||||
})]);
|
||||
},
|
||||
genButtons: function genButtons() {
|
||||
var _this5 = this,
|
||||
_ref;
|
||||
|
||||
var h = this.$createElement;
|
||||
var multiple = this.showCancelButton && this.showConfirmButton;
|
||||
return h("div", {
|
||||
"class": [BORDER_TOP, bem('footer')]
|
||||
}, [this.showCancelButton && h(Button, {
|
||||
"attrs": {
|
||||
"size": "large",
|
||||
"loading": this.loading.cancel,
|
||||
"text": this.cancelButtonText || t('cancel'),
|
||||
"nativeType": "button"
|
||||
},
|
||||
"class": bem('cancel'),
|
||||
"style": {
|
||||
color: this.cancelButtonColor
|
||||
},
|
||||
"on": {
|
||||
"click": function click() {
|
||||
_this5.handleAction('cancel');
|
||||
}
|
||||
}
|
||||
}), this.showConfirmButton && h(Button, {
|
||||
"attrs": {
|
||||
"size": "large",
|
||||
"loading": this.loading.confirm,
|
||||
"text": this.confirmButtonText || t('confirm'),
|
||||
"nativeType": "button"
|
||||
},
|
||||
"class": [bem('confirm'), (_ref = {}, _ref[BORDER_LEFT] = multiple, _ref)],
|
||||
"style": {
|
||||
color: this.confirmButtonColor
|
||||
},
|
||||
"on": {
|
||||
"click": function click() {
|
||||
_this5.handleAction('confirm');
|
||||
}
|
||||
}
|
||||
})]);
|
||||
},
|
||||
genContent: function genContent(hasTitle, messageSlot) {
|
||||
var h = this.$createElement;
|
||||
|
||||
if (messageSlot) {
|
||||
return h("div", {
|
||||
"class": bem('content')
|
||||
}, [messageSlot]);
|
||||
}
|
||||
|
||||
var message = this.message,
|
||||
messageAlign = this.messageAlign;
|
||||
|
||||
if (message) {
|
||||
var _bem, _domProps;
|
||||
|
||||
var data = {
|
||||
class: bem('message', (_bem = {
|
||||
'has-title': hasTitle
|
||||
}, _bem[messageAlign] = messageAlign, _bem)),
|
||||
domProps: (_domProps = {}, _domProps[this.allowHtml ? 'innerHTML' : 'textContent'] = message, _domProps)
|
||||
};
|
||||
return h("div", {
|
||||
"class": bem('content', {
|
||||
isolated: !hasTitle
|
||||
})
|
||||
}, [h("div", _mergeJSXProps([{}, data]))]);
|
||||
}
|
||||
}
|
||||
},
|
||||
render: function render() {
|
||||
var h = arguments[0];
|
||||
|
||||
if (!this.shouldRender) {
|
||||
return;
|
||||
}
|
||||
|
||||
var message = this.message;
|
||||
var messageSlot = this.slots();
|
||||
var title = this.slots('title') || this.title;
|
||||
var Title = title && h("div", {
|
||||
"class": bem('header', {
|
||||
isolated: !message && !messageSlot
|
||||
})
|
||||
}, [title]);
|
||||
return h("transition", {
|
||||
"attrs": {
|
||||
"name": this.transition
|
||||
},
|
||||
"on": {
|
||||
"afterEnter": this.onOpened,
|
||||
"afterLeave": this.onClosed
|
||||
}
|
||||
}, [h("div", {
|
||||
"directives": [{
|
||||
name: "show",
|
||||
value: this.value
|
||||
}],
|
||||
"attrs": {
|
||||
"role": "dialog",
|
||||
"aria-labelledby": this.title || message,
|
||||
"tabIndex": 0
|
||||
},
|
||||
"class": [bem([this.theme]), this.className],
|
||||
"style": {
|
||||
width: addUnit(this.width)
|
||||
},
|
||||
"ref": "dialog",
|
||||
"on": {
|
||||
"keydown": this.onKeydown
|
||||
}
|
||||
}, [Title, this.genContent(title, messageSlot), this.theme === 'round-button' ? this.genRoundButtons() : this.genButtons()])]);
|
||||
}
|
||||
});
|
1
node_modules/vant/es/dialog/index.css
generated
vendored
Normal file
1
node_modules/vant/es/dialog/index.css
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
.van-dialog{position:fixed;top:45%;left:50%;width:320px;overflow:hidden;font-size:16px;background-color:#fff;border-radius:16px;-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0);-webkit-backface-visibility:hidden;backface-visibility:hidden;-webkit-transition:.3s;transition:.3s;-webkit-transition-property:opacity,-webkit-transform;transition-property:opacity,-webkit-transform;transition-property:transform,opacity;transition-property:transform,opacity,-webkit-transform}@media (max-width:321px){.van-dialog{width:90%}}.van-dialog__header{padding-top:26px;font-weight:500;line-height:24px;text-align:center}.van-dialog__header--isolated{padding:24px 0}.van-dialog__content--isolated{display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-align:center;-webkit-align-items:center;align-items:center;min-height:104px}.van-dialog__message{-webkit-box-flex:1;-webkit-flex:1;flex:1;max-height:60vh;padding:26px 24px;overflow-y:auto;font-size:14px;line-height:20px;white-space:pre-wrap;text-align:center;word-wrap:break-word;-webkit-overflow-scrolling:touch}.van-dialog__message--has-title{padding-top:8px;color:#646566}.van-dialog__message--left{text-align:left}.van-dialog__message--right{text-align:right}.van-dialog__footer{display:-webkit-box;display:-webkit-flex;display:flex;overflow:hidden;-webkit-user-select:none;user-select:none}.van-dialog__cancel,.van-dialog__confirm{-webkit-box-flex:1;-webkit-flex:1;flex:1;height:48px;margin:0;border:0}.van-dialog__confirm,.van-dialog__confirm:active{color:#ee0a24}.van-dialog--round-button .van-dialog__footer{position:relative;height:auto;padding:8px 24px 16px}.van-dialog--round-button .van-dialog__message{padding-bottom:16px;color:#323233}.van-dialog--round-button .van-dialog__cancel,.van-dialog--round-button .van-dialog__confirm{height:36px}.van-dialog--round-button .van-dialog__confirm{color:#fff}.van-dialog-bounce-enter{-webkit-transform:translate3d(-50%,-50%,0) scale(.7);transform:translate3d(-50%,-50%,0) scale(.7);opacity:0}.van-dialog-bounce-leave-active{-webkit-transform:translate3d(-50%,-50%,0) scale(.9);transform:translate3d(-50%,-50%,0) scale(.9);opacity:0}
|
104
node_modules/vant/es/dialog/index.js
generated
vendored
Normal file
104
node_modules/vant/es/dialog/index.js
generated
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import Vue from 'vue';
|
||||
import VanDialog from './Dialog';
|
||||
import { isServer } from '../utils';
|
||||
var instance;
|
||||
|
||||
function isInDocument(element) {
|
||||
return document.body.contains(element);
|
||||
}
|
||||
|
||||
function initInstance() {
|
||||
if (instance) {
|
||||
instance.$destroy();
|
||||
}
|
||||
|
||||
instance = new (Vue.extend(VanDialog))({
|
||||
el: document.createElement('div'),
|
||||
// avoid missing animation when first rendered
|
||||
propsData: {
|
||||
lazyRender: false
|
||||
}
|
||||
});
|
||||
instance.$on('input', function (value) {
|
||||
instance.value = value;
|
||||
});
|
||||
}
|
||||
|
||||
function Dialog(options) {
|
||||
/* istanbul ignore if */
|
||||
if (isServer) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (!instance || !isInDocument(instance.$el)) {
|
||||
initInstance();
|
||||
}
|
||||
|
||||
_extends(instance, Dialog.currentOptions, options, {
|
||||
resolve: resolve,
|
||||
reject: reject
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Dialog.defaultOptions = {
|
||||
value: true,
|
||||
title: '',
|
||||
width: '',
|
||||
theme: null,
|
||||
message: '',
|
||||
overlay: true,
|
||||
className: '',
|
||||
allowHtml: true,
|
||||
lockScroll: true,
|
||||
transition: 'van-dialog-bounce',
|
||||
beforeClose: null,
|
||||
overlayClass: '',
|
||||
overlayStyle: null,
|
||||
messageAlign: '',
|
||||
getContainer: 'body',
|
||||
cancelButtonText: '',
|
||||
cancelButtonColor: null,
|
||||
confirmButtonText: '',
|
||||
confirmButtonColor: null,
|
||||
showConfirmButton: true,
|
||||
showCancelButton: false,
|
||||
closeOnPopstate: true,
|
||||
closeOnClickOverlay: false,
|
||||
callback: function callback(action) {
|
||||
instance[action === 'confirm' ? 'resolve' : 'reject'](action);
|
||||
}
|
||||
};
|
||||
Dialog.alert = Dialog;
|
||||
|
||||
Dialog.confirm = function (options) {
|
||||
return Dialog(_extends({
|
||||
showCancelButton: true
|
||||
}, options));
|
||||
};
|
||||
|
||||
Dialog.close = function () {
|
||||
if (instance) {
|
||||
instance.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
Dialog.setDefaultOptions = function (options) {
|
||||
_extends(Dialog.currentOptions, options);
|
||||
};
|
||||
|
||||
Dialog.resetDefaultOptions = function () {
|
||||
Dialog.currentOptions = _extends({}, Dialog.defaultOptions);
|
||||
};
|
||||
|
||||
Dialog.resetDefaultOptions();
|
||||
|
||||
Dialog.install = function () {
|
||||
Vue.use(VanDialog);
|
||||
};
|
||||
|
||||
Dialog.Component = VanDialog;
|
||||
Vue.prototype.$dialog = Dialog;
|
||||
export default Dialog;
|
120
node_modules/vant/es/dialog/index.less
generated
vendored
Normal file
120
node_modules/vant/es/dialog/index.less
generated
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
@import '../style/var';
|
||||
|
||||
.van-dialog {
|
||||
position: fixed;
|
||||
top: 45%;
|
||||
left: 50%;
|
||||
width: @dialog-width;
|
||||
overflow: hidden;
|
||||
font-size: @dialog-font-size;
|
||||
background-color: @dialog-background-color;
|
||||
border-radius: @dialog-border-radius;
|
||||
transform: translate3d(-50%, -50%, 0);
|
||||
backface-visibility: hidden; // avoid blurry text after scale animation
|
||||
transition: @dialog-transition;
|
||||
transition-property: transform, opacity;
|
||||
|
||||
@media (max-width: 321px) {
|
||||
width: @dialog-small-screen-width;
|
||||
}
|
||||
|
||||
&__header {
|
||||
padding-top: @dialog-header-padding-top;
|
||||
font-weight: @dialog-header-font-weight;
|
||||
line-height: @dialog-header-line-height;
|
||||
text-align: center;
|
||||
|
||||
&--isolated {
|
||||
padding: @dialog-header-isolated-padding;
|
||||
}
|
||||
}
|
||||
|
||||
&__content {
|
||||
&--isolated {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 104px;
|
||||
}
|
||||
}
|
||||
|
||||
&__message {
|
||||
flex: 1;
|
||||
max-height: @dialog-message-max-height;
|
||||
padding: 26px @dialog-message-padding;
|
||||
overflow-y: auto;
|
||||
font-size: @dialog-message-font-size;
|
||||
line-height: @dialog-message-line-height;
|
||||
|
||||
// allow newline charactor
|
||||
white-space: pre-wrap;
|
||||
text-align: center;
|
||||
word-wrap: break-word;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
|
||||
&--has-title {
|
||||
padding-top: @dialog-has-title-message-padding-top;
|
||||
color: @dialog-has-title-message-text-color;
|
||||
}
|
||||
|
||||
&--left {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
&--right {
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
&__confirm,
|
||||
&__cancel {
|
||||
flex: 1;
|
||||
height: @dialog-button-height;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
&__confirm {
|
||||
&,
|
||||
&:active {
|
||||
color: @dialog-confirm-button-text-color;
|
||||
}
|
||||
}
|
||||
|
||||
&--round-button {
|
||||
.van-dialog__footer {
|
||||
position: relative;
|
||||
height: auto;
|
||||
padding: @padding-xs @padding-lg @padding-md;
|
||||
}
|
||||
|
||||
.van-dialog__message {
|
||||
padding-bottom: @padding-md;
|
||||
color: @text-color;
|
||||
}
|
||||
|
||||
.van-dialog__confirm,
|
||||
.van-dialog__cancel {
|
||||
height: @dialog-round-button-height;
|
||||
}
|
||||
|
||||
.van-dialog__confirm {
|
||||
color: @white;
|
||||
}
|
||||
}
|
||||
|
||||
&-bounce-enter {
|
||||
transform: translate3d(-50%, -50%, 0) scale(0.7);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
&-bounce-leave-active {
|
||||
transform: translate3d(-50%, -50%, 0) scale(0.9);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
10
node_modules/vant/es/dialog/style/index.js
generated
vendored
Normal file
10
node_modules/vant/es/dialog/style/index.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import '../../style/base.css';
|
||||
import '../../overlay/index.css';
|
||||
import '../../info/index.css';
|
||||
import '../../icon/index.css';
|
||||
import '../../popup/index.css';
|
||||
import '../../loading/index.css';
|
||||
import '../../button/index.css';
|
||||
import '../../goods-action-button/index.css';
|
||||
import '../../goods-action/index.css';
|
||||
import '../index.css';
|
10
node_modules/vant/es/dialog/style/less.js
generated
vendored
Normal file
10
node_modules/vant/es/dialog/style/less.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import '../../style/base.less';
|
||||
import '../../overlay/index.less';
|
||||
import '../../info/index.less';
|
||||
import '../../icon/index.less';
|
||||
import '../../popup/index.less';
|
||||
import '../../loading/index.less';
|
||||
import '../../button/index.less';
|
||||
import '../../goods-action-button/index.less';
|
||||
import '../../goods-action/index.less';
|
||||
import '../index.less';
|
Reference in New Issue
Block a user