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

36
node_modules/vant/lib/mixins/bind-event.js generated vendored Normal file
View File

@ -0,0 +1,36 @@
"use strict";
exports.__esModule = true;
exports.BindEventMixin = BindEventMixin;
var _event = require("../utils/dom/event");
/**
* Bind event when mounted or activated
*/
var uid = 0;
function BindEventMixin(handler) {
var key = "binded_" + uid++;
function bind() {
if (!this[key]) {
handler.call(this, _event.on, true);
this[key] = true;
}
}
function unbind() {
if (this[key]) {
handler.call(this, _event.off, false);
this[key] = false;
}
}
return {
mounted: bind,
activated: bind,
deactivated: unbind,
beforeDestroy: unbind
};
}

152
node_modules/vant/lib/mixins/checkbox.js generated vendored Normal file
View File

@ -0,0 +1,152 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.CheckboxMixin = void 0;
var _icon = _interopRequireDefault(require("../icon"));
var _field = require("./field");
var _relation = require("./relation");
var _utils = require("../utils");
/**
* Common part of Checkbox & Radio
*/
var CheckboxMixin = function CheckboxMixin(_ref) {
var parent = _ref.parent,
bem = _ref.bem,
role = _ref.role;
return {
mixins: [(0, _relation.ChildrenMixin)(parent), _field.FieldMixin],
props: {
name: null,
value: null,
disabled: Boolean,
iconSize: [Number, String],
checkedColor: String,
labelPosition: String,
labelDisabled: Boolean,
shape: {
type: String,
default: 'round'
},
bindGroup: {
type: Boolean,
default: true
}
},
computed: {
disableBindRelation: function disableBindRelation() {
return !this.bindGroup;
},
isDisabled: function isDisabled() {
return this.parent && this.parent.disabled || this.disabled;
},
direction: function direction() {
return this.parent && this.parent.direction || null;
},
iconStyle: function iconStyle() {
var checkedColor = this.checkedColor || this.parent && this.parent.checkedColor;
if (checkedColor && this.checked && !this.isDisabled) {
return {
borderColor: checkedColor,
backgroundColor: checkedColor
};
}
},
tabindex: function tabindex() {
if (this.isDisabled || role === 'radio' && !this.checked) {
return -1;
}
return 0;
}
},
methods: {
onClick: function onClick(event) {
var _this = this;
var target = event.target;
var icon = this.$refs.icon;
var iconClicked = icon === target || (icon == null ? void 0 : icon.contains(target));
if (!this.isDisabled && (iconClicked || !this.labelDisabled)) {
this.toggle(); // wait for toggle method to complete
// so we can get the changed value in the click event listener
setTimeout(function () {
_this.$emit('click', event);
});
} else {
this.$emit('click', event);
}
},
genIcon: function genIcon() {
var h = this.$createElement;
var checked = this.checked;
var iconSize = this.iconSize || this.parent && this.parent.iconSize;
return h("div", {
"ref": "icon",
"class": bem('icon', [this.shape, {
disabled: this.isDisabled,
checked: checked
}]),
"style": {
fontSize: (0, _utils.addUnit)(iconSize)
}
}, [this.slots('icon', {
checked: checked
}) || h(_icon.default, {
"attrs": {
"name": "success"
},
"style": this.iconStyle
})]);
},
genLabel: function genLabel() {
var h = this.$createElement;
var slot = this.slots();
if (slot) {
return h("span", {
"class": bem('label', [this.labelPosition, {
disabled: this.isDisabled
}])
}, [slot]);
}
}
},
render: function render() {
var h = arguments[0];
var Children = [this.genIcon()];
if (this.labelPosition === 'left') {
Children.unshift(this.genLabel());
} else {
Children.push(this.genLabel());
}
return h("div", {
"attrs": {
"role": role,
"tabindex": this.tabindex,
"aria-checked": String(this.checked)
},
"class": bem([{
disabled: this.isDisabled,
'label-disabled': this.labelDisabled
}, this.direction]),
"on": {
"click": this.onClick
}
}, [Children]);
}
};
};
exports.CheckboxMixin = CheckboxMixin;

