Skip to content

Commit bd48d16

Browse files
committed
build: package
1 parent ff4cc98 commit bd48d16

File tree

16 files changed

+311
-141
lines changed

16 files changed

+311
-141
lines changed

lib/cube.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/cube.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/form/form.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/form/index.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3887,6 +3887,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
38873887

38883888
exports.default = {
38893889
name: COMPONENT_NAME,
3890+
provide: function provide() {
3891+
return {
3892+
radioGroup: this
3893+
};
3894+
},
3895+
38903896
props: {
38913897
value: [String, Number],
38923898
options: {
@@ -3974,6 +3980,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
39743980

39753981
exports.default = {
39763982
name: COMPONENT_NAME,
3983+
inject: {
3984+
radioGroup: {
3985+
default: null
3986+
}
3987+
},
39773988
props: {
39783989
value: [String, Number],
39793990
option: {
@@ -3994,6 +4005,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
39944005
radioValue: this.value
39954006
};
39964007
},
4008+
created: function created() {
4009+
var _this = this;
4010+
4011+
var radioGroup = this.radioGroup;
4012+
if (radioGroup) {
4013+
this.radioValue = radioGroup.radioValue;
4014+
this._cancelWatchGroup = this.$watch(function () {
4015+
return radioGroup.radioValue;
4016+
}, function (newValue) {
4017+
_this.radioValue = newValue;
4018+
});
4019+
}
4020+
},
4021+
beforeDestroy: function beforeDestroy() {
4022+
this._cancelWatchGroup && this._cancelWatchGroup();
4023+
this._cancelWatchGroup = null;
4024+
},
39974025

39984026
watch: {
39994027
value: function value(newV) {
@@ -4004,6 +4032,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
40044032
newV = Number(newV);
40054033
}
40064034
this.$emit(EVENT_INPUT, newV);
4035+
if (this.radioGroup) {
4036+
this.radioGroup.radioValue = newV;
4037+
}
40074038
}
40084039
},
40094040
computed: {

lib/index.js

Lines changed: 119 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6907,7 +6907,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
69076907
}
69086908

69096909
var Cube = {
6910-
version: "1.12.10",
6910+
version: "1.12.11",
69116911
install: install,
69126912
BScroll: _module.BetterScroll,
69136913
createAPI: _module.createAPI
@@ -10399,6 +10399,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1039910399

1040010400
exports.default = {
1040110401
name: COMPONENT_NAME,
10402+
provide: function provide() {
10403+
return {
10404+
radioGroup: this
10405+
};
10406+
},
10407+
1040210408
props: {
1040310409
value: [String, Number],
1040410410
options: {
@@ -10486,6 +10492,11 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1048610492

1048710493
exports.default = {
1048810494
name: COMPONENT_NAME,
10495+
inject: {
10496+
radioGroup: {
10497+
default: null
10498+
}
10499+
},
1048910500
props: {
1049010501
value: [String, Number],
1049110502
option: {
@@ -10506,6 +10517,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1050610517
radioValue: this.value
1050710518
};
1050810519
},
10520+
created: function created() {
10521+
var _this = this;
10522+
10523+
var radioGroup = this.radioGroup;
10524+
if (radioGroup) {
10525+
this.radioValue = radioGroup.radioValue;
10526+
this._cancelWatchGroup = this.$watch(function () {
10527+
return radioGroup.radioValue;
10528+
}, function (newValue) {
10529+
_this.radioValue = newValue;
10530+
});
10531+
}
10532+
},
10533+
beforeDestroy: function beforeDestroy() {
10534+
this._cancelWatchGroup && this._cancelWatchGroup();
10535+
this._cancelWatchGroup = null;
10536+
},
1050910537

1051010538
watch: {
1051110539
value: function value(newV) {
@@ -10516,6 +10544,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1051610544
newV = Number(newV);
1051710545
}
1051810546
this.$emit(EVENT_INPUT, newV);
10547+
if (this.radioGroup) {
10548+
this.radioGroup.radioValue = newV;
10549+
}
1051910550
}
1052010551
},
1052110552
computed: {
@@ -21781,7 +21812,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
2178121812
Vue.component(_stickyEle2.default.name, _stickyEle2.default);
2178221813
};
2178321814

21784-
_sticky2.default.Ele = _sticky2.default;
21815+
_sticky2.default.Ele = _stickyEle2.default;
2178521816

2178621817
exports.default = _sticky2.default;
2178721818
module.exports = exports['default'];
@@ -22926,11 +22957,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
2292622957
data: function data() {
2292722958
return {
2292822959
items: [],
22929-
list: [],
2293022960
heights: 0,
2293122961
startIndex: 0,
2293222962
loadings: [],
22933-
startOffset: 0,
2293422963
noMore: false
2293522964
};
2293622965
},
@@ -22964,26 +22993,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
2296422993
return this.loadings.length;
2296522994
}
2296622995
},
22967-
watch: {
22968-
list: function list(newV) {
22969-
if (newV.length) {
22970-
this.loadings.pop();
22971-
if (!this.loading) {
22972-
this.loadItems();
22973-
}
22974-
}
22975-
},
22976-
items: function items(newV) {
22977-
if (newV.length > this.list.length) {
22978-
this.getItems();
22979-
}
22980-
}
22996+
created: function created() {
22997+
this.list = [];
22998+
this.promiseStack = [];
2298122999
},
2298223000
mounted: function mounted() {
2298323001
this.checkPromiseCompatibility();
2298423002
this.$el.addEventListener(EVENT_SCROLL, this._onScroll);
2298523003
window.addEventListener(EVENT_RESIZE, this._onResize);
22986-
this.init();
23004+
this.load();
2298723005
},
2298823006
beforeDestroy: function beforeDestroy() {
2298923007
this.$el.removeEventListener(EVENT_SCROLL, this._onScroll);
@@ -22996,40 +23014,78 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
2299623014
(0, _debug.warn)(PROMISE_ERROR);
2299723015
}
2299823016
},
22999-
init: function init() {
23000-
this.load();
23001-
},
2300223017
load: function load() {
2300323018
if (this.infinite) {
23004-
this.items.length += this.size;
23005-
this.loadItems();
23019+
var items = this.items;
23020+
var start = items.length;
23021+
23022+
items.length += this.size;
23023+
var end = items.length;
23024+
this.loadItems(start, end);
23025+
this.getItems();
2300623026
} else if (!this.loading) {
2300723027
this.getItems();
2300823028
}
2300923029
},
2301023030
getItems: function getItems() {
2301123031
var _this = this;
2301223032

23033+
var index = this.promiseStack.length;
23034+
var promiseFetch = this.onFetch();
2301323035
this.loadings.push('pending');
23014-
this.onFetch().then(function (res) {
23036+
this.promiseStack.push(promiseFetch);
23037+
promiseFetch.then(function (res) {
23038+
_this.loadings.pop();
23039+
2301523040
if (!res) {
23016-
_this.noMore = true;
23017-
_this.loadings.pop();
23041+
_this.stopScroll(index);
2301823042
} else {
23019-
_this.list = _this.list.concat(res);
23043+
_this.setList(index, res);
23044+
_this.loadItemsByIndex(index);
23045+
if (res.length < _this.size) {
23046+
_this.stopScroll(index);
23047+
}
2302023048
}
2302123049
});
2302223050
},
23023-
loadItems: function loadItems(isResize) {
23051+
removeUnusedTombs: function removeUnusedTombs(copy, index) {
23052+
var cursor = void 0;
23053+
var size = this.size;
23054+
var start = index * size;
23055+
var end = (index + 1) * size;
23056+
for (cursor = start; cursor < end; cursor++) {
23057+
if (copy[cursor] && copy[cursor].isTombstone) break;
23058+
}
23059+
this.items = copy.slice(0, cursor);
23060+
},
23061+
stopScroll: function stopScroll(index) {
23062+
this.noMore = true;
23063+
this.removeUnusedTombs(this.items.slice(0), index);
23064+
this.updateItemTop();
23065+
this.updateStartIndex();
23066+
},
23067+
setList: function setList(index, res) {
23068+
var list = this.list;
23069+
var baseIndex = index * this.size;
23070+
for (var i = 0; i < res.length; i++) {
23071+
list[baseIndex + i] = res[i];
23072+
}
23073+
},
23074+
loadItemsByIndex: function loadItemsByIndex(index) {
23075+
var size = this.size;
23076+
var start = index * size;
23077+
var end = (index + 1) * size;
23078+
this.loadItems(start, end);
23079+
},
23080+
loadItems: function loadItems(start, end) {
2302423081
var _this2 = this;
2302523082

23083+
var items = this.items;
2302623084
var promiseTasks = [];
23027-
var start = 0;
23028-
var end = this.infinite ? this.items.length : this.list.length;
2302923085
var item = void 0;
2303023086

2303123087
var _loop = function _loop(i) {
23032-
item = _this2.items[i];
23088+
item = items[i];
2303323089

2303423090
if (item && item.loaded) {
2303523091
return 'continue';
@@ -23049,6 +23105,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
2304923105

2305023106
window.Promise.all(promiseTasks).then(function () {
2305123107
_this2.updateItemTop();
23108+
_this2.updateStartIndex();
2305223109
});
2305323110
},
2305423111
setItem: function setItem(index, data) {
@@ -23065,56 +23122,53 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
2306523122
var dom = this.$refs['preloads' + index];
2306623123
if (dom && dom[0]) {
2306723124
cur.height = dom[0].offsetHeight;
23068-
} else {
23125+
} else if (cur) {
2306923126
cur.height = this.tombHeight;
2307023127
}
2307123128
},
2307223129
updateItemTop: function updateItemTop() {
23073-
this.heights = 0;
23074-
for (var i = 0; i < this.items.length; i++) {
23075-
var pre = this.items[i - 1];
23076-
this.items[i].top = pre ? pre.top + pre.height : 0;
23077-
this.heights += this.items[i].height;
23078-
}
23130+
var heights = 0;
23131+
var items = this.items;
23132+
var pre = void 0;
23133+
var current = void 0;
2307923134

23080-
if (this.startOffset) {
23081-
this.setScrollTop();
23135+
for (var i = 0; i < items.length; i++) {
23136+
pre = items[i - 1];
23137+
current = items[i];
23138+
23139+
if (!items[i]) {
23140+
heights += 0;
23141+
} else {
23142+
current.top = pre ? pre.top + pre.height : 0;
23143+
heights += current.height;
23144+
}
2308223145
}
23083-
this.updateIndex();
23146+
this.heights = heights;
2308423147
},
23085-
updateIndex: function updateIndex() {
23148+
updateStartIndex: function updateStartIndex() {
2308623149
var top = this.$el.scrollTop;
23087-
for (var i = 0; i < this.items.length; i++) {
23088-
if (this.items[i].top > top) {
23150+
var item = void 0;
23151+
var items = this.items;
23152+
for (var i = 0; i < items.length; i++) {
23153+
item = items[i];
23154+
if (!item || item.top > top) {
2308923155
this.startIndex = Math.max(0, i - 1);
2309023156
break;
2309123157
}
2309223158
}
2309323159
},
23094-
getStartItemOffset: function getStartItemOffset() {
23095-
if (this.items[this.startIndex]) {
23096-
this.startOffset = this.items[this.startIndex].top - this.$el.scrollTop;
23097-
}
23098-
},
23099-
setScrollTop: function setScrollTop() {
23100-
if (this.items[this.startIndex]) {
23101-
this.$el.scrollTop = this.items[this.startIndex].top - this.startOffset;
23102-
23103-
this.startOffset = 0;
23104-
}
23105-
},
2310623160
_onScroll: function _onScroll() {
23107-
if (this.$el.scrollTop + this.$el.offsetHeight > this.heights - this.offset) {
23161+
if (!this.noMore && this.$el.scrollTop + this.$el.offsetHeight > this.heights - this.offset) {
2310823162
this.load();
2310923163
}
23110-
this.updateIndex();
23164+
this.updateStartIndex();
2311123165
},
2311223166
_onResize: function _onResize() {
23113-
this.getStartItemOffset();
23114-
this.items.forEach(function (item) {
23167+
var items = this.items;
23168+
items.forEach(function (item) {
2311523169
item.loaded = false;
2311623170
});
23117-
this.loadItems(true);
23171+
this.loadItems(0, items.length);
2311823172
}
2311923173
},
2312023174
components: {
@@ -23164,7 +23218,7 @@ module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c
2316423218
}), _vm._v(" "), _c('div', {
2316523219
staticClass: "cube-recycle-list-pool"
2316623220
}, [_vm._l((_vm.items), function(item, index) {
23167-
return (!item.isTombstone && !item.height) ? _c('div', {
23221+
return (item && !item.isTombstone && !item.height) ? _c('div', {
2316823222
ref: 'preloads' + index,
2316923223
refInFor: true,
2317023224
staticClass: "cube-recycle-list-item cube-recycle-list-invisible"
@@ -23174,15 +23228,15 @@ module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c
2317423228
}), _vm._v(" "), _c('div', {
2317523229
ref: "tomb",
2317623230
staticClass: "cube-recycle-list-item cube-recycle-list-invisible"
23177-
}, [_vm._t("tombstone")], 2)], 2)], 2), _vm._v(" "), (!_vm.infinite) ? _c('div', {
23231+
}, [_vm._t("tombstone")], 2)], 2)], 2), _vm._v(" "), (!_vm.infinite && !_vm.noMore) ? _c('div', {
2317823232
staticClass: "cube-recycle-list-loading",
2317923233
style: ({
2318023234
visibility: _vm.loading ? 'visible' : 'hidden'
2318123235
})
2318223236
}, [_vm._t("spinner", [_c('div', {
2318323237
staticClass: "cube-recycle-list-loading-content"
2318423238
}, [_c('cube-loading', {
23185-
staticClass: "spinner"
23239+
staticClass: "cube-recycle-list-spinner"
2318623240
})], 1)])], 2) : _vm._e(), _vm._v(" "), _c('div', {
2318723241
directives: [{
2318823242
name: "show",

0 commit comments

Comments
 (0)