This commit is contained in:
2023-08-11 10:45:20 +08:00
commit 161ca982f3
31850 changed files with 2706500 additions and 0 deletions

155
node_modules/vant/es/toast/Toast.js generated vendored Normal file
View File

@ -0,0 +1,155 @@
// Utils
import { createNamespace, isDef } from '../utils';
import { lockClick } from './lock-click'; // Mixins
import { PopupMixin } from '../mixins/popup'; // Components
import Icon from '../icon';
import Loading from '../loading';
var _createNamespace = createNamespace('toast'),
createComponent = _createNamespace[0],
bem = _createNamespace[1];
export default createComponent({
mixins: [PopupMixin()],
props: {
icon: String,
className: null,
iconPrefix: String,
loadingType: String,
forbidClick: Boolean,
closeOnClick: Boolean,
message: [Number, String],
type: {
type: String,
default: 'text'
},
position: {
type: String,
default: 'middle'
},
transition: {
type: String,
default: 'van-fade'
},
lockScroll: {
type: Boolean,
default: false
}
},
data: function data() {
return {
clickable: false
};
},
mounted: function mounted() {
this.toggleClickable();
},
destroyed: function destroyed() {
this.toggleClickable();
},
watch: {
value: 'toggleClickable',
forbidClick: 'toggleClickable'
},
methods: {
onClick: function onClick() {
if (this.closeOnClick) {
this.close();
}
},
toggleClickable: function toggleClickable() {
var clickable = this.value && this.forbidClick;
if (this.clickable !== clickable) {
this.clickable = clickable;
lockClick(clickable);
}
},
/* istanbul ignore next */
onAfterEnter: function onAfterEnter() {
this.$emit('opened');
if (this.onOpened) {
this.onOpened();
}
},
onAfterLeave: function onAfterLeave() {
this.$emit('closed');
},
genIcon: function genIcon() {
var h = this.$createElement;
var icon = this.icon,
type = this.type,
iconPrefix = this.iconPrefix,
loadingType = this.loadingType;
var hasIcon = icon || type === 'success' || type === 'fail';
if (hasIcon) {
return h(Icon, {
"class": bem('icon'),
"attrs": {
"classPrefix": iconPrefix,
"name": icon || type
}
});
}
if (type === 'loading') {
return h(Loading, {
"class": bem('loading'),
"attrs": {
"type": loadingType
}
});
}
},
genMessage: function genMessage() {
var h = this.$createElement;
var type = this.type,
message = this.message;
if (!isDef(message) || message === '') {
return;
}
if (type === 'html') {
return h("div", {
"class": bem('text'),
"domProps": {
"innerHTML": message
}
});
}
return h("div", {
"class": bem('text')
}, [message]);
}
},
render: function render() {
var _ref;
var h = arguments[0];
return h("transition", {
"attrs": {
"name": this.transition
},
"on": {
"afterEnter": this.onAfterEnter,
"afterLeave": this.onAfterLeave
}
}, [h("div", {
"directives": [{
name: "show",
value: this.value
}],
"class": [bem([this.position, (_ref = {}, _ref[this.type] = !this.icon, _ref)]), this.className],
"on": {
"click": this.onClick
}
}, [this.genIcon(), this.genMessage()])]);
}
});

1
node_modules/vant/es/toast/index.css generated vendored Normal file
View File