41
node_modules/vant/lib/mixins/click-outside.js generated vendored Normal file
View File

@ -0,0 +1,41 @@
"use strict";
exports.__esModule = true;
exports.ClickOutsideMixin = void 0;
var _event = require("../utils/dom/event");
/**
* Listen to click outside event
*/
var ClickOutsideMixin = function ClickOutsideMixin(config) {
return {
props: {
closeOnClickOutside: {
type: Boolean,
default: true
}
},
data: function data() {
var _this = this;
var clickOutsideHandler = function clickOutsideHandler(event) {
if (_this.closeOnClickOutside && !_this.$el.contains(event.target)) {
_this[config.method]();
}
};
return {
clickOutsideHandler: clickOutsideHandler
};
},
mounted: function mounted() {
(0, _event.on)(document, config.event, this.clickOutsideHandler);
},
beforeDestroy: function beforeDestroy() {
(0, _event.off)(document, config.event, this.clickOutsideHandler);
}
};
};
exports.ClickOutsideMixin = ClickOutsideMixin;

46
node_modules/vant/lib/mixins/close-on-popstate.js generated vendored Normal file
View File

@ -0,0 +1,46 @@
"use strict";
exports.__esModule = true;
exports.CloseOnPopstateMixin = void 0;
var _event = require("../utils/dom/event");
var _bindEvent = require("./bind-event");
var CloseOnPopstateMixin = {
mixins: [(0, _bindEvent.BindEventMixin)(function (bind, isBind) {
this.handlePopstate(isBind && this.closeOnPopstate);
})],
props: {
closeOnPopstate: Boolean
},
data: function data() {
return {
bindStatus: false
};
},
watch: {
closeOnPopstate: function closeOnPopstate(val) {
this.handlePopstate(val);
}
},
methods: {
onPopstate: function onPopstate() {
this.close();
this.shouldReopen = false;
},
handlePopstate: function handlePopstate(bind) {
/* istanbul ignore if */
if (this.$isServer) {
return;
}
if (this.bindStatus !== bind) {
this.bindStatus = bind;
var action = bind ? _event.on : _event.off;
action(window, 'popstate', this.onPopstate);
}
}
}
};
exports.CloseOnPopstateMixin = CloseOnPopstateMixin;

29
node_modules/vant/lib/mixins/field.js generated vendored Normal file
View File

@ -0,0 +1,29 @@
"use strict";
exports.__esModule = true;
exports.FieldMixin = void 0;
var FieldMixin = {
inject: {
vanField: {
default: null
}
},
watch: {
value: function value() {
var field = this.vanField;
if (field) {
field.resetValidation();
field.validateWithTrigger('onChange');
}
}
},
created: function created() {
var field = this.vanField;
if (field && !field.children) {
field.children = this;
}
}
};
exports.FieldMixin = FieldMixin;

23
node_modules/vant/lib/mixins/popup/context.js generated vendored Normal file
View File

@ -0,0 +1,23 @@
"use strict";
exports.__esModule = true;
exports.context = void 0;
var context = {
zIndex: 2000,
lockCount: 0,
stack: [],
find: function find(vm) {
return this.stack.filter(function (item) {
return item.vm === vm;
})[0];
},
remove: function remove(vm) {
var item = this.find(vm);
if (!item) return;
item.vm = null;
item.overlay = null;
var index = this.stack.indexOf(item);
this.stack.splice(index, 1);
}
};
exports.context = context;

236
node_modules/vant/lib/mixins/popup/index.js generated vendored Normal file
View File

