@opentiny/vue-renderless 3.5.0-alpha.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/action-sheet/index.js
CHANGED
|
@@ -1,13 +1,58 @@
|
|
|
1
|
-
export var
|
|
1
|
+
export var setSheetStyle = function setSheetStyle(_ref) {
|
|
2
|
+
var state = _ref.state,
|
|
3
|
+
props = _ref.props;
|
|
2
4
|
return function () {
|
|
5
|
+
if (props.contentPosition) {
|
|
6
|
+
state.sheetMaskStyle = {
|
|
7
|
+
'position': 'absolute'
|
|
8
|
+
};
|
|
9
|
+
state.sheetContentStyle = {
|
|
10
|
+
'position': 'absolute',
|
|
11
|
+
'max-height': props.height
|
|
12
|
+
};
|
|
13
|
+
} else {
|
|
14
|
+
state.sheetMaskStyle = {
|
|
15
|
+
'position': 'fixed'
|
|
16
|
+
};
|
|
17
|
+
state.sheetContentStyle = {
|
|
18
|
+
'position': 'fixed',
|
|
19
|
+
'max-height': props.height
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export var initScrollMenu = function initScrollMenu(_ref2) {
|
|
25
|
+
var state = _ref2.state,
|
|
26
|
+
nextTick = _ref2.nextTick,
|
|
27
|
+
refs = _ref2.refs,
|
|
28
|
+
BScroll = _ref2.BScroll;
|
|
29
|
+
return function () {
|
|
30
|
+
nextTick(function () {
|
|
31
|
+
var scrollMenu = refs.scrollMenu;
|
|
32
|
+
if (!state.scroll) {
|
|
33
|
+
state.scroll = new BScroll(scrollMenu, {
|
|
34
|
+
probeType: 3,
|
|
35
|
+
click: true
|
|
36
|
+
});
|
|
37
|
+
} else {
|
|
38
|
+
state.scroll.refresh();
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export var visibleHandle = function visibleHandle(_ref3) {
|
|
44
|
+
var emit = _ref3.emit,
|
|
45
|
+
state = _ref3.state;
|
|
46
|
+
return function () {
|
|
47
|
+
state.scroll = null;
|
|
3
48
|
emit('update:visible', false);
|
|
4
49
|
emit('close', false);
|
|
5
50
|
};
|
|
6
51
|
};
|
|
7
|
-
export var watchVisible = function watchVisible(
|
|
8
|
-
var emit =
|
|
9
|
-
props =
|
|
10
|
-
state =
|
|
52
|
+
export var watchVisible = function watchVisible(_ref4) {
|
|
53
|
+
var emit = _ref4.emit,
|
|
54
|
+
props = _ref4.props,
|
|
55
|
+
state = _ref4.state;
|
|
11
56
|
return function (value) {
|
|
12
57
|
state.active = props.modelValue;
|
|
13
58
|
setTimeout(function () {
|
|
@@ -16,11 +61,12 @@ export var watchVisible = function watchVisible(_ref) {
|
|
|
16
61
|
emit('update:visible', value);
|
|
17
62
|
};
|
|
18
63
|
};
|
|
19
|
-
export var menuHandle = function menuHandle(
|
|
20
|
-
var emit =
|
|
21
|
-
state =
|
|
64
|
+
export var menuHandle = function menuHandle(_ref5) {
|
|
65
|
+
var emit = _ref5.emit,
|
|
66
|
+
state = _ref5.state;
|
|
22
67
|
return function (item) {
|
|
23
68
|
state.active = item.id;
|
|
69
|
+
state.scroll = null;
|
|
24
70
|
emit('update:visible', false);
|
|
25
71
|
emit('update:modelValue', item.id);
|
|
26
72
|
emit('click', item);
|
package/action-sheet/vue.js
CHANGED
|
@@ -1,28 +1,61 @@
|
|
|
1
|
-
import { visibleHandle, watchVisible, menuHandle } from './index';
|
|
2
|
-
export var api = ['state', 'visibleHandle', 'menuHandle'];
|
|
3
|
-
export var renderless = function renderless(props, _ref, _ref2) {
|
|
1
|
+
import { setSheetStyle, initScrollMenu, visibleHandle, watchVisible, menuHandle } from './index';
|
|
2
|
+
export var api = ['state', 'setSheetStyle', 'initScrollMenu', 'visibleHandle', 'menuHandle'];
|
|
3
|
+
export var renderless = function renderless(props, _ref, _ref2, _ref3) {
|
|
4
4
|
var reactive = _ref.reactive,
|
|
5
5
|
watch = _ref.watch;
|
|
6
|
-
var emit = _ref2.emit
|
|
6
|
+
var emit = _ref2.emit,
|
|
7
|
+
nextTick = _ref2.nextTick,
|
|
8
|
+
refs = _ref2.refs;
|
|
9
|
+
var BScroll = _ref3.BScroll;
|
|
7
10
|
var api = {};
|
|
8
11
|
var state = reactive({
|
|
9
12
|
toggle: false,
|
|
10
|
-
active: null
|
|
13
|
+
active: null,
|
|
14
|
+
sheetMaskStyle: {},
|
|
15
|
+
sheetContentStyle: {},
|
|
16
|
+
scroll: null
|
|
11
17
|
});
|
|
12
18
|
watch(function () {
|
|
13
19
|
return props.visible;
|
|
14
|
-
},
|
|
20
|
+
}, function (value) {
|
|
21
|
+
if (value) {
|
|
22
|
+
api.setSheetStyle({
|
|
23
|
+
state: state,
|
|
24
|
+
props: props
|
|
25
|
+
});
|
|
26
|
+
api.initScrollMenu({
|
|
27
|
+
state: state,
|
|
28
|
+
nextTick: nextTick,
|
|
29
|
+
refs: refs,
|
|
30
|
+
BScroll: BScroll
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
api.watchVisible(value);
|
|
34
|
+
});
|
|
15
35
|
Object.assign(api, {
|
|
16
36
|
state: state,
|
|
17
|
-
|
|
37
|
+
setSheetStyle: setSheetStyle({
|
|
18
38
|
state: state,
|
|
19
|
-
|
|
39
|
+
props: props
|
|
40
|
+
}),
|
|
41
|
+
initScrollMenu: initScrollMenu({
|
|
42
|
+
state: state,
|
|
43
|
+
nextTick: nextTick,
|
|
44
|
+
refs: refs,
|
|
45
|
+
BScroll: BScroll
|
|
46
|
+
}),
|
|
47
|
+
visibleHandle: visibleHandle({
|
|
48
|
+
emit: emit,
|
|
49
|
+
state: state
|
|
20
50
|
}),
|
|
21
|
-
visibleHandle: visibleHandle(emit),
|
|
22
51
|
watchVisible: watchVisible({
|
|
23
52
|
emit: emit,
|
|
24
53
|
props: props,
|
|
25
54
|
state: state
|
|
55
|
+
}),
|
|
56
|
+
menuHandle: menuHandle({
|
|
57
|
+
state: state,
|
|
58
|
+
emit: emit
|
|
26
59
|
})
|
|
27
60
|
});
|
|
28
61
|
return api;
|
package/anchor/index.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { addClass, removeClass } from '@opentiny/vue-renderless/common/deps/dom';
|
|
2
|
+
var setFixAnchor = function setFixAnchor(_ref) {
|
|
3
|
+
var vm = _ref.vm;
|
|
4
|
+
var fixRef = vm.$refs.fixRef;
|
|
5
|
+
if (fixRef) {
|
|
6
|
+
fixRef.style.top = fixRef.offsetTop;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
var setMarkClass = function setMarkClass(_ref2) {
|
|
10
|
+
var state = _ref2.state,
|
|
11
|
+
props = _ref2.props;
|
|
12
|
+
var scrollContainer = state.scrollContainer;
|
|
13
|
+
var markClass = props.markClass;
|
|
14
|
+
var activeContentEl = scrollContainer.querySelector("".concat(state.currentLink));
|
|
15
|
+
if (markClass) {
|
|
16
|
+
addClass(activeContentEl, markClass);
|
|
17
|
+
setTimeout(function () {
|
|
18
|
+
removeClass(activeContentEl, markClass);
|
|
19
|
+
}, 1000);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var setScrollContainer = function setScrollContainer(_ref3) {
|
|
23
|
+
var state = _ref3.state,
|
|
24
|
+
api = _ref3.api,
|
|
25
|
+
_ref3$cb = _ref3.cb,
|
|
26
|
+
cb = _ref3$cb === void 0 ? null : _ref3$cb;
|
|
27
|
+
var currentContainer = api.getContainer();
|
|
28
|
+
var scrollContainer = state.scrollContainer;
|
|
29
|
+
if (scrollContainer !== currentContainer) {
|
|
30
|
+
removeClass(scrollContainer, 'tiny-anchor-scroll-container');
|
|
31
|
+
state.scrollContainer = currentContainer;
|
|
32
|
+
addClass(currentContainer, 'tiny-anchor-scroll-container');
|
|
33
|
+
cb && cb();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var updateSkidPosition = function updateSkidPosition(_ref4) {
|
|
37
|
+
var vm = _ref4.vm,
|
|
38
|
+
state = _ref4.state,
|
|
39
|
+
emit = _ref4.emit;
|
|
40
|
+
var currentLink = state.currentLink;
|
|
41
|
+
var activeEl = vm.$refs[currentLink];
|
|
42
|
+
var _vm$$refs = vm.$refs,
|
|
43
|
+
skidRef = _vm$$refs.skidRef,
|
|
44
|
+
maskRef = _vm$$refs.maskRef,
|
|
45
|
+
anchorRef = _vm$$refs.anchorRef;
|
|
46
|
+
if (!activeEl || !anchorRef) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
emit('onChange', currentLink);
|
|
50
|
+
var offsetHeight = activeEl.offsetHeight,
|
|
51
|
+
offsetWidth = activeEl.offsetWidth;
|
|
52
|
+
var _activeEl$getBounding = activeEl.getBoundingClientRect(),
|
|
53
|
+
linkTitleClientTop = _activeEl$getBounding.top,
|
|
54
|
+
linkTitleClientLeft = _activeEl$getBounding.left;
|
|
55
|
+
var _anchorRef$getBoundin = anchorRef.getBoundingClientRect(),
|
|
56
|
+
anchorClientTop = _anchorRef$getBoundin.top,
|
|
57
|
+
anchorClientLeft = _anchorRef$getBoundin.left;
|
|
58
|
+
var offsetTop = linkTitleClientTop - anchorClientTop;
|
|
59
|
+
var offsetLeft = linkTitleClientLeft - anchorClientLeft;
|
|
60
|
+
addClass(skidRef, 'tiny-anchor-orbit-skid--active');
|
|
61
|
+
skidRef.style.top = "".concat(offsetTop, "px");
|
|
62
|
+
skidRef.style.height = "".concat(offsetHeight, "px");
|
|
63
|
+
if (maskRef) {
|
|
64
|
+
maskRef.style.top = "".concat(offsetTop, "px");
|
|
65
|
+
maskRef.style.height = "".concat(offsetHeight, "px");
|
|
66
|
+
maskRef.style.maxWidth = "".concat(offsetWidth + offsetLeft, "px");
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var getCurrentAnchor = function getCurrentAnchor(_ref5) {
|
|
70
|
+
var vm = _ref5.vm,
|
|
71
|
+
state = _ref5.state,
|
|
72
|
+
link = _ref5.link,
|
|
73
|
+
emit = _ref5.emit;
|
|
74
|
+
if (state.currentLink === link) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
state.currentLink = link;
|
|
78
|
+
updateSkidPosition({
|
|
79
|
+
vm: vm,
|
|
80
|
+
state: state,
|
|
81
|
+
emit: emit
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
var addObserver = function addObserver(_ref6) {
|
|
85
|
+
var props = _ref6.props,
|
|
86
|
+
state = _ref6.state;
|
|
87
|
+
var links = props.links;
|
|
88
|
+
var intersectionObserver = state.intersectionObserver;
|
|
89
|
+
var observer = function observer(list) {
|
|
90
|
+
list.forEach(function (item) {
|
|
91
|
+
var link = item.link;
|
|
92
|
+
if (item.children) {
|
|
93
|
+
observer(item.children);
|
|
94
|
+
} else {
|
|
95
|
+
var linkEl = document.querySelector(link);
|
|
96
|
+
linkEl && intersectionObserver.observe(linkEl);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
observer(links);
|
|
101
|
+
};
|
|
102
|
+
var setCurrentHash = function setCurrentHash(state) {
|
|
103
|
+
if (state.currentHash !== location.hash) {
|
|
104
|
+
state.currentHash = location.hash;
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
};
|
|
109
|
+
export var getContainer = function getContainer(_ref7) {
|
|
110
|
+
var props = _ref7.props;
|
|
111
|
+
return function () {
|
|
112
|
+
return props.containerId ? document.querySelector(props.containerId) : document.body;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
export var mounted = function mounted(_ref8) {
|
|
116
|
+
var vm = _ref8.vm,
|
|
117
|
+
state = _ref8.state,
|
|
118
|
+
api = _ref8.api;
|
|
119
|
+
return function () {
|
|
120
|
+
setScrollContainer({
|
|
121
|
+
state: state,
|
|
122
|
+
api: api
|
|
123
|
+
});
|
|
124
|
+
setFixAnchor({
|
|
125
|
+
vm: vm
|
|
126
|
+
});
|
|
127
|
+
api.onItersectionObserver();
|
|
128
|
+
setCurrentHash(state);
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
export var updated = function updated(_ref9) {
|
|
132
|
+
var state = _ref9.state,
|
|
133
|
+
api = _ref9.api;
|
|
134
|
+
return function () {
|
|
135
|
+
var cb = api.onItersectionObserver;
|
|
136
|
+
setScrollContainer({
|
|
137
|
+
state: state,
|
|
138
|
+
api: api,
|
|
139
|
+
cb: cb
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
export var unmounted = function unmounted(_ref10) {
|
|
144
|
+
var state = _ref10.state;
|
|
145
|
+
return function () {
|
|
146
|
+
var intersectionObserver = state.intersectionObserver;
|
|
147
|
+
intersectionObserver.disconnect();
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
export var onItersectionObserver = function onItersectionObserver(_ref11) {
|
|
151
|
+
var vm = _ref11.vm,
|
|
152
|
+
state = _ref11.state,
|
|
153
|
+
props = _ref11.props,
|
|
154
|
+
emit = _ref11.emit;
|
|
155
|
+
return function () {
|
|
156
|
+
state.intersectionObserver = new IntersectionObserver(function (entries) {
|
|
157
|
+
entries.forEach(function (item) {
|
|
158
|
+
var key = item.target.id;
|
|
159
|
+
state.observerLinks[key] = item;
|
|
160
|
+
});
|
|
161
|
+
for (var _i = 0, _Object$values = Object.values(state.observerLinks); _i < _Object$values.length; _i++) {
|
|
162
|
+
var item = _Object$values[_i];
|
|
163
|
+
if (item.isIntersecting && item.intersectionRatio > 0) {
|
|
164
|
+
var link = "#".concat(item.target.id);
|
|
165
|
+
getCurrentAnchor({
|
|
166
|
+
vm: vm,
|
|
167
|
+
state: state,
|
|
168
|
+
link: link,
|
|
169
|
+
emit: emit
|
|
170
|
+
});
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
addObserver({
|
|
176
|
+
props: props,
|
|
177
|
+
state: state
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
export var linkClick = function linkClick(_ref12) {
|
|
182
|
+
var state = _ref12.state,
|
|
183
|
+
vm = _ref12.vm,
|
|
184
|
+
emit = _ref12.emit,
|
|
185
|
+
props = _ref12.props;
|
|
186
|
+
return function (e, item) {
|
|
187
|
+
var link = item.link,
|
|
188
|
+
title = item.title;
|
|
189
|
+
var emitLink = {
|
|
190
|
+
link: link,
|
|
191
|
+
title: title
|
|
192
|
+
};
|
|
193
|
+
emit('linkClick', e, emitLink);
|
|
194
|
+
var isChangeHash = setCurrentHash(state);
|
|
195
|
+
var scrollContainer = state.scrollContainer;
|
|
196
|
+
state.currentLink = link;
|
|
197
|
+
updateSkidPosition({
|
|
198
|
+
vm: vm,
|
|
199
|
+
state: state,
|
|
200
|
+
emit: emit
|
|
201
|
+
});
|
|
202
|
+
setMarkClass({
|
|
203
|
+
state: state,
|
|
204
|
+
props: props
|
|
205
|
+
});
|
|
206
|
+
if (scrollContainer !== document.body && !isChangeHash) {
|
|
207
|
+
var linkEl = scrollContainer.querySelector(item.link);
|
|
208
|
+
var top = linkEl.offsetTop;
|
|
209
|
+
var param = {
|
|
210
|
+
top: top,
|
|
211
|
+
left: 0,
|
|
212
|
+
behavior: 'smooth'
|
|
213
|
+
};
|
|
214
|
+
scrollContainer.scrollTo(param);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
};
|
package/anchor/vue.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { mounted, updated, unmounted, getContainer, linkClick, onItersectionObserver } from './index';
|
|
2
|
+
export var api = ['state', 'getContainer', 'linkClick', 'onItersectionObserver'];
|
|
3
|
+
export var renderless = function renderless(props, _ref, _ref2) {
|
|
4
|
+
var onMounted = _ref.onMounted,
|
|
5
|
+
onUnmounted = _ref.onUnmounted,
|
|
6
|
+
onUpdated = _ref.onUpdated,
|
|
7
|
+
reactive = _ref.reactive;
|
|
8
|
+
var vm = _ref2.vm,
|
|
9
|
+
emit = _ref2.emit;
|
|
10
|
+
var api = {};
|
|
11
|
+
var state = reactive({
|
|
12
|
+
currentLink: '',
|
|
13
|
+
observerLinks: {},
|
|
14
|
+
intersectionObserver: null,
|
|
15
|
+
scrollContainer: null,
|
|
16
|
+
currentHash: ''
|
|
17
|
+
});
|
|
18
|
+
Object.assign(api, {
|
|
19
|
+
state: state,
|
|
20
|
+
mounted: mounted({
|
|
21
|
+
vm: vm,
|
|
22
|
+
state: state,
|
|
23
|
+
api: api
|
|
24
|
+
}),
|
|
25
|
+
updated: updated({
|
|
26
|
+
state: state,
|
|
27
|
+
api: api
|
|
28
|
+
}),
|
|
29
|
+
unmounted: unmounted({
|
|
30
|
+
state: state
|
|
31
|
+
}),
|
|
32
|
+
getContainer: getContainer({
|
|
33
|
+
props: props
|
|
34
|
+
}),
|
|
35
|
+
linkClick: linkClick({
|
|
36
|
+
state: state,
|
|
37
|
+
vm: vm,
|
|
38
|
+
emit: emit,
|
|
39
|
+
props: props
|
|
40
|
+
}),
|
|
41
|
+
onItersectionObserver: onItersectionObserver({
|
|
42
|
+
vm: vm,
|
|
43
|
+
state: state,
|
|
44
|
+
props: props,
|
|
45
|
+
emit: emit
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
onMounted(api.mounted);
|
|
49
|
+
onUpdated(api.updated);
|
|
50
|
+
onUnmounted(api.unmounted);
|
|
51
|
+
return api;
|
|
52
|
+
};
|
package/carousel-item/index.js
CHANGED
|
@@ -74,7 +74,9 @@ export var handleItemClick = function handleItemClick(parent) {
|
|
|
74
74
|
return function () {
|
|
75
75
|
var vnode = parent.$parent;
|
|
76
76
|
if (vnode && vnode.type === parent.$constants.TYPE_CARD) {
|
|
77
|
-
var index = vnode.state.items.
|
|
77
|
+
var index = vnode.state.items.findIndex(function (item) {
|
|
78
|
+
return item.$el === parent.$el;
|
|
79
|
+
});
|
|
78
80
|
vnode.setActiveItem(index);
|
|
79
81
|
}
|
|
80
82
|
};
|
package/dropdown/index.js
CHANGED
|
@@ -54,11 +54,13 @@ export var hide = function hide(_ref4) {
|
|
|
54
54
|
export var handleClick = function handleClick(_ref5) {
|
|
55
55
|
var api = _ref5.api,
|
|
56
56
|
props = _ref5.props,
|
|
57
|
-
state = _ref5.state
|
|
57
|
+
state = _ref5.state,
|
|
58
|
+
emit = _ref5.emit;
|
|
58
59
|
return function () {
|
|
59
60
|
if (props.disabled) {
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
63
|
+
emit('handle-click', state.visible);
|
|
62
64
|
state.visible ? api.hide() : api.show();
|
|
63
65
|
};
|
|
64
66
|
};
|
package/dropdown/vue.js
CHANGED
package/form-item/index.js
CHANGED
|
@@ -39,9 +39,28 @@ export var computedLabelStyle = function computedLabelStyle(_ref2) {
|
|
|
39
39
|
return result;
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
|
-
export var
|
|
42
|
+
export var computedValueStyle = function computedValueStyle(_ref3) {
|
|
43
43
|
var props = _ref3.props,
|
|
44
44
|
state = _ref3.state;
|
|
45
|
+
return function () {
|
|
46
|
+
var result = {};
|
|
47
|
+
if (state.form.labelPosition === POSITION.Top) {
|
|
48
|
+
return result.width = '100%';
|
|
49
|
+
}
|
|
50
|
+
var labelWidth = props.labelWidth || state.form.labelWidth;
|
|
51
|
+
if (labelWidth) {
|
|
52
|
+
if (labelWidth === 'auto') {
|
|
53
|
+
result.width = labelWidth;
|
|
54
|
+
} else {
|
|
55
|
+
result.width = "calc(100% - ".concat(labelWidth, ")");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export var computedContentStyle = function computedContentStyle(_ref4) {
|
|
62
|
+
var props = _ref4.props,
|
|
63
|
+
state = _ref4.state;
|
|
45
64
|
return function () {
|
|
46
65
|
var result = {};
|
|
47
66
|
var label = props.label;
|
|
@@ -64,10 +83,10 @@ export var computedContentStyle = function computedContentStyle(_ref3) {
|
|
|
64
83
|
return result;
|
|
65
84
|
};
|
|
66
85
|
};
|
|
67
|
-
export var computedForm = function computedForm(
|
|
68
|
-
var constants =
|
|
69
|
-
instance =
|
|
70
|
-
state =
|
|
86
|
+
export var computedForm = function computedForm(_ref5) {
|
|
87
|
+
var constants = _ref5.constants,
|
|
88
|
+
instance = _ref5.instance,
|
|
89
|
+
state = _ref5.state;
|
|
71
90
|
return function () {
|
|
72
91
|
var FORM_NAME = constants.FORM_NAME,
|
|
73
92
|
FORM_ITEM_NAME = constants.FORM_ITEM_NAME;
|
|
@@ -83,9 +102,9 @@ export var computedForm = function computedForm(_ref4) {
|
|
|
83
102
|
return parent;
|
|
84
103
|
};
|
|
85
104
|
};
|
|
86
|
-
export var computedIsRequired = function computedIsRequired(
|
|
87
|
-
var api =
|
|
88
|
-
state =
|
|
105
|
+
export var computedIsRequired = function computedIsRequired(_ref6) {
|
|
106
|
+
var api = _ref6.api,
|
|
107
|
+
state = _ref6.state;
|
|
89
108
|
return function () {
|
|
90
109
|
if (state.validationRequired) {
|
|
91
110
|
return true;
|
|
@@ -130,9 +149,9 @@ export var getPropByPath = function getPropByPath(obj, path, strict) {
|
|
|
130
149
|
v: findObj ? findObj[keys[index]] : null
|
|
131
150
|
};
|
|
132
151
|
};
|
|
133
|
-
export var computedFieldValue = function computedFieldValue(
|
|
134
|
-
var props =
|
|
135
|
-
state =
|
|
152
|
+
export var computedFieldValue = function computedFieldValue(_ref7) {
|
|
153
|
+
var props = _ref7.props,
|
|
154
|
+
state = _ref7.state;
|
|
136
155
|
return function () {
|
|
137
156
|
var model = state.form.model;
|
|
138
157
|
if (!model || !props.prop) {
|
|
@@ -145,12 +164,12 @@ export var computedFieldValue = function computedFieldValue(_ref6) {
|
|
|
145
164
|
return getPropByPath(model, path, true).v;
|
|
146
165
|
};
|
|
147
166
|
};
|
|
148
|
-
export var mounted = function mounted(
|
|
149
|
-
var api =
|
|
150
|
-
instance =
|
|
151
|
-
props =
|
|
152
|
-
state =
|
|
153
|
-
refs =
|
|
167
|
+
export var mounted = function mounted(_ref8) {
|
|
168
|
+
var api = _ref8.api,
|
|
169
|
+
instance = _ref8.instance,
|
|
170
|
+
props = _ref8.props,
|
|
171
|
+
state = _ref8.state,
|
|
172
|
+
refs = _ref8.refs;
|
|
154
173
|
return function () {
|
|
155
174
|
state.tooltip = refs.tooltip;
|
|
156
175
|
if (props.prop) {
|
|
@@ -164,20 +183,20 @@ export var mounted = function mounted(_ref7) {
|
|
|
164
183
|
}
|
|
165
184
|
};
|
|
166
185
|
};
|
|
167
|
-
export var unmounted = function unmounted(
|
|
168
|
-
var api =
|
|
169
|
-
instance =
|
|
170
|
-
state =
|
|
186
|
+
export var unmounted = function unmounted(_ref9) {
|
|
187
|
+
var api = _ref9.api,
|
|
188
|
+
instance = _ref9.instance,
|
|
189
|
+
state = _ref9.state;
|
|
171
190
|
return function () {
|
|
172
191
|
state.canShowTip = false;
|
|
173
192
|
api.dispatch('Form', 'form:removeField', instance);
|
|
174
193
|
};
|
|
175
194
|
};
|
|
176
|
-
export var validate = function validate(
|
|
177
|
-
var api =
|
|
178
|
-
props =
|
|
179
|
-
state =
|
|
180
|
-
t =
|
|
195
|
+
export var validate = function validate(_ref10) {
|
|
196
|
+
var api = _ref10.api,
|
|
197
|
+
props = _ref10.props,
|
|
198
|
+
state = _ref10.state,
|
|
199
|
+
t = _ref10.t;
|
|
181
200
|
return function (trigger) {
|
|
182
201
|
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
|
|
183
202
|
return undefined;
|
|
@@ -226,11 +245,11 @@ export var clearValidate = function clearValidate(state) {
|
|
|
226
245
|
state.validateDisabled = false;
|
|
227
246
|
};
|
|
228
247
|
};
|
|
229
|
-
export var resetField = function resetField(
|
|
230
|
-
var api =
|
|
231
|
-
nextTick =
|
|
232
|
-
props =
|
|
233
|
-
state =
|
|
248
|
+
export var resetField = function resetField(_ref11) {
|
|
249
|
+
var api = _ref11.api,
|
|
250
|
+
nextTick = _ref11.nextTick,
|
|
251
|
+
props = _ref11.props,
|
|
252
|
+
state = _ref11.state;
|
|
234
253
|
return function () {
|
|
235
254
|
if (state.getValidateType === 'tip') {
|
|
236
255
|
state.canShowTip = false;
|
|
@@ -259,9 +278,9 @@ export var resetField = function resetField(_ref10) {
|
|
|
259
278
|
api.broadcast('timeSelect', 'fieldReset', state.initialValue);
|
|
260
279
|
};
|
|
261
280
|
};
|
|
262
|
-
export var getRules = function getRules(
|
|
263
|
-
var props =
|
|
264
|
-
state =
|
|
281
|
+
export var getRules = function getRules(_ref12) {
|
|
282
|
+
var props = _ref12.props,
|
|
283
|
+
state = _ref12.state;
|
|
265
284
|
return function () {
|
|
266
285
|
var formRules = state.form.rules;
|
|
267
286
|
var selfRules = props.rules;
|
|
@@ -294,9 +313,9 @@ export var onFieldBlur = function onFieldBlur(api) {
|
|
|
294
313
|
api.validate('blur');
|
|
295
314
|
};
|
|
296
315
|
};
|
|
297
|
-
export var onFieldChange = function onFieldChange(
|
|
298
|
-
var api =
|
|
299
|
-
state =
|
|
316
|
+
export var onFieldChange = function onFieldChange(_ref13) {
|
|
317
|
+
var api = _ref13.api,
|
|
318
|
+
state = _ref13.state;
|
|
300
319
|
return function () {
|
|
301
320
|
if (state.validateDisabled) {
|
|
302
321
|
state.validateDisabled = false;
|
|
@@ -310,11 +329,11 @@ export var updateComputedLabelWidth = function updateComputedLabelWidth(state) {
|
|
|
310
329
|
state.computedLabelWidth = width ? "".concat(width, "px") : '';
|
|
311
330
|
};
|
|
312
331
|
};
|
|
313
|
-
export var addValidateEvents = function addValidateEvents(
|
|
314
|
-
var api =
|
|
315
|
-
instance =
|
|
316
|
-
props =
|
|
317
|
-
state =
|
|
332
|
+
export var addValidateEvents = function addValidateEvents(_ref14) {
|
|
333
|
+
var api = _ref14.api,
|
|
334
|
+
instance = _ref14.instance,
|
|
335
|
+
props = _ref14.props,
|
|
336
|
+
state = _ref14.state;
|
|
318
337
|
return function () {
|
|
319
338
|
var rules = api.getRules();
|
|
320
339
|
if (rules.length || props.required !== undefined) {
|
|
@@ -331,9 +350,9 @@ export var removeValidateEvents = function removeValidateEvents(instance) {
|
|
|
331
350
|
instance.$off();
|
|
332
351
|
};
|
|
333
352
|
};
|
|
334
|
-
export var updateTip = function updateTip(
|
|
335
|
-
var refs =
|
|
336
|
-
state =
|
|
353
|
+
export var updateTip = function updateTip(_ref15) {
|
|
354
|
+
var refs = _ref15.refs,
|
|
355
|
+
state = _ref15.state;
|
|
337
356
|
return function () {
|
|
338
357
|
if (state.getValidateType !== 'tip' && !state.canShowTip) {
|
|
339
358
|
return;
|
|
@@ -363,9 +382,9 @@ export var getValueByPath = function getValueByPath(object, prop) {
|
|
|
363
382
|
}
|
|
364
383
|
return result;
|
|
365
384
|
};
|
|
366
|
-
export var wrapValidate = function wrapValidate(
|
|
367
|
-
var validateFunc =
|
|
368
|
-
props =
|
|
385
|
+
export var wrapValidate = function wrapValidate(_ref16) {
|
|
386
|
+
var validateFunc = _ref16.validateFunc,
|
|
387
|
+
props = _ref16.props;
|
|
369
388
|
if (props.validateDebounce) {
|
|
370
389
|
return debounce(50, validateFunc);
|
|
371
390
|
} else {
|
package/form-item/vue.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { validate, clearValidate, resetField, getRules, getFilteredRule, onFieldBlur, onFieldChange, updateComputedLabelWidth, addValidateEvents, removeValidateEvents, mounted, unmounted, watchError, watchValidateStatus, computedLabelStyle, computedContentStyle, computedForm, computedIsRequired, computedFieldValue, computedGetValidateType, updateTip, wrapValidate } from './index';
|
|
1
|
+
import { validate, clearValidate, resetField, getRules, getFilteredRule, onFieldBlur, onFieldChange, updateComputedLabelWidth, addValidateEvents, removeValidateEvents, mounted, unmounted, watchError, watchValidateStatus, computedLabelStyle, computedValueStyle, computedContentStyle, computedForm, computedIsRequired, computedFieldValue, computedGetValidateType, updateTip, wrapValidate } from './index';
|
|
2
2
|
export var api = ['state', 'validate', 'clearValidate', 'resetField', 'getRules', 'getFilteredRule', 'onFieldBlur', 'onFieldChange', 'updateComputedLabelWidth', 'addValidateEvents', 'removeValidateEvents', 'updateTip'];
|
|
3
3
|
var initState = function initState(_ref) {
|
|
4
4
|
var reactive = _ref.reactive,
|
|
@@ -27,6 +27,9 @@ var initState = function initState(_ref) {
|
|
|
27
27
|
labelStyle: computed(function () {
|
|
28
28
|
return api.computedLabelStyle();
|
|
29
29
|
}),
|
|
30
|
+
valueStyle: computed(function () {
|
|
31
|
+
return api.computedValueStyle();
|
|
32
|
+
}),
|
|
30
33
|
contentStyle: computed(function () {
|
|
31
34
|
return api.computedContentStyle();
|
|
32
35
|
}),
|
|
@@ -79,6 +82,10 @@ var initApi = function initApi(_ref2) {
|
|
|
79
82
|
props: props,
|
|
80
83
|
state: state
|
|
81
84
|
}),
|
|
85
|
+
computedValueStyle: computedValueStyle({
|
|
86
|
+
props: props,
|
|
87
|
+
state: state
|
|
88
|
+
}),
|
|
82
89
|
computedContentStyle: computedContentStyle({
|
|
83
90
|
props: props,
|
|
84
91
|
state: state
|