build: compile 1.2.1

This commit is contained in:
rex-zsd 2020-04-12 13:37:52 +08:00
parent e6c97e1904
commit 50ee859046
12 changed files with 124 additions and 72 deletions

View File

@ -203,8 +203,9 @@ VantComponent({
return equal;
});
if (selected) {
currentDate.splice(selectedIndex, 1);
const cancelDate = currentDate.splice(selectedIndex, 1);
this.setData({ currentDate });
this.unselect(cancelDate);
}
else {
this.select([...currentDate, date]);
@ -214,6 +215,12 @@ VantComponent({
this.select(date, true);
}
},
unselect(dateArray) {
const date = dateArray[0];
if (date) {
this.$emit('unselect', copyDates(date));
}
},
select(date, complete) {
const getTime = (date) => (date instanceof Date ? date.getTime() : date);
this.setData({

7
dist/field/index.js vendored
View File

@ -75,8 +75,11 @@ VantComponent({
this.$emit('keyboardheightchange', event.detail);
},
emitChange() {
this.$emit('input', this.value);
this.$emit('change', this.value);
this.setData({ value: this.value });
wx.nextTick(() => {
this.$emit('input', this.value);
this.$emit('change', this.value);
});
},
setShowClear() {
const { clearable, readonly } = this.data;

View File

@ -5,10 +5,10 @@ function inputStyle(autosize) {
if (autosize.constructor === 'Object') {
var style = '';
if (autosize.minHeight) {
style += 'min-height:' + utils.addUnit(autosize.minHeight);
style += 'min-height:' + utils.addUnit(autosize.minHeight) + ';';
}
if (autosize.maxHeight) {
style += 'min-height:' + utils.addUnit(autosize.maxHeight);
style += 'max-height:' + utils.addUnit(autosize.maxHeight) + ';';
}
return style;
}

View File

@ -3,7 +3,7 @@ VantComponent({
relation: {
name: 'index-bar',
type: 'ancestor',
current: 'index-anchor',
current: 'index-anchor'
},
props: {
useSlot: Boolean,
@ -13,5 +13,18 @@ VantComponent({
active: false,
wrapperStyle: '',
anchorStyle: ''
},
methods: {
scrollIntoView(scrollTop) {
this.getBoundingClientRect().then((rect) => {
wx.pageScrollTo({
duration: 0,
scrollTop: scrollTop + rect.top - this.parent.data.stickyOffsetTop
});
});
},
getBoundingClientRect() {
return this.getRect('.van-index-anchor-wrapper');
}
}
});

View File

@ -1,5 +1,6 @@
import { VantComponent } from '../common/component';
import { GREEN } from '../common/color';
import { pageScrollMixin } from '../mixins/page-scroll';
const indexList = () => {
const indexList = [];
const charCodeOfA = 'A'.charCodeAt(0);
@ -16,9 +17,6 @@ VantComponent({
linked() {
this.updateData();
},
linkChanged() {
this.updateData();
},
unlinked() {
this.updateData();
}
@ -36,11 +34,6 @@ VantComponent({
type: String,
value: GREEN
},
scrollTop: {
type: Number,
value: 0,
observer: 'onScroll'
},
stickyOffsetTop: {
type: Number,
value: 0
@ -50,22 +43,34 @@ VantComponent({
value: indexList()
}
},
mixins: [
pageScrollMixin(function (event) {
this.scrollTop = event.scrollTop || 0;
this.onScroll();
})
],
data: {
activeAnchorIndex: null,
showSidebar: false
},
created() {
this.scrollTop = 0;
},
methods: {
updateData() {
this.timer && clearTimeout(this.timer);
this.timer = setTimeout(() => {
this.children = this.getRelationNodes('../index-anchor/index');
this.setData({
showSidebar: !!this.children.length
});
this.setRect().then(() => {
this.onScroll();
});
}, 0);
wx.nextTick(() => {
if (this.timer != null) {
clearTimeout(this.timer);
}
this.timer = setTimeout(() => {
this.setData({
showSidebar: !!this.children.length
});
this.setRect().then(() => {
this.onScroll();
});
}, 0);
});
},
setRect() {
return Promise.all([
@ -80,7 +85,7 @@ VantComponent({
.then((rect) => {
Object.assign(anchor, {
height: rect.height,
top: rect.top + this.data.scrollTop
top: rect.top + this.scrollTop
});
})));
},
@ -88,7 +93,7 @@ VantComponent({
return this.getRect('.van-index-bar').then((rect) => {
Object.assign(this, {
height: rect.height,
top: rect.top + this.data.scrollTop
top: rect.top + this.scrollTop
});
});
},
@ -120,8 +125,8 @@ VantComponent({
}));
},
getActiveAnchorIndex() {
const { children } = this;
const { sticky, scrollTop, stickyOffsetTop } = this.data;
const { children, scrollTop } = this;
const { sticky, stickyOffsetTop } = this.data;
for (let i = this.children.length - 1; i >= 0; i--) {
const preAnchorHeight = i > 0 ? children[i - 1].height : 0;
const reachTop = sticky ? preAnchorHeight + stickyOffsetTop : 0;
@ -132,11 +137,11 @@ VantComponent({
return -1;
},
onScroll() {
const { children = [] } = this;
const { children = [], scrollTop } = this;
if (!children.length) {
return;
}
const { sticky, stickyOffsetTop, zIndex, highlightColor, scrollTop } = this.data;
const { sticky, stickyOffsetTop, zIndex, highlightColor } = this.data;
const active = this.getActiveAnchorIndex();
this.setDiffData({
target: this,
@ -237,11 +242,8 @@ VantComponent({
this.scrollToAnchorIndex = index;
const anchor = this.children.find((item) => item.data.index === this.data.indexList[index]);
if (anchor) {
anchor.scrollIntoView(this.scrollTop);
this.$emit('select', anchor.data.index);
wx.pageScrollTo({
duration: 0,
scrollTop: anchor.top
});
}
}
}

View File

@ -1,6 +1,6 @@
const IMAGE_EXT = ['jpeg', 'jpg', 'gif', 'png', 'svg'];
const IMAGE_EXT = ['jpeg', 'jpg', 'gif', 'png', 'svg', 'webp'];
export function isImageUrl(url) {
return IMAGE_EXT.some(ext => url.indexOf(`.${ext}`) !== -1);
return IMAGE_EXT.some(ext => url.indexOf(`.${ext}`) !== -1 || url.indexOf(`.${ext.toLocaleUpperCase()}`) !== -1); // 有些七牛返回来的后缀的大写,加以判断
}
export function isImageFile(item) {
if (item.type) {

View File

@ -217,8 +217,9 @@ component_1.VantComponent({
return equal;
});
if (selected) {
currentDate.splice(selectedIndex_1, 1);
var cancelDate = currentDate.splice(selectedIndex_1, 1);
this.setData({ currentDate: currentDate });
this.unselect(cancelDate);
}
else {
this.select(__spreadArrays(currentDate, [date]));
@ -228,6 +229,12 @@ component_1.VantComponent({
this.select(date, true);
}
},
unselect: function (dateArray) {
var date = dateArray[0];
if (date) {
this.$emit('unselect', utils_1.copyDates(date));
}
},
select: function (date, complete) {
var getTime = function (date) {
return (date instanceof Date ? date.getTime() : date);

View File

@ -89,8 +89,12 @@ component_1.VantComponent({
this.$emit('keyboardheightchange', event.detail);
},
emitChange: function () {
this.$emit('input', this.value);
this.$emit('change', this.value);
var _this = this;
this.setData({ value: this.value });
wx.nextTick(function () {
_this.$emit('input', _this.value);
_this.$emit('change', _this.value);
});
},
setShowClear: function () {
var _a = this.data, clearable = _a.clearable, readonly = _a.readonly;

View File

@ -5,10 +5,10 @@ function inputStyle(autosize) {
if (autosize.constructor === 'Object') {
var style = '';
if (autosize.minHeight) {
style += 'min-height:' + utils.addUnit(autosize.minHeight);
style += 'min-height:' + utils.addUnit(autosize.minHeight) + ';';
}
if (autosize.maxHeight) {
style += 'min-height:' + utils.addUnit(autosize.maxHeight);
style += 'max-height:' + utils.addUnit(autosize.maxHeight) + ';';
}
return style;
}

View File

@ -5,7 +5,7 @@ component_1.VantComponent({
relation: {
name: 'index-bar',
type: 'ancestor',
current: 'index-anchor',
current: 'index-anchor'
},
props: {
useSlot: Boolean,
@ -15,5 +15,19 @@ component_1.VantComponent({
active: false,
wrapperStyle: '',
anchorStyle: ''
},
methods: {
scrollIntoView: function (scrollTop) {
var _this = this;
this.getBoundingClientRect().then(function (rect) {
wx.pageScrollTo({
duration: 0,
scrollTop: scrollTop + rect.top - _this.parent.data.stickyOffsetTop
});
});
},
getBoundingClientRect: function () {
return this.getRect('.van-index-anchor-wrapper');
}
}
});

View File

@ -2,6 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
var color_1 = require("../common/color");
var page_scroll_1 = require("../mixins/page-scroll");
var indexList = function () {
var indexList = [];
var charCodeOfA = 'A'.charCodeAt(0);
@ -18,9 +19,6 @@ component_1.VantComponent({
linked: function () {
this.updateData();
},
linkChanged: function () {
this.updateData();
},
unlinked: function () {
this.updateData();
}
@ -38,11 +36,6 @@ component_1.VantComponent({
type: String,
value: color_1.GREEN
},
scrollTop: {
type: Number,
value: 0,
observer: 'onScroll'
},
stickyOffsetTop: {
type: Number,
value: 0
@ -52,23 +45,35 @@ component_1.VantComponent({
value: indexList()
}
},
mixins: [
page_scroll_1.pageScrollMixin(function (event) {
this.scrollTop = event.scrollTop || 0;
this.onScroll();
})
],
data: {
activeAnchorIndex: null,
showSidebar: false
},
created: function () {
this.scrollTop = 0;
},
methods: {
updateData: function () {
var _this = this;
this.timer && clearTimeout(this.timer);
this.timer = setTimeout(function () {
_this.children = _this.getRelationNodes('../index-anchor/index');
_this.setData({
showSidebar: !!_this.children.length
});
_this.setRect().then(function () {
_this.onScroll();
});
}, 0);
wx.nextTick(function () {
if (_this.timer != null) {
clearTimeout(_this.timer);
}
_this.timer = setTimeout(function () {
_this.setData({
showSidebar: !!_this.children.length
});
_this.setRect().then(function () {
_this.onScroll();
});
}, 0);
});
},
setRect: function () {
return Promise.all([
@ -85,7 +90,7 @@ component_1.VantComponent({
.then(function (rect) {
Object.assign(anchor, {
height: rect.height,
top: rect.top + _this.data.scrollTop
top: rect.top + _this.scrollTop
});
});
}));
@ -95,7 +100,7 @@ component_1.VantComponent({
return this.getRect('.van-index-bar').then(function (rect) {
Object.assign(_this, {
height: rect.height,
top: rect.top + _this.data.scrollTop
top: rect.top + _this.scrollTop
});
});
},
@ -129,8 +134,8 @@ component_1.VantComponent({
}); });
},
getActiveAnchorIndex: function () {
var children = this.children;
var _a = this.data, sticky = _a.sticky, scrollTop = _a.scrollTop, stickyOffsetTop = _a.stickyOffsetTop;
var _a = this, children = _a.children, scrollTop = _a.scrollTop;
var _b = this.data, sticky = _b.sticky, stickyOffsetTop = _b.stickyOffsetTop;
for (var i = this.children.length - 1; i >= 0; i--) {
var preAnchorHeight = i > 0 ? children[i - 1].height : 0;
var reachTop = sticky ? preAnchorHeight + stickyOffsetTop : 0;
@ -142,11 +147,11 @@ component_1.VantComponent({
},
onScroll: function () {
var _this = this;
var _a = this.children, children = _a === void 0 ? [] : _a;
var _a = this, _b = _a.children, children = _b === void 0 ? [] : _b, scrollTop = _a.scrollTop;
if (!children.length) {
return;
}
var _b = this.data, sticky = _b.sticky, stickyOffsetTop = _b.stickyOffsetTop, zIndex = _b.zIndex, highlightColor = _b.highlightColor, scrollTop = _b.scrollTop;
var _c = this.data, sticky = _c.sticky, stickyOffsetTop = _c.stickyOffsetTop, zIndex = _c.zIndex, highlightColor = _c.highlightColor;
var active = this.getActiveAnchorIndex();
this.setDiffData({
target: this,
@ -236,11 +241,8 @@ component_1.VantComponent({
return item.data.index === _this.data.indexList[index];
});
if (anchor) {
anchor.scrollIntoView(this.scrollTop);
this.$emit('select', anchor.data.index);
wx.pageScrollTo({
duration: 0,
scrollTop: anchor.top
});
}
}
}

View File

@ -1,8 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var IMAGE_EXT = ['jpeg', 'jpg', 'gif', 'png', 'svg'];
var IMAGE_EXT = ['jpeg', 'jpg', 'gif', 'png', 'svg', 'webp'];
function isImageUrl(url) {
return IMAGE_EXT.some(function (ext) { return url.indexOf("." + ext) !== -1; });
return IMAGE_EXT.some(function (ext) { return url.indexOf("." + ext) !== -1 || url.indexOf("." + ext.toLocaleUpperCase()) !== -1; }); // 有些七牛返回来的后缀的大写,加以判断
}
exports.isImageUrl = isImageUrl;
function isImageFile(item) {