@ -0,0 +1,236 @@
"use strict";
exports.__esModule = true;
exports.PopupMixin = PopupMixin;
exports.popupMixinProps = void 0;
var _context = require("./context");
var _overlay = require("./overlay");
var _event = require("../../utils/dom/event");
var _node = require("../../utils/dom/node");
var _scroll = require("../../utils/dom/scroll");
var _touch = require("../touch");
var _portal = require("../portal");
var _closeOnPopstate = require("../close-on-popstate");
// Context
// Utils
// Mixins
var popupMixinProps = {
// Initial rendering animation
transitionAppear: Boolean,
// whether to show popup
value: Boolean,
// whether to show overlay
overlay: Boolean,
// overlay custom style
overlayStyle: Object,
// overlay custom class name
overlayClass: String,
// whether to close popup when overlay is clicked
closeOnClickOverlay: Boolean,
// z-index
zIndex: [Number, String],
// prevent body scroll
lockScroll: {
type: Boolean,
default: true
},
// whether to lazy render
lazyRender: {
type: Boolean,
default: true
}
};
exports.popupMixinProps = popupMixinProps;
function PopupMixin(options) {
if (options === void 0) {
options = {};
}
return {
mixins: [_touch.TouchMixin, _closeOnPopstate.CloseOnPopstateMixin, (0, _portal.PortalMixin)({
afterPortal: function afterPortal() {
if (this.overlay) {
(0, _overlay.updateOverlay)();
}
}
})],
provide: function provide() {
return {
vanPopup: this
};
},
props: popupMixinProps,
data: function data() {
this.onReopenCallback = [];
return {
inited: this.value
};
},
computed: {
shouldRender: function shouldRender() {
return this.inited || !this.lazyRender;
}
},
watch: {
value: function value(val) {
var type = val ? 'open' : 'close';
this.inited = this.inited || this.value;
this[type]();
if (!options.skipToggleEvent) {
this.$emit(type);
}
},
overlay: 'renderOverlay'
},
mounted: function mounted() {
if (this.value) {
this.open();
}
},
/* istanbul ignore next */
activated: function activated() {
if (this.shouldReopen) {
this.$emit('input', true);
this.shouldReopen = false;
}
},
beforeDestroy: function beforeDestroy() {
(0, _overlay.removeOverlay)(this);
if (this.opened) {
this.removeLock();
}
if (this.getContainer) {
(0, _node.removeNode)(this.$el);
}
},
/* istanbul ignore next */
deactivated: function deactivated() {
if (this.value) {
this.close();
this.shouldReopen = true;
}
},
methods: {
open: function open() {
/* istanbul ignore next */
if (this.$isServer || this.opened) {
return;
} // cover default zIndex
if (this.zIndex !== undefined) {
_context.context.zIndex = this.zIndex;
}
this.opened = true;
this.renderOverlay();
this.addLock();
this.onReopenCallback.forEach(function (callback) {
callback();
});
},
addLock: function addLock() {
if (this.lockScroll) {
(0, _event.on)(document, 'touchstart', this.touchStart);
(0, _event.on)(document, 'touchmove', this.onTouchMove);
if (!_context.context.lockCount) {
document.body.classList.add('van-overflow-hidden');
}
_context.context.lockCount++;
}
},
removeLock: function removeLock() {
if (this.lockScroll && _context.context.lockCount) {
_context.context.lockCount--;
(0, _event.off)(document, 'touchstart', this.touchStart);
(0, _event.off)(document, 'touchmove', this.onTouchMove);
if (!_context.context.lockCount) {
document.body.classList.remove('van-overflow-hidden');
}
}
},
close: function close() {
if (!this.opened) {
return;
}
(0, _overlay.closeOverlay)(this);
this.opened = false;
this.removeLock();
this.$emit('input', false);
},
onTouchMove: function onTouchMove(event) {
this.touchMove(event);
var direction = this.deltaY > 0 ? '10' : '01';
var el = (0, _scroll.getScroller)(event.target, this.$el);
var scrollHeight = el.scrollHeight,
offsetHeight = el.offsetHeight,
scrollTop = el.scrollTop;
var status = '11';
/* istanbul ignore next */
if (scrollTop === 0) {
status = offsetHeight >= scrollHeight ? '00' : '01';
} else if (scrollTop + offsetHeight >= scrollHeight) {
status = '10';
}
/* istanbul ignore next */
if (status !== '11' && this.direction === 'vertical' && !(parseInt(status, 2) & parseInt(direction, 2))) {
(0, _event.preventDefault)(event, true);
}
},
renderOverlay: function renderOverlay() {
var _this = this;
if (this.$isServer || !this.value) {
return;
}
this.$nextTick(function () {
_this.updateZIndex(_this.overlay ? 1 : 0);
if (_this.overlay) {
(0, _overlay.openOverlay)(_this, {
zIndex: _context.context.zIndex++,
duration: _this.duration,
className: _this.overlayClass,
customStyle: _this.overlayStyle
});
} else {
(0, _overlay.closeOverlay)(_this);
}
});
},
updateZIndex: function updateZIndex(value) {
if (value === void 0) {
value = 0;
}
this.$el.style.zIndex = ++_context.context.zIndex + value;
},
onReopen: function onReopen(callback) {
this.onReopenCallback.push(callback);
}
}
};
}