@ -0,0 +1 @@
.van-toast{position:fixed;top:50%;left:50%;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;flex-direction:column;-webkit-box-align:center;-webkit-align-items:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;justify-content:center;box-sizing:content-box;width:88px;max-width:70%;min-height:88px;padding:16px;color:#fff;font-size:14px;line-height:20px;white-space:pre-wrap;text-align:center;word-break:break-all;background-color:rgba(0,0,0,.7);border-radius:8px;-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0)}.van-toast--unclickable{overflow:hidden}.van-toast--unclickable *{pointer-events:none}.van-toast--html,.van-toast--text{width:-webkit-fit-content;width:fit-content;min-width:96px;min-height:0;padding:8px 12px}.van-toast--html .van-toast__text,.van-toast--text .van-toast__text{margin-top:0}.van-toast--top{top:20%}.van-toast--bottom{top:auto;bottom:20%}.van-toast__icon{font-size:36px}.van-toast__loading{padding:4px;color:#fff}.van-toast__text{margin-top:8px}

189
node_modules/vant/es/toast/index.js generated vendored Normal file
View File

@ -0,0 +1,189 @@
import _extends from "@babel/runtime/helpers/esm/extends";
import Vue from 'vue';
import VueToast from './Toast';
import { isObject, isServer } from '../utils';
import { removeNode } from '../utils/dom/node';
var defaultOptions = {
icon: '',
type: 'text',
// @deprecated
mask: false,
value: true,
message: '',
className: '',
overlay: false,
onClose: null,
onOpened: null,
duration: 2000,
iconPrefix: undefined,
position: 'middle',
transition: 'van-fade',
forbidClick: false,
loadingType: undefined,
getContainer: 'body',
overlayStyle: null,
closeOnClick: false,
closeOnClickOverlay: false
}; // default options of specific type
var defaultOptionsMap = {};
var queue = [];
var multiple = false;
var currentOptions = _extends({}, defaultOptions);
function parseOptions(message) {
if (isObject(message)) {
return message;
}
return {
message: message
};
}
function isInDocument(element) {
return document.body.contains(element);
}
function createInstance() {
/* istanbul ignore if */
if (isServer) {
return {};
}
queue = queue.filter(function (item) {
return !item.$el.parentNode || isInDocument(item.$el);
});
if (!queue.length || multiple) {
var toast = new (Vue.extend(VueToast))({
el: document.createElement('div')
});
toast.$on('input', function (value) {
toast.value = value;
});
queue.push(toast);
}
return queue[queue.length - 1];
} // transform toast options to popup props
function transformOptions(options) {
return _extends({}, options, {
overlay: options.mask || options.overlay,
mask: undefined,
duration: undefined
});
}
function Toast(options) {
if (options === void 0) {
options = {};
}
var toast = createInstance(); // should add z-index if previous toast has not disappeared
if (toast.value) {
toast.updateZIndex();
}
options = parseOptions(options);
options = _extends({}, currentOptions, defaultOptionsMap[options.type || currentOptions.type], options);
if (process.env.NODE_ENV === 'development' && options.mask) {
console.warn('[Vant] Toast: "mask" option is deprecated, use "overlay" option instead.');
}
options.clear = function () {
toast.value = false;
if (options.onClose) {
options.onClose();
options.onClose = null;
}
if (multiple && !isServer) {
toast.$on('closed', function () {
clearTimeout(toast.timer);
queue = queue.filter(function (item) {
return item !== toast;
});
removeNode(toast.$el);
toast.$destroy();
});
}
};
_extends(toast, transformOptions(options));
clearTimeout(toast.timer);
if (options.duration > 0) {
toast.timer = setTimeout(function () {
toast.clear();
}, options.duration);
}
return toast;
}
var createMethod = function createMethod(type) {
return function (options) {
return Toast(_extends({
type: type
}, parseOptions(options)));
};
};
['loading', 'success', 'fail'].forEach(function (method) {
Toast[method] = createMethod(method);
});
Toast.clear = function (all) {
if (queue.length) {
if (all) {
queue.forEach(function (toast) {
toast.clear();
});
queue = [];
} else if (!multiple) {
queue[0].clear();
} else {
queue.shift().clear();
}
}
};
Toast.setDefaultOptions = function (type, options) {
if (typeof type === 'string') {
defaultOptionsMap[type] = options;
} else {
_extends(currentOptions, type);
}
};
Toast.resetDefaultOptions = function (type) {
if (typeof type === 'string') {
defaultOptionsMap[type] = null;
} else {
currentOptions = _extends({}, defaultOptions);
defaultOptionsMap = {};
}
};
Toast.allowMultiple = function (value) {
if (value === void 0) {
value = true;
}
multiple = value;
};
Toast.install = function () {
Vue.use(VueToast);
};
Vue.prototype.$toast = Toast;
export default Toast;

75
node_modules/vant/es/toast/index.less generated vendored Normal file
View File

@ -0,0 +1,75 @@
@import '../style/var';
.van-toast {
position: fixed;
top: 50%;
left: 50%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: content-box;
// hack for avoid max-width when use left & fixed
width: @toast-default-width;
max-width: @toast-max-width;
min-height: @toast-default-min-height;
padding: @toast-default-padding;
color: @toast-text-color;
font-size: @toast-font-size;
line-height: @toast-line-height;
// allow newline character
white-space: pre-wrap;
text-align: center;
// https://github.com/vant-ui/vant/issues/8959
word-break: break-all;
background-color: @toast-background-color;
border-radius: @toast-border-radius;
transform: translate3d(-50%, -50%, 0);
&--unclickable {
// lock scroll
overflow: hidden;
// should not add pointer-events: none directly to body tag
// that will cause unexpected tap-highlight-color in mobile safari
* {
pointer-events: none;
}
}
&--text,
&--html {
width: fit-content;
min-width: @toast-text-min-width;
min-height: 0;
padding: @toast-text-padding;
.van-toast__text {
margin-top: 0;
}
}
&--top {
top: @toast-position-top-distance;
}
&--bottom {
top: auto;
bottom: @toast-position-bottom-distance;
}
&__icon {
font-size: @toast-icon-size;
}
&__loading {
padding: @padding-base;
color: @toast-loading-icon-color;
}
&__text {
margin-top: @padding-xs;
}
}

16
node_modules/vant/es/toast/lock-click.js generated vendored Normal file
View File

@ -0,0 +1,16 @@
var lockCount = 0;
export function lockClick(lock) {
if (lock) {
if (!lockCount) {
document.body.classList.add('van-toast--unclickable');
}
lockCount++;
} else {
lockCount--;
if (!lockCount) {
document.body.classList.remove('van-toast--unclickable');
}
}
}

7
node_modules/vant/es/toast/style/index.js generated vendored Normal file
View File

@ -0,0 +1,7 @@
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 '../index.css';

7
node_modules/vant/es/toast/style/less.js generated vendored Normal file
View File

@ -0,0 +1,7 @@
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 '../index.less';