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

7
dist/field/index.js vendored
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,8 +1,8 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); 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) { 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; exports.isImageUrl = isImageUrl;
function isImageFile(item) { function isImageFile(item) {