97
node_modules/vant/lib/mixins/popup/overlay.js generated vendored Normal file
View File

@ -0,0 +1,97 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.updateOverlay = updateOverlay;
exports.openOverlay = openOverlay;
exports.closeOverlay = closeOverlay;
exports.removeOverlay = removeOverlay;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _overlay = _interopRequireDefault(require("../../overlay"));
var _context = require("./context");
var _functional = require("../../utils/functional");
var _node = require("../../utils/dom/node");
var defaultConfig = {
className: '',
customStyle: {}
};
function mountOverlay(vm) {
return (0, _functional.mount)(_overlay.default, {
on: {
// close popup when overlay clicked & closeOnClickOverlay is true
click: function click() {
vm.$emit('click-overlay');
if (vm.closeOnClickOverlay) {
if (vm.onClickOverlay) {
vm.onClickOverlay();
} else {
vm.close();
}
}
}
}
});
}
function updateOverlay(vm) {
var item = _context.context.find(vm);
if (item) {
var el = vm.$el;
var config = item.config,
overlay = item.overlay;
if (el && el.parentNode) {
el.parentNode.insertBefore(overlay.$el, el);
}
(0, _extends2.default)(overlay, defaultConfig, config, {
show: true
});
}
}
function openOverlay(vm, config) {
var item = _context.context.find(vm);
if (item) {
item.config = config;
} else {
var overlay = mountOverlay(vm);
_context.context.stack.push({
vm: vm,
config: config,
overlay: overlay
});
}
updateOverlay(vm);
}
function closeOverlay(vm) {
var item = _context.context.find(vm);
if (item) {
item.overlay.show = false;
}
}
function removeOverlay(vm) {
var item = _context.context.find(vm);
if (item) {
(0, _node.removeNode)(item.overlay.$el);
_context.context.remove(vm);
}
}

1
node_modules/vant/lib/mixins/popup/type.js generated vendored Normal file
View File

@ -0,0 +1 @@
"use strict";

53
node_modules/vant/lib/mixins/portal.js generated vendored Normal file
View File

@ -0,0 +1,53 @@
"use strict";
exports.__esModule = true;
exports.PortalMixin = PortalMixin;
function getElement(selector) {
if (typeof selector === 'string') {
return document.querySelector(selector);
}
return selector();
}
function PortalMixin(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
ref = _ref.ref,
afterPortal = _ref.afterPortal;
return {
props: {
getContainer: [String, Function]
},
watch: {
getContainer: 'portal'
},
mounted: function mounted() {
if (this.getContainer) {
this.portal();
}
},
methods: {
portal: function portal() {
var getContainer = this.getContainer;
var el = ref ? this.$refs[ref] : this.$el;
var container;
if (getContainer) {
container = getElement(getContainer);
} else if (this.$parent) {
container = this.$parent.$el;
}
if (container && container !== el.parentNode) {
container.appendChild(el);
}
if (afterPortal) {
afterPortal.call(this);
}
}
}
};
}

84
node_modules/vant/lib/mixins/relation.js generated vendored Normal file
View File

