From 50ee8590466517664c5a64d7f36228d1995d1a40 Mon Sep 17 00:00:00 2001 From: rex-zsd Date: Sun, 12 Apr 2020 13:37:52 +0800 Subject: [PATCH] build: compile 1.2.1 --- dist/calendar/index.js | 9 +++++- dist/field/index.js | 7 +++-- dist/field/index.wxs | 4 +-- dist/index-anchor/index.js | 15 +++++++++- dist/index-bar/index.js | 58 ++++++++++++++++++++------------------ dist/uploader/utils.js | 4 +-- lib/calendar/index.js | 9 +++++- lib/field/index.js | 8 ++++-- lib/field/index.wxs | 4 +-- lib/index-anchor/index.js | 16 ++++++++++- lib/index-bar/index.js | 58 ++++++++++++++++++++------------------ lib/uploader/utils.js | 4 +-- 12 files changed, 124 insertions(+), 72 deletions(-) diff --git a/dist/calendar/index.js b/dist/calendar/index.js index e9a4614e..62ca3ac8 100644 --- a/dist/calendar/index.js +++ b/dist/calendar/index.js @@ -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({ diff --git a/dist/field/index.js b/dist/field/index.js index 4abc4f88..e4cfb54d 100644 --- a/dist/field/index.js +++ b/dist/field/index.js @@ -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; diff --git a/dist/field/index.wxs b/dist/field/index.wxs index bd9b7143..51b03781 100644 --- a/dist/field/index.wxs +++ b/dist/field/index.wxs @@ -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; } diff --git a/dist/index-anchor/index.js b/dist/index-anchor/index.js index 0e9d1756..94f50600 100644 --- a/dist/index-anchor/index.js +++ b/dist/index-anchor/index.js @@ -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'); + } } }); diff --git a/dist/index-bar/index.js b/dist/index-bar/index.js index 8bd9f8d7..aaee3966 100644 --- a/dist/index-bar/index.js +++ b/dist/index-bar/index.js @@ -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 - }); } } } diff --git a/dist/uploader/utils.js b/dist/uploader/utils.js index 9326fe24..26389acd 100644 --- a/dist/uploader/utils.js +++ b/dist/uploader/utils.js @@ -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) { diff --git a/lib/calendar/index.js b/lib/calendar/index.js index 25d7256b..a77863c6 100644 --- a/lib/calendar/index.js +++ b/lib/calendar/index.js @@ -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); diff --git a/lib/field/index.js b/lib/field/index.js index 4dcb42c2..448da0e9 100644 --- a/lib/field/index.js +++ b/lib/field/index.js @@ -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; diff --git a/lib/field/index.wxs b/lib/field/index.wxs index bd9b7143..51b03781 100644 --- a/lib/field/index.wxs +++ b/lib/field/index.wxs @@ -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; } diff --git a/lib/index-anchor/index.js b/lib/index-anchor/index.js index fbc4e4bd..4e22b2be 100644 --- a/lib/index-anchor/index.js +++ b/lib/index-anchor/index.js @@ -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'); + } } }); diff --git a/lib/index-bar/index.js b/lib/index-bar/index.js index d486a02d..679f67fa 100644 --- a/lib/index-bar/index.js +++ b/lib/index-bar/index.js @@ -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 - }); } } } diff --git a/lib/uploader/utils.js b/lib/uploader/utils.js index 12e9e2ac..8b59f418 100644 --- a/lib/uploader/utils.js +++ b/lib/uploader/utils.js @@ -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) {