@opentiny/vue-renderless 3.5.0 → 3.6.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/action-sheet/index.js +54 -8
- package/action-sheet/vue.js +42 -9
- package/anchor/index.js +217 -0
- package/anchor/vue.js +52 -0
- package/carousel-item/index.js +3 -1
- package/dropdown/index.js +3 -1
- package/dropdown/vue.js +2 -1
- package/form-item/index.js +67 -48
- package/form-item/vue.js +8 -1
- package/fullscreen/index.js +36 -29
- package/fullscreen/vue.js +2 -1
- package/index-bar/index.js +76 -0
- package/index-bar/vue.js +87 -0
- package/index-bar-anchor/vue.js +20 -0
- package/ip-address/index.js +7 -7
- package/ip-address/vue.js +7 -6
- package/multi-select/index.js +282 -0
- package/multi-select/vue.js +120 -0
- package/package.json +1 -1
- package/pull-refresh/index.js +109 -70
- package/pull-refresh/vue.js +38 -33
- package/rate/index.js +1 -1
- package/slider/index.js +1 -1
- package/split/index.js +9 -0
- package/split/vue.js +8 -3
- package/switch/index.js +6 -3
- package/switch/vue.js +1 -1
- package/tab-nav/index.js +26 -3
- package/tab-nav/vue.js +15 -4
- package/tabs/index.js +46 -26
- package/tabs/vue.js +13 -3
- package/tag/index.js +10 -5
- package/tag/vue.js +4 -1
- package/wheel/index.js +201 -0
- package/wheel/vue.js +110 -0
package/fullscreen/index.js
CHANGED
|
@@ -21,42 +21,49 @@ export var request = function request(_ref2) {
|
|
|
21
21
|
sf = _ref2.sf,
|
|
22
22
|
api = _ref2.api;
|
|
23
23
|
return function () {
|
|
24
|
-
|
|
25
|
-
state.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (props.teleport) {
|
|
35
|
-
if (vm.$el.parentNode === document.body) {
|
|
36
|
-
return;
|
|
24
|
+
var change = function change() {
|
|
25
|
+
if (state.isPageOnly) {
|
|
26
|
+
state.isFullscreen = true;
|
|
27
|
+
api.onChangeFullscreen();
|
|
28
|
+
off(document, 'keyup', api.keypressCallback);
|
|
29
|
+
on(document, 'keyup', api.keypressCallback);
|
|
30
|
+
} else {
|
|
31
|
+
sf.off('change', api.fullScreenCallback);
|
|
32
|
+
sf.on('change', api.fullScreenCallback);
|
|
33
|
+
sf.request(props.teleport ? document.body : vm.$el);
|
|
37
34
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
if (props.teleport) {
|
|
36
|
+
if (vm.$el.parentNode === document.body) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
state.__parentNode = vm.$el.parentNode;
|
|
40
|
+
state.__token = document.createComment('fullscreen-token');
|
|
41
|
+
state.__parentNode.insertBefore(state.__token, vm.$el);
|
|
42
|
+
document.body.appendChild(vm.$el);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
props.beforeChange ? props.beforeChange(change) : change();
|
|
43
46
|
};
|
|
44
47
|
};
|
|
45
48
|
export var exit = function exit(_ref3) {
|
|
46
49
|
var state = _ref3.state,
|
|
47
50
|
api = _ref3.api,
|
|
48
|
-
sf = _ref3.sf
|
|
51
|
+
sf = _ref3.sf,
|
|
52
|
+
props = _ref3.props;
|
|
49
53
|
return function () {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
state.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
var change = function change() {
|
|
55
|
+
if (!state.isFullscreen) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (state.isPageOnly) {
|
|
59
|
+
state.isFullscreen = false;
|
|
60
|
+
api.onChangeFullscreen();
|
|
61
|
+
off(document, 'keyup', api.keypressCallback);
|
|
62
|
+
} else {
|
|
63
|
+
sf.exit();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
props.beforeChange ? props.beforeChange(change) : change();
|
|
60
67
|
};
|
|
61
68
|
};
|
|
62
69
|
export var shadeClick = function shadeClick(_ref4) {
|
package/fullscreen/vue.js
CHANGED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export var switchIndex = function switchIndex(index, state, emit) {
|
|
2
|
+
if (index === state.index) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
emit('select', index);
|
|
6
|
+
state.index = index;
|
|
7
|
+
if (index < state.childrenAnchor.length) {
|
|
8
|
+
var item = state.childrenAnchor[index];
|
|
9
|
+
document.documentElement.scrollTop = item.offsetTop;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export var handleTouchDown = function handleTouchDown(_ref) {
|
|
13
|
+
var state = _ref.state;
|
|
14
|
+
return function () {
|
|
15
|
+
state.isMouseDown = true;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export var handleTouchMove = function handleTouchMove(_ref2) {
|
|
19
|
+
var emit = _ref2.emit,
|
|
20
|
+
state = _ref2.state;
|
|
21
|
+
return function (e) {
|
|
22
|
+
console.log(e, state.isMouseDown);
|
|
23
|
+
if (state.isMouseDown && e.target.id) {
|
|
24
|
+
switchIndex(Number(e.target.id), state, emit);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export var handleTouchUp = function handleTouchUp(_ref3) {
|
|
29
|
+
var state = _ref3.state;
|
|
30
|
+
return function () {
|
|
31
|
+
state.isMouseDown = false;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export var handleIndexClick = function handleIndexClick(_ref4) {
|
|
35
|
+
var emit = _ref4.emit,
|
|
36
|
+
state = _ref4.state;
|
|
37
|
+
return function (value) {
|
|
38
|
+
switchIndex(value.index, state, emit);
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export var updateAnchorChildren = function updateAnchorChildren(_ref5) {
|
|
42
|
+
var state = _ref5.state,
|
|
43
|
+
refs = _ref5.refs;
|
|
44
|
+
return function () {
|
|
45
|
+
var node = refs.indexBarContent;
|
|
46
|
+
if (node) {
|
|
47
|
+
state.childrenAnchor = [];
|
|
48
|
+
getAnchorChildren(node, state);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export var getAnchorChildren = function getAnchorChildren(node, state) {
|
|
53
|
+
node.childNodes.forEach(function (ele) {
|
|
54
|
+
if (ele.className === 'tiny-mobile-index-bar-anchor') {
|
|
55
|
+
state.childrenAnchor.push(ele);
|
|
56
|
+
} else {
|
|
57
|
+
getAnchorChildren(ele, state);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
export var handleScroll = function handleScroll(_ref6) {
|
|
62
|
+
var state = _ref6.state;
|
|
63
|
+
return function () {
|
|
64
|
+
findTopAnchor(state);
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export var findTopAnchor = function findTopAnchor(state) {
|
|
68
|
+
var scrollTop = document.documentElement.scrollTop;
|
|
69
|
+
for (var index = 0; index < state.childrenAnchor.length; index++) {
|
|
70
|
+
var item = state.childrenAnchor[index];
|
|
71
|
+
if (item.offsetTop + item.offsetHeight > scrollTop) {
|
|
72
|
+
state.index = index;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
package/index-bar/vue.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { handleScroll, updateAnchorChildren, handleTouchDown, handleTouchMove, handleTouchUp, handleIndexClick } from './index';
|
|
2
|
+
export var api = ['state', 'handleIndexClick', 'handleScroll', 'updateAnchorChildren', 'handleTouchDown', 'handleTouchMove', 'handleTouchUp', 'handleIndexClick'];
|
|
3
|
+
export var renderless = function renderless(props, _ref, _ref2) {
|
|
4
|
+
var computed = _ref.computed,
|
|
5
|
+
reactive = _ref.reactive,
|
|
6
|
+
onMounted = _ref.onMounted,
|
|
7
|
+
onUnmounted = _ref.onUnmounted,
|
|
8
|
+
onUpdated = _ref.onUpdated,
|
|
9
|
+
watch = _ref.watch;
|
|
10
|
+
var emit = _ref2.emit,
|
|
11
|
+
parent = _ref2.parent,
|
|
12
|
+
refs = _ref2.refs;
|
|
13
|
+
var state = reactive({
|
|
14
|
+
index: 0,
|
|
15
|
+
childrenAnchor: [],
|
|
16
|
+
isFistUpdate: true
|
|
17
|
+
});
|
|
18
|
+
var api = {
|
|
19
|
+
state: state,
|
|
20
|
+
isMouseDown: false,
|
|
21
|
+
handleScroll: handleScroll({
|
|
22
|
+
state: state
|
|
23
|
+
}),
|
|
24
|
+
updateAnchorChildren: updateAnchorChildren({
|
|
25
|
+
emit: emit,
|
|
26
|
+
parent: parent,
|
|
27
|
+
refs: refs,
|
|
28
|
+
state: state
|
|
29
|
+
}),
|
|
30
|
+
handleTouchDown: handleTouchDown({
|
|
31
|
+
state: state
|
|
32
|
+
}),
|
|
33
|
+
handleTouchMove: handleTouchMove({
|
|
34
|
+
emit: emit,
|
|
35
|
+
state: state
|
|
36
|
+
}),
|
|
37
|
+
handleTouchUp: handleTouchUp({
|
|
38
|
+
state: state
|
|
39
|
+
}),
|
|
40
|
+
handleIndexClick: handleIndexClick({
|
|
41
|
+
emit: emit,
|
|
42
|
+
parent: parent,
|
|
43
|
+
refs: refs,
|
|
44
|
+
state: state
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
Object.assign(api, {
|
|
48
|
+
state: state
|
|
49
|
+
});
|
|
50
|
+
onMounted(function (e) {
|
|
51
|
+
window.addEventListener('scroll', api.handleScroll);
|
|
52
|
+
});
|
|
53
|
+
onUnmounted(function () {
|
|
54
|
+
window.removeEventListener('scroll', api.handleScroll);
|
|
55
|
+
});
|
|
56
|
+
watch(function () {
|
|
57
|
+
return state.index;
|
|
58
|
+
}, function (value, oldValue) {
|
|
59
|
+
var isChange = value !== oldValue && value >= 0 && value < parent.indexList.length;
|
|
60
|
+
if (isChange) {
|
|
61
|
+
emit('change', value);
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
immediate: false
|
|
65
|
+
});
|
|
66
|
+
watch(function () {
|
|
67
|
+
return props.indexList;
|
|
68
|
+
}, function () {
|
|
69
|
+
api.updateAnchorChildren({
|
|
70
|
+
refs: refs,
|
|
71
|
+
state: state
|
|
72
|
+
});
|
|
73
|
+
}, {
|
|
74
|
+
immediate: false,
|
|
75
|
+
deep: true
|
|
76
|
+
});
|
|
77
|
+
onUpdated(function () {
|
|
78
|
+
if (state.isFistUpdate) {
|
|
79
|
+
state.isFistUpdate = false;
|
|
80
|
+
api.updateAnchorChildren({
|
|
81
|
+
refs: refs,
|
|
82
|
+
state: state
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return api;
|
|
87
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import './index';
|
|
2
|
+
export var api = ['state'];
|
|
3
|
+
export var renderless = function renderless(props, _ref, _ref2) {
|
|
4
|
+
var computed = _ref.computed,
|
|
5
|
+
reactive = _ref.reactive,
|
|
6
|
+
onMounted = _ref.onMounted,
|
|
7
|
+
onUpdated = _ref.onUpdated,
|
|
8
|
+
watch = _ref.watch;
|
|
9
|
+
var emit = _ref2.emit,
|
|
10
|
+
parent = _ref2.parent,
|
|
11
|
+
refs = _ref2.refs;
|
|
12
|
+
var state = reactive({});
|
|
13
|
+
var api = {
|
|
14
|
+
state: state
|
|
15
|
+
};
|
|
16
|
+
Object.assign(api, {
|
|
17
|
+
state: state
|
|
18
|
+
});
|
|
19
|
+
return api;
|
|
20
|
+
};
|
package/ip-address/index.js
CHANGED
|
@@ -148,7 +148,9 @@ export var select = function select(_ref7) {
|
|
|
148
148
|
};
|
|
149
149
|
export var inputEvent = function inputEvent(_ref9) {
|
|
150
150
|
var api = _ref9.api,
|
|
151
|
+
componentName = _ref9.componentName,
|
|
151
152
|
emit = _ref9.emit,
|
|
153
|
+
eventName = _ref9.eventName,
|
|
152
154
|
props = _ref9.props;
|
|
153
155
|
return function (_ref10) {
|
|
154
156
|
var item = _ref10.item,
|
|
@@ -166,6 +168,7 @@ export var inputEvent = function inputEvent(_ref9) {
|
|
|
166
168
|
}
|
|
167
169
|
value = api.getValue();
|
|
168
170
|
emit('update:modelValue', value, index);
|
|
171
|
+
api.dispatch(componentName, eventName, [value]);
|
|
169
172
|
};
|
|
170
173
|
};
|
|
171
174
|
export var change = function change(_ref11) {
|
|
@@ -192,7 +195,7 @@ export var blur = function blur(_ref12) {
|
|
|
192
195
|
item.value = item.value.replace(/\D/g, '');
|
|
193
196
|
}
|
|
194
197
|
emit('blur', item.value, index);
|
|
195
|
-
api.dispatch(componentName, eventName);
|
|
198
|
+
api.dispatch(componentName, eventName, [item.value]);
|
|
196
199
|
};
|
|
197
200
|
};
|
|
198
201
|
export var keyup = function keyup(_ref14) {
|
|
@@ -229,13 +232,12 @@ export var keyup = function keyup(_ref14) {
|
|
|
229
232
|
};
|
|
230
233
|
};
|
|
231
234
|
var checkError1 = function checkError1(_ref16) {
|
|
232
|
-
var
|
|
233
|
-
Space = _ref16.Space,
|
|
235
|
+
var Space = _ref16.Space,
|
|
234
236
|
NumpadDecimal = _ref16.NumpadDecimal,
|
|
235
237
|
NumpadComma = _ref16.NumpadComma,
|
|
236
238
|
keyCode = _ref16.keyCode,
|
|
237
239
|
value = _ref16.value;
|
|
238
|
-
return [
|
|
240
|
+
return [Space, NumpadDecimal, NumpadComma].indexOf(keyCode) > -1 && value;
|
|
239
241
|
};
|
|
240
242
|
var checkError2 = function checkError2(newValue) {
|
|
241
243
|
return newValue && (isNaN(newValue) || newValue > IPTHRESHOLD.Max);
|
|
@@ -270,13 +272,11 @@ var isError = function isError(_ref20) {
|
|
|
270
272
|
ctrlKey = _ref20.ctrlKey,
|
|
271
273
|
keyCode = _ref20.keyCode,
|
|
272
274
|
newValue = _ref20.newValue;
|
|
273
|
-
var
|
|
274
|
-
Space = KEY_CODE.Space,
|
|
275
|
+
var Space = KEY_CODE.Space,
|
|
275
276
|
NumpadDecimal = KEY_CODE.NumpadDecimal,
|
|
276
277
|
NumpadComma = KEY_CODE.NumpadComma,
|
|
277
278
|
KeyV = KEY_CODE.KeyV;
|
|
278
279
|
return checkError1({
|
|
279
|
-
Tab: Tab,
|
|
280
280
|
Space: Space,
|
|
281
281
|
NumpadDecimal: NumpadDecimal,
|
|
282
282
|
NumpadComma: NumpadComma,
|
package/ip-address/vue.js
CHANGED
|
@@ -75,8 +75,7 @@ var initApi = function initApi(_ref2) {
|
|
|
75
75
|
}),
|
|
76
76
|
change: change({
|
|
77
77
|
api: api,
|
|
78
|
-
emit: emit
|
|
79
|
-
props: props
|
|
78
|
+
emit: emit
|
|
80
79
|
}),
|
|
81
80
|
keydown: keydown({
|
|
82
81
|
api: api,
|
|
@@ -86,7 +85,9 @@ var initApi = function initApi(_ref2) {
|
|
|
86
85
|
inputEvent: inputEvent({
|
|
87
86
|
api: api,
|
|
88
87
|
emit: emit,
|
|
89
|
-
props: props
|
|
88
|
+
props: props,
|
|
89
|
+
componentName: componentName,
|
|
90
|
+
eventName: eventName.change
|
|
90
91
|
})
|
|
91
92
|
}));
|
|
92
93
|
};
|
|
@@ -147,10 +148,10 @@ export var renderless = function renderless(props, _ref4, _ref5) {
|
|
|
147
148
|
broadcast = _ref5.broadcast,
|
|
148
149
|
dispatch = _ref5.dispatch;
|
|
149
150
|
var api = {};
|
|
150
|
-
var componentName = "
|
|
151
|
+
var componentName = "FormItem";
|
|
151
152
|
var eventName = {
|
|
152
|
-
change: "
|
|
153
|
-
blur: "
|
|
153
|
+
change: "form.change",
|
|
154
|
+
blur: "form.blur"
|
|
154
155
|
};
|
|
155
156
|
parent.tinyForm = parent.tinyForm || inject('form', null);
|
|
156
157
|
var handleValue = useHandleValue({
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { cloneDeep } from '@opentiny/vue-renderless/chart-core/deps/utils';
|
|
3
|
+
export var created = function created(_ref) {
|
|
4
|
+
var props = _ref.props,
|
|
5
|
+
state = _ref.state,
|
|
6
|
+
refs = _ref.refs,
|
|
7
|
+
nextTick = _ref.nextTick;
|
|
8
|
+
return function () {
|
|
9
|
+
nextTick(function () {
|
|
10
|
+
state.dataSource = cloneDeep(props.dataSource);
|
|
11
|
+
state.defaultSelectedArray = cloneDeep(props.defaultSelectedArray);
|
|
12
|
+
state.labelLevelsInfo = getLabelLevelsInfo(refs);
|
|
13
|
+
state.labelsStyle = getLabelsStyle(state);
|
|
14
|
+
state.headerInfo = state.dataSource.map(function (item) {
|
|
15
|
+
return {
|
|
16
|
+
isSelected: false,
|
|
17
|
+
title: item.title,
|
|
18
|
+
isUP: false
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export var handleClick = function handleClick(_ref2) {
|
|
25
|
+
var api = _ref2.api,
|
|
26
|
+
props = _ref2.props,
|
|
27
|
+
state = _ref2.state;
|
|
28
|
+
return function (value) {
|
|
29
|
+
var _props$dataSource$val;
|
|
30
|
+
state.wheelData = (_props$dataSource$val = props.dataSource[value]) === null || _props$dataSource$val === void 0 ? void 0 : _props$dataSource$val.children;
|
|
31
|
+
if (state.headerIndex === -1) {
|
|
32
|
+
var _state$defaultSelecte;
|
|
33
|
+
state.showWheel = true;
|
|
34
|
+
state.headerIndex = value;
|
|
35
|
+
state.headerInfo[value] = getNewHeaderInfo(state.headerInfo, value, true);
|
|
36
|
+
state.defaultSelectedIndexs = (_state$defaultSelecte = state.defaultSelectedArray[value]) !== null && _state$defaultSelecte !== void 0 ? _state$defaultSelecte : api.loadDefault(value);
|
|
37
|
+
} else if (state.headerIndex !== value) {
|
|
38
|
+
var _state$defaultSelecte2;
|
|
39
|
+
state.showWheel = true;
|
|
40
|
+
state.headerInfo[state.headerIndex] = getNewHeaderInfo(state.headerInfo, state.headerIndex, false);
|
|
41
|
+
state.headerIndex = value;
|
|
42
|
+
state.headerInfo[value] = getNewHeaderInfo(state.headerInfo, value, true);
|
|
43
|
+
state.defaultSelectedIndexs = (_state$defaultSelecte2 = state.defaultSelectedArray[value]) !== null && _state$defaultSelecte2 !== void 0 ? _state$defaultSelecte2 : api.loadDefault(value);
|
|
44
|
+
} else {
|
|
45
|
+
state.showWheel = !state.showWheel;
|
|
46
|
+
var isUP = state.headerInfo[value].isUP;
|
|
47
|
+
state.headerInfo[value] = getNewHeaderInfo(state.headerInfo, value, !isUP);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export var confirm = function confirm(_ref3) {
|
|
52
|
+
var state = _ref3.state,
|
|
53
|
+
emit = _ref3.emit;
|
|
54
|
+
return function () {
|
|
55
|
+
var wheelLevelItems = getWheelLevelItems(state.wheelData, state.defaultSelectedIndexs);
|
|
56
|
+
var wheelLevelText = getWheelLevelText(wheelLevelItems, state.defaultSelectedIndexs);
|
|
57
|
+
state.headerInfo[state.headerIndex] = {
|
|
58
|
+
isSelected: true,
|
|
59
|
+
title: wheelLevelText,
|
|
60
|
+
isUP: false
|
|
61
|
+
};
|
|
62
|
+
state.defaultSelectedArray[state.headerIndex] = state.defaultSelectedIndexs;
|
|
63
|
+
emit('confirm', state.defaultSelectedIndexs, wheelLevelText);
|
|
64
|
+
state.showWheel = false;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export var reset = function reset(_ref4) {
|
|
68
|
+
var api = _ref4.api,
|
|
69
|
+
props = _ref4.props,
|
|
70
|
+
state = _ref4.state,
|
|
71
|
+
emit = _ref4.emit;
|
|
72
|
+
return function () {
|
|
73
|
+
var _props$defaultSelecte;
|
|
74
|
+
state.headerInfo[state.headerIndex] = {
|
|
75
|
+
isSelected: false,
|
|
76
|
+
title: '',
|
|
77
|
+
isUP: false
|
|
78
|
+
};
|
|
79
|
+
state.defaultSelectedIndexs = (_props$defaultSelecte = props.defaultSelectedArray[state.headerIndex]) !== null && _props$defaultSelecte !== void 0 ? _props$defaultSelecte : api.loadDefault(state.headerIndex);
|
|
80
|
+
state.defaultSelectedArray[state.headerIndex] = state.defaultSelectedIndexs;
|
|
81
|
+
emit('reset', state.headerIndex);
|
|
82
|
+
state.showWheel = false;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
export var wheelChange = function wheelChange(state) {
|
|
86
|
+
return function (indexs) {
|
|
87
|
+
state.defaultSelectedIndexs = indexs;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
export var clickWheelItem = function clickWheelItem(_ref5) {
|
|
91
|
+
var state = _ref5.state,
|
|
92
|
+
emit = _ref5.emit;
|
|
93
|
+
return function (indexs, text) {
|
|
94
|
+
if (indexs.length === 0) {
|
|
95
|
+
state.defaultSelectedIndexs = [-1];
|
|
96
|
+
state.headerInfo[state.headerIndex] = {
|
|
97
|
+
isSelected: false,
|
|
98
|
+
title: '',
|
|
99
|
+
isUP: false
|
|
100
|
+
};
|
|
101
|
+
} else {
|
|
102
|
+
state.defaultSelectedIndexs = indexs;
|
|
103
|
+
state.headerInfo[state.headerIndex] = {
|
|
104
|
+
isSelected: true,
|
|
105
|
+
title: text,
|
|
106
|
+
isUP: false
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
state.defaultSelectedArray[state.headerIndex] = state.defaultSelectedIndexs;
|
|
110
|
+
emit('confirm', indexs, text);
|
|
111
|
+
state.showWheel = false;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
export var getWheelLevelItems = function getWheelLevelItems(wheelData, newIndexs) {
|
|
115
|
+
var level_1 = wheelData.map(function (_ref6) {
|
|
116
|
+
var label = _ref6.label;
|
|
117
|
+
return {
|
|
118
|
+
label: label
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
var level_n = getNextLevel([], wheelData, newIndexs, 0);
|
|
122
|
+
var wheelLevelItems = [];
|
|
123
|
+
if (level_n.length === 0) {
|
|
124
|
+
wheelLevelItems = [level_1];
|
|
125
|
+
} else {
|
|
126
|
+
wheelLevelItems = [level_1].concat(_toConsumableArray(level_n));
|
|
127
|
+
}
|
|
128
|
+
return wheelLevelItems;
|
|
129
|
+
};
|
|
130
|
+
export var getNextLevel = function getNextLevel(levelItems, children, nextIndexs, start) {
|
|
131
|
+
var _children$nextIndexs$, _children$nextIndexs$2;
|
|
132
|
+
var levelItem = (_children$nextIndexs$ = (_children$nextIndexs$2 = children[nextIndexs[start]]) === null || _children$nextIndexs$2 === void 0 ? void 0 : _children$nextIndexs$2.children) !== null && _children$nextIndexs$ !== void 0 ? _children$nextIndexs$ : [];
|
|
133
|
+
if (start !== nextIndexs.length - 1) {
|
|
134
|
+
levelItems.push(levelItem);
|
|
135
|
+
return getNextLevel(levelItems, levelItem, nextIndexs, ++start);
|
|
136
|
+
} else {
|
|
137
|
+
return levelItems;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
export var getWheelLevelText = function getWheelLevelText(wheelLevelItems, selectedIndexs) {
|
|
141
|
+
var selectedLabels = [];
|
|
142
|
+
wheelLevelItems.forEach(function (levelItem, i) {
|
|
143
|
+
var _levelItem$index;
|
|
144
|
+
var index = selectedIndexs[i];
|
|
145
|
+
if ((_levelItem$index = levelItem[index]) !== null && _levelItem$index !== void 0 && _levelItem$index.label) {
|
|
146
|
+
var _levelItem$index2;
|
|
147
|
+
selectedLabels.push((_levelItem$index2 = levelItem[index]) === null || _levelItem$index2 === void 0 ? void 0 : _levelItem$index2.label);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
return selectedLabels.join(' ');
|
|
151
|
+
};
|
|
152
|
+
export var loadDefault = function loadDefault(_ref7) {
|
|
153
|
+
var props = _ref7.props,
|
|
154
|
+
state = _ref7.state;
|
|
155
|
+
return function (value) {
|
|
156
|
+
var _props$defaultSelecte2, _state$dataSource$sta;
|
|
157
|
+
var current = (_props$defaultSelecte2 = props.defaultSelectedArray[value]) !== null && _props$defaultSelecte2 !== void 0 ? _props$defaultSelecte2 : [];
|
|
158
|
+
var defaultSelectedIndexs = [];
|
|
159
|
+
if ((_state$dataSource$sta = state.dataSource[state.headerIndex]) !== null && _state$dataSource$sta !== void 0 && _state$dataSource$sta.hasFooter) {
|
|
160
|
+
var defaultL = current.length;
|
|
161
|
+
var dataSL = getMaxFloor(state.wheelData);
|
|
162
|
+
if (defaultL <= dataSL) {
|
|
163
|
+
defaultSelectedIndexs = current.concat(new Array(dataSL - defaultL).fill(0));
|
|
164
|
+
} else {
|
|
165
|
+
defaultSelectedIndexs = current.slice(0, dataSL);
|
|
166
|
+
}
|
|
167
|
+
} else {
|
|
168
|
+
defaultSelectedIndexs = current.length > 0 ? current : [-1];
|
|
169
|
+
}
|
|
170
|
+
return defaultSelectedIndexs;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
export var getMaxFloor = function getMaxFloor(treeData) {
|
|
174
|
+
var maxFloor = 0;
|
|
175
|
+
var loop = function loop(data, level) {
|
|
176
|
+
data.forEach(function (item) {
|
|
177
|
+
var _item$children;
|
|
178
|
+
item.level = level;
|
|
179
|
+
if (level > maxFloor) {
|
|
180
|
+
maxFloor = level;
|
|
181
|
+
}
|
|
182
|
+
if ((item === null || item === void 0 ? void 0 : (_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) > 0) {
|
|
183
|
+
loop(item.children, level + 1);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
loop(treeData, 1);
|
|
188
|
+
return maxFloor;
|
|
189
|
+
};
|
|
190
|
+
export var getNewHeaderInfo = function getNewHeaderInfo(headerInfo, index, isUP) {
|
|
191
|
+
var _headerInfo$index, _headerInfo$index2;
|
|
192
|
+
return {
|
|
193
|
+
isSelected: (_headerInfo$index = headerInfo[index]) === null || _headerInfo$index === void 0 ? void 0 : _headerInfo$index.isSelected,
|
|
194
|
+
title: (_headerInfo$index2 = headerInfo[index]) === null || _headerInfo$index2 === void 0 ? void 0 : _headerInfo$index2.title,
|
|
195
|
+
isUP: isUP
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
export var getLabelLevelsInfo = function getLabelLevelsInfo(refs) {
|
|
199
|
+
var headerBox = refs.headerBox,
|
|
200
|
+
label = refs.label;
|
|
201
|
+
if (!headerBox || !label) return [];
|
|
202
|
+
var totalWidth = getRect(getEl(headerBox)).width;
|
|
203
|
+
var labelWidth = label.map(function (node) {
|
|
204
|
+
return getRect(getEl(node));
|
|
205
|
+
}).map(function (rect) {
|
|
206
|
+
return rect.width;
|
|
207
|
+
});
|
|
208
|
+
return labelWidth.map(function (labelWidth, idx) {
|
|
209
|
+
var isOver25 = totalWidth * 0.25 < labelWidth;
|
|
210
|
+
return {
|
|
211
|
+
idx: idx,
|
|
212
|
+
labelWidth: labelWidth,
|
|
213
|
+
totalWidth: totalWidth,
|
|
214
|
+
isOver25: isOver25
|
|
215
|
+
};
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
export var getRect = function getRect(el) {
|
|
219
|
+
return {
|
|
220
|
+
top: el.offsetTop,
|
|
221
|
+
left: el.offsetLeft,
|
|
222
|
+
width: el.offsetWidth,
|
|
223
|
+
height: el.offsetHeight
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
export var getEl = function getEl(node) {
|
|
227
|
+
return node.$el || node;
|
|
228
|
+
};
|
|
229
|
+
export var getLabelsStyle = function getLabelsStyle(state) {
|
|
230
|
+
var over25Labels = state.labelLevelsInfo.filter(function (i) {
|
|
231
|
+
return i && !i.isOver25;
|
|
232
|
+
});
|
|
233
|
+
var widthInfo = over25Labels;
|
|
234
|
+
var len = state.dataSource.length;
|
|
235
|
+
if (len >= 4) {
|
|
236
|
+
return getStyleConfig(state.labelLevelsInfo, {
|
|
237
|
+
width: "".concat((1 / len * 100).toFixed(2), "%")
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
if (!widthInfo.length || widthInfo.length === state.labelLevelsInfo.length) {
|
|
241
|
+
return getStyleConfig(state.labelLevelsInfo, {
|
|
242
|
+
maxWidth: "".concat((1 / len * 100).toFixed(2), "%")
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
var fillArr;
|
|
246
|
+
if (widthInfo.length === 1) {
|
|
247
|
+
fillArr = getFillArray(state, widthInfo, "37.5%");
|
|
248
|
+
} else if (widthInfo.length === 2) {
|
|
249
|
+
fillArr = getFillArray(state, widthInfo, "50%");
|
|
250
|
+
}
|
|
251
|
+
widthInfo = widthInfo.concat(fillArr);
|
|
252
|
+
return widthInfo.reduce(function (styles, item) {
|
|
253
|
+
styles[item.idx] = item.maxWidth ? {
|
|
254
|
+
maxWidth: item.maxWidth
|
|
255
|
+
} : {
|
|
256
|
+
maxWidth: "25%"
|
|
257
|
+
};
|
|
258
|
+
return styles;
|
|
259
|
+
}, {});
|
|
260
|
+
};
|
|
261
|
+
export var getStyleConfig = function getStyleConfig(data, style) {
|
|
262
|
+
return data.reduce(function (styleConfig, _, idx) {
|
|
263
|
+
styleConfig[idx] = style;
|
|
264
|
+
return styleConfig;
|
|
265
|
+
}, {});
|
|
266
|
+
};
|
|
267
|
+
export var getFillArray = function getFillArray(state, widthInfo, maxWidth) {
|
|
268
|
+
var labelIndexArr = state.labelLevelsInfo.map(function (_, idx) {
|
|
269
|
+
return idx;
|
|
270
|
+
});
|
|
271
|
+
var mapWidthInfoArr = widthInfo.map(function (i) {
|
|
272
|
+
return i.idx;
|
|
273
|
+
});
|
|
274
|
+
return labelIndexArr.filter(function (i) {
|
|
275
|
+
return mapWidthInfoArr.indexOf(i) === -1;
|
|
276
|
+
}).map(function (i) {
|
|
277
|
+
return {
|
|
278
|
+
idx: i,
|
|
279
|
+
maxWidth: maxWidth
|
|
280
|
+
};
|
|
281
|
+
});
|
|
282
|
+
};
|