@ -0,0 +1,84 @@
"use strict";
exports.__esModule = true;
exports.ChildrenMixin = ChildrenMixin;
exports.ParentMixin = ParentMixin;
var _vnodes = require("../utils/vnodes");
function ChildrenMixin(_parent, options) {
var _inject, _computed;
if (options === void 0) {
options = {};
}
var indexKey = options.indexKey || 'index';
return {
inject: (_inject = {}, _inject[_parent] = {
default: null
}, _inject),
computed: (_computed = {
parent: function parent() {
if (this.disableBindRelation) {
return null;
}
return this[_parent];
}
}, _computed[indexKey] = function () {
this.bindRelation();
if (this.parent) {
return this.parent.children.indexOf(this);
}
return null;
}, _computed),
watch: {
disableBindRelation: function disableBindRelation(val) {
if (!val) {
this.bindRelation();
}
}
},
mounted: function mounted() {
this.bindRelation();
},
beforeDestroy: function beforeDestroy() {
var _this = this;
if (this.parent) {
this.parent.children = this.parent.children.filter(function (item) {
return item !== _this;
});
}
},
methods: {
bindRelation: function bindRelation() {
if (!this.parent || this.parent.children.indexOf(this) !== -1) {
return;
}
var children = [].concat(this.parent.children, [this]);
(0, _vnodes.sortChildren)(children, this.parent);
this.parent.children = children;
}
}
};
}
function ParentMixin(parent) {
return {
provide: function provide() {
var _ref;
return _ref = {}, _ref[parent] = this, _ref;
},
data: function data() {
return {
children: []
};
}
};
}

29
node_modules/vant/lib/mixins/slots.js generated vendored Normal file
View File

@ -0,0 +1,29 @@
"use strict";
exports.__esModule = true;
exports.SlotsMixin = void 0;
/**
* Use scopedSlots in Vue 2.6+
* downgrade to slots in lower version
*/
var SlotsMixin = {
methods: {
slots: function slots(name, props) {
if (name === void 0) {
name = 'default';
}
var $slots = this.$slots,
$scopedSlots = this.$scopedSlots;
var scopedSlot = $scopedSlots[name];
if (scopedSlot) {
return scopedSlot(props);
}
return $slots[name];
}
}
};
exports.SlotsMixin = SlotsMixin;

69
node_modules/vant/lib/mixins/touch.js generated vendored Normal file
View File

@ -0,0 +1,69 @@
"use strict";
exports.__esModule = true;
exports.TouchMixin = void 0;
var _event = require("../utils/dom/event");
function getDirection(x, y) {
if (x > y) {
return 'horizontal';
}
if (y > x) {
return 'vertical';
}
return '';
}
var TouchMixin = {
data: function data() {
return {
direction: ''
};
},
methods: {
touchStart: function touchStart(event) {
this.resetTouchStatus();
this.startX = event.touches[0].clientX;
this.startY = event.touches[0].clientY;
},
touchMove: function touchMove(event) {
var touch = event.touches[0]; // safari back will set clientX to negative number
this.deltaX = touch.clientX < 0 ? 0 : touch.clientX - this.startX;
this.deltaY = touch.clientY - this.startY;
this.offsetX = Math.abs(this.deltaX);
this.offsetY = Math.abs(this.deltaY); // lock direction when distance is greater than a certain value
var LOCK_DIRECTION_DISTANCE = 10;
if (!this.direction || this.offsetX < LOCK_DIRECTION_DISTANCE && this.offsetY < LOCK_DIRECTION_DISTANCE) {
this.direction = getDirection(this.offsetX, this.offsetY);
}
},
resetTouchStatus: function resetTouchStatus() {
this.direction = '';
this.deltaX = 0;
this.deltaY = 0;
this.offsetX = 0;
this.offsetY = 0;
},
// avoid Vue 2.6 event bubble issues by manually binding events
// https://github.com/vant-ui/vant/issues/3015
bindTouchEvent: function bindTouchEvent(el) {
var onTouchStart = this.onTouchStart,
onTouchMove = this.onTouchMove,
onTouchEnd = this.onTouchEnd;
(0, _event.on)(el, 'touchstart', onTouchStart);
(0, _event.on)(el, 'touchmove', onTouchMove);
if (onTouchEnd) {
(0, _event.on)(el, 'touchend', onTouchEnd);
(0, _event.on)(el, 'touchcancel', onTouchEnd);
}
}
}
};
exports.TouchMixin = TouchMixin;