@nutui/nutui 3.1.12-beta.1 → 3.1.14
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/CHANGELOG.md +56 -0
- package/README.md +139 -37
- package/dist/nutui.d.ts +9 -2
- package/dist/nutui.es.js +4830 -2950
- package/dist/nutui.umd.js +4910 -2953
- package/dist/packages/_es/ActionSheet.js +12 -13
- package/dist/packages/_es/Address.js +64 -77
- package/dist/packages/_es/Avatar.js +5 -4
- package/dist/packages/_es/BackTop.js +109 -72
- package/dist/packages/_es/Badge.js +5 -4
- package/dist/packages/_es/Barrage.js +57 -63
- package/dist/packages/_es/Button.js +6 -5
- package/dist/packages/_es/Calendar.js +18 -27
- package/dist/packages/_es/Card.js +8 -7
- package/dist/packages/_es/Cascader.js +547 -0
- package/dist/packages/_es/Cell.js +13 -5
- package/dist/packages/_es/CellGroup.js +14 -7
- package/dist/packages/_es/Checkbox.js +3 -3
- package/dist/packages/_es/CheckboxGroup.js +4 -9
- package/dist/packages/_es/CircleProgress.js +46 -142
- package/dist/packages/_es/Col.js +5 -4
- package/dist/packages/_es/Collapse.js +10 -35
- package/dist/packages/_es/CollapseItem.js +35 -80
- package/dist/packages/_es/CountDown.js +7 -10
- package/dist/packages/_es/CountUp.js +33 -34
- package/dist/packages/_es/DatePicker.js +219 -451
- package/dist/packages/_es/Dialog.js +98 -46
- package/dist/packages/_es/Divider.js +6 -5
- package/dist/packages/_es/Drag.js +50 -76
- package/dist/packages/_es/Elevator.js +53 -81
- package/dist/packages/_es/Empty.js +74 -0
- package/dist/packages/_es/FixedNav.js +9 -8
- package/dist/packages/_es/Form.js +23 -9
- package/dist/packages/_es/FormItem.js +5 -4
- package/dist/packages/_es/Grid.js +12 -0
- package/dist/packages/_es/GridItem.js +149 -0
- package/dist/packages/_es/Icon.js +40 -6
- package/dist/packages/_es/ImagePreview.js +158 -44
- package/dist/packages/_es/Indicator.js +66 -0
- package/dist/packages/_es/InfiniteLoading.js +109 -95
- package/dist/packages/_es/Input.js +21 -22
- package/dist/packages/_es/InputNumber.js +18 -24
- package/dist/packages/_es/Layout.js +2 -2
- package/dist/packages/_es/Menu.js +14 -16
- package/dist/packages/_es/MenuItem.js +11 -9
- package/dist/packages/_es/Navbar.js +7 -7
- package/dist/packages/_es/NoticeBar.js +31 -46
- package/dist/packages/_es/Notify.js +166 -30
- package/dist/packages/_es/NumberKeyboard.js +7 -9
- package/dist/packages/_es/OverLay.js +29 -22
- package/dist/packages/_es/Pagination.js +9 -8
- package/dist/packages/_es/Picker.js +447 -61
- package/dist/packages/_es/Popover.js +34 -161
- package/dist/packages/_es/Popup.js +77 -17
- package/dist/packages/_es/Price.js +7 -18
- package/dist/packages/_es/Progress.js +12 -23
- package/dist/packages/_es/Radio.js +3 -3
- package/dist/packages/_es/RadioGroup.js +2 -2
- package/dist/packages/_es/Range.js +31 -38
- package/dist/packages/_es/Rate.js +35 -17
- package/dist/packages/_es/Row.js +5 -4
- package/dist/packages/_es/SearchBar.js +5 -7
- package/dist/packages/_es/ShortPassword.js +59 -89
- package/dist/packages/_es/Signature.js +71 -70
- package/dist/packages/_es/Skeleton.js +138 -0
- package/dist/packages/_es/Sku.js +43 -53
- package/dist/packages/_es/Step.js +8 -10
- package/dist/packages/_es/Steps.js +2 -2
- package/dist/packages/_es/Swipe.js +28 -43
- package/dist/packages/_es/Swiper.js +418 -17
- package/dist/packages/_es/SwiperItem.js +39 -14
- package/dist/packages/_es/Switch.js +47 -16
- package/dist/packages/_es/TabPane.js +5 -4
- package/dist/packages/_es/Tabbar.js +5 -4
- package/dist/packages/_es/TabbarItem.js +9 -8
- package/dist/packages/_es/Table.js +191 -0
- package/dist/packages/_es/Tabs.js +21 -23
- package/dist/packages/_es/Tag.js +6 -5
- package/dist/packages/_es/TextArea.js +12 -16
- package/dist/packages/_es/TimeDetail.js +5 -7
- package/dist/packages/_es/TimePannel.js +5 -7
- package/dist/packages/_es/TimeSelect.js +7 -12
- package/dist/packages/_es/Toast.js +178 -46
- package/dist/packages/_es/Uploader.js +149 -109
- package/dist/packages/_es/Video.js +405 -0
- package/dist/packages/_es/common.js +136 -0
- package/dist/packages/_es/component.js +1 -1
- package/dist/packages/_es/index.js +7 -58
- package/dist/packages/_es/index2.js +58 -43
- package/dist/packages/_es/index3.js +28 -411
- package/dist/packages/_es/plugin-vue_export-helper.js +13 -0
- package/dist/packages/_es/pxCheck.js +1 -1
- package/dist/packages/_es/raf.js +1 -1
- package/dist/packages/_es/util.js +1 -1
- package/dist/packages/cascader/index.scss +81 -0
- package/dist/packages/cellgroup/index.scss +9 -0
- package/dist/packages/dialog/index.scss +17 -0
- package/dist/packages/drag/index.scss +4 -0
- package/dist/packages/empty/index.scss +33 -0
- package/dist/packages/fixednav/index.scss +6 -1
- package/dist/packages/formitem/index.scss +4 -1
- package/dist/packages/grid/index.scss +10 -0
- package/dist/packages/griditem/index.scss +92 -0
- package/dist/packages/icon/index.scss +2 -1
- package/dist/packages/indicator/index.scss +48 -0
- package/dist/packages/numberkeyboard/index.scss +1 -1
- package/dist/packages/popover/index.scss +2 -2
- package/dist/packages/rate/index.scss +1 -0
- package/dist/packages/skeleton/index.scss +57 -0
- package/dist/packages/table/index.scss +81 -0
- package/dist/packages/tabs/index.scss +16 -0
- package/dist/packages/textarea/index.scss +1 -0
- package/dist/packages/timedetail/index.scss +1 -2
- package/dist/packages/timeselect/index.scss +3 -0
- package/dist/packages/toast/index.scss +6 -0
- package/dist/style.css +1 -1
- package/dist/style.es.js +2 -1
- package/dist/styles/font/config.json +2 -1
- package/dist/styles/font/demo_index.html +26 -3
- package/dist/styles/font/iconfont.css +7 -3
- package/dist/styles/font/iconfont.js +31 -32
- package/dist/styles/font/iconfont.json +7 -0
- package/dist/styles/font/iconfont.ttf +0 -0
- package/dist/styles/font/iconfont.woff +0 -0
- package/dist/styles/font/iconfont.woff2 +0 -0
- package/dist/styles/themes/default.scss +40 -33
- package/dist/styles/variables.scss +54 -1
- package/package.json +2 -3
- package/dist/packages/_es/commonProps.js +0 -30
- package/dist/packages/_es/index.taro.vue_vue&type=script&lang.js +0 -44
- package/dist/packages/_es/use-lock-scroll.js +0 -23
|
@@ -17,21 +17,17 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __require = typeof require !== "undefined" ? require : (x) => {
|
|
21
|
-
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
22
|
-
};
|
|
23
20
|
/*!
|
|
24
|
-
* @nutui/nutui v3.1.
|
|
21
|
+
* @nutui/nutui v3.1.14 Wed Dec 22 2021 20:49:10 GMT+0800 (中国标准时间)
|
|
25
22
|
* (c) 2021 @jdf2e.
|
|
26
23
|
* Released under the MIT License.
|
|
27
24
|
*/
|
|
28
|
-
import
|
|
29
|
-
import {
|
|
30
|
-
import { computed, ref, onMounted, reactive, openBlock, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, renderSlot } from "vue";
|
|
25
|
+
import { u as useTouch } from "./index2.js";
|
|
26
|
+
import { computed, ref, reactive, openBlock, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, renderSlot } from "vue";
|
|
31
27
|
import { c as createComponent } from "./component.js";
|
|
32
|
-
import {
|
|
28
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
33
29
|
const { componentName, create } = createComponent("swipe");
|
|
34
|
-
|
|
30
|
+
const _sfc_main = create({
|
|
35
31
|
props: {
|
|
36
32
|
name: {
|
|
37
33
|
type: String,
|
|
@@ -52,29 +48,21 @@ var _sfc_main = create({
|
|
|
52
48
|
},
|
|
53
49
|
emits: ["open", "close"],
|
|
54
50
|
setup(props, { emit }) {
|
|
55
|
-
const refRandomId = Math.random().toString(36).slice(-8);
|
|
56
51
|
const classes = computed(() => {
|
|
57
52
|
const prefixCls = componentName;
|
|
58
53
|
return {
|
|
59
54
|
[prefixCls]: true
|
|
60
55
|
};
|
|
61
56
|
});
|
|
62
|
-
const getRefWidth =
|
|
63
|
-
|
|
64
|
-
return
|
|
65
|
-
};
|
|
66
|
-
const leftRef = ref();
|
|
67
|
-
const leftRefWidth = ref(0);
|
|
68
|
-
const rightRef = ref();
|
|
69
|
-
const rightRefWidth = ref(0);
|
|
70
|
-
const initWidth = async () => {
|
|
71
|
-
leftRefWidth.value = await getRefWidth(leftRef);
|
|
72
|
-
rightRefWidth.value = await getRefWidth(rightRef);
|
|
57
|
+
const getRefWidth = (ref2) => {
|
|
58
|
+
var _a;
|
|
59
|
+
return ((_a = ref2.value) == null ? void 0 : _a.clientWidth) || 0;
|
|
73
60
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
61
|
+
const leftRef = ref(), leftRefWidth = computed(() => {
|
|
62
|
+
return getRefWidth(leftRef);
|
|
63
|
+
});
|
|
64
|
+
const rightRef = ref(), rightRefWidth = computed(() => {
|
|
65
|
+
return getRefWidth(rightRef);
|
|
78
66
|
});
|
|
79
67
|
let opened = false;
|
|
80
68
|
let position = "";
|
|
@@ -134,7 +122,7 @@ var _sfc_main = create({
|
|
|
134
122
|
return;
|
|
135
123
|
touch.start(event);
|
|
136
124
|
},
|
|
137
|
-
|
|
125
|
+
onTouchMove(event) {
|
|
138
126
|
if (props.disabled)
|
|
139
127
|
return;
|
|
140
128
|
touch.move(event);
|
|
@@ -180,15 +168,20 @@ var _sfc_main = create({
|
|
|
180
168
|
}, touchMethods), {
|
|
181
169
|
leftRef,
|
|
182
170
|
rightRef,
|
|
183
|
-
refRandomId,
|
|
184
171
|
open,
|
|
185
172
|
close
|
|
186
173
|
});
|
|
187
174
|
}
|
|
188
175
|
});
|
|
189
|
-
const _hoisted_1 =
|
|
176
|
+
const _hoisted_1 = {
|
|
177
|
+
class: "nut-swipe__left",
|
|
178
|
+
ref: "leftRef"
|
|
179
|
+
};
|
|
190
180
|
const _hoisted_2 = { class: "nut-swipe__content" };
|
|
191
|
-
const _hoisted_3 =
|
|
181
|
+
const _hoisted_3 = {
|
|
182
|
+
class: "nut-swipe__right",
|
|
183
|
+
ref: "rightRef"
|
|
184
|
+
};
|
|
192
185
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
193
186
|
return openBlock(), createElementBlock("view", {
|
|
194
187
|
class: normalizeClass(_ctx.classes),
|
|
@@ -198,24 +191,16 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
198
191
|
onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args)),
|
|
199
192
|
onTouchcancel: _cache[3] || (_cache[3] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args))
|
|
200
193
|
}, [
|
|
201
|
-
createElementVNode("view",
|
|
202
|
-
class: "nut-swipe__left",
|
|
203
|
-
ref: "leftRef",
|
|
204
|
-
id: "leftRef-" + _ctx.refRandomId
|
|
205
|
-
}, [
|
|
194
|
+
createElementVNode("view", _hoisted_1, [
|
|
206
195
|
renderSlot(_ctx.$slots, "left")
|
|
207
|
-
],
|
|
196
|
+
], 512),
|
|
208
197
|
createElementVNode("view", _hoisted_2, [
|
|
209
198
|
renderSlot(_ctx.$slots, "default")
|
|
210
199
|
]),
|
|
211
|
-
createElementVNode("view",
|
|
212
|
-
class: "nut-swipe__right",
|
|
213
|
-
ref: "rightRef",
|
|
214
|
-
id: "rightRef-" + _ctx.refRandomId
|
|
215
|
-
}, [
|
|
200
|
+
createElementVNode("view", _hoisted_3, [
|
|
216
201
|
renderSlot(_ctx.$slots, "right")
|
|
217
|
-
],
|
|
202
|
+
], 512)
|
|
218
203
|
], 38);
|
|
219
204
|
}
|
|
220
|
-
_sfc_main
|
|
221
|
-
export {
|
|
205
|
+
var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
206
|
+
export { index as default };
|
|
@@ -1,28 +1,429 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.14 Wed Dec 22 2021 20:49:10 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2021 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
+
import { reactive, ref, computed, provide, onMounted, nextTick, onActivated, onDeactivated, onBeforeUnmount, watch, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, renderSlot, Fragment, renderList, createCommentVNode } from "vue";
|
|
6
7
|
import { c as createComponent } from "./component.js";
|
|
7
|
-
import {
|
|
8
|
+
import { u as useExpose } from "./index.js";
|
|
9
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
10
|
+
const DISTANCE = 5;
|
|
11
|
+
function useTouch() {
|
|
12
|
+
const state = reactive({
|
|
13
|
+
startX: 0,
|
|
14
|
+
startY: 0,
|
|
15
|
+
deltaX: 0,
|
|
16
|
+
deltaY: 0,
|
|
17
|
+
offsetX: 0,
|
|
18
|
+
offsetY: 0,
|
|
19
|
+
direction: ""
|
|
20
|
+
});
|
|
21
|
+
const getDirection = (x, y) => {
|
|
22
|
+
if (x > y && x > DISTANCE)
|
|
23
|
+
return "horizontal";
|
|
24
|
+
if (y > x && y > DISTANCE)
|
|
25
|
+
return "vertical";
|
|
26
|
+
return "";
|
|
27
|
+
};
|
|
28
|
+
const reset = () => {
|
|
29
|
+
state.startX = 0;
|
|
30
|
+
state.startY = 0;
|
|
31
|
+
state.deltaX = 0;
|
|
32
|
+
state.deltaY = 0;
|
|
33
|
+
state.offsetX = 0;
|
|
34
|
+
state.offsetY = 0;
|
|
35
|
+
state.direction = "";
|
|
36
|
+
};
|
|
37
|
+
const start = (e) => {
|
|
38
|
+
reset();
|
|
39
|
+
state.startX = e.touches[0].clientX;
|
|
40
|
+
state.startY = e.touches[0].clientY;
|
|
41
|
+
};
|
|
42
|
+
const move = (e) => {
|
|
43
|
+
state.deltaX = e.touches[0].clientX - state.startX;
|
|
44
|
+
state.deltaY = e.touches[0].clientY - state.startY;
|
|
45
|
+
state.offsetX = Math.abs(state.deltaX);
|
|
46
|
+
state.offsetY = Math.abs(state.deltaY);
|
|
47
|
+
if (!state.direction) {
|
|
48
|
+
state.direction = getDirection(state.offsetX, state.offsetY);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
state,
|
|
53
|
+
start,
|
|
54
|
+
reset,
|
|
55
|
+
move
|
|
56
|
+
};
|
|
57
|
+
}
|
|
8
58
|
const { create, componentName } = createComponent("swiper");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
59
|
+
const _sfc_main = create({
|
|
60
|
+
props: {
|
|
61
|
+
width: {
|
|
62
|
+
type: [Number, String],
|
|
63
|
+
default: window.innerWidth
|
|
64
|
+
},
|
|
65
|
+
height: {
|
|
66
|
+
type: [Number, String],
|
|
67
|
+
default: 0
|
|
68
|
+
},
|
|
69
|
+
direction: {
|
|
70
|
+
type: [String],
|
|
71
|
+
default: "horizontal"
|
|
72
|
+
},
|
|
73
|
+
paginationVisible: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: false
|
|
76
|
+
},
|
|
77
|
+
paginationColor: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: "#fff"
|
|
80
|
+
},
|
|
81
|
+
loop: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: true
|
|
84
|
+
},
|
|
85
|
+
duration: {
|
|
86
|
+
type: [Number, String],
|
|
87
|
+
default: 500
|
|
88
|
+
},
|
|
89
|
+
autoPlay: {
|
|
90
|
+
type: [Number, String],
|
|
91
|
+
default: 0
|
|
92
|
+
},
|
|
93
|
+
initPage: {
|
|
94
|
+
type: [Number, String],
|
|
95
|
+
default: 0
|
|
96
|
+
},
|
|
97
|
+
touchable: {
|
|
98
|
+
type: Boolean,
|
|
99
|
+
default: true
|
|
100
|
+
},
|
|
101
|
+
isPreventDefault: {
|
|
102
|
+
type: Boolean,
|
|
103
|
+
default: true
|
|
104
|
+
},
|
|
105
|
+
isStopPropagation: {
|
|
106
|
+
type: Boolean,
|
|
107
|
+
default: true
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
emits: ["change"],
|
|
111
|
+
setup(props, { emit, slots }) {
|
|
112
|
+
const container = ref();
|
|
113
|
+
const state = reactive({
|
|
114
|
+
active: 0,
|
|
115
|
+
num: 0,
|
|
116
|
+
rect: null,
|
|
117
|
+
width: 0,
|
|
118
|
+
height: 0,
|
|
119
|
+
moving: false,
|
|
120
|
+
offset: 0,
|
|
121
|
+
touchTime: 0,
|
|
122
|
+
autoplayTimer: 0,
|
|
123
|
+
children: [],
|
|
124
|
+
style: {}
|
|
125
|
+
});
|
|
126
|
+
const touch = useTouch();
|
|
127
|
+
const classes = computed(() => {
|
|
128
|
+
const prefixCls = componentName;
|
|
129
|
+
return {
|
|
130
|
+
[prefixCls]: true
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
const isVertical = computed(() => props.direction === "vertical");
|
|
134
|
+
const delTa = computed(() => {
|
|
135
|
+
return isVertical.value ? touch.state.deltaY : touch.state.deltaX;
|
|
136
|
+
});
|
|
137
|
+
const isCorrectDirection = computed(() => {
|
|
138
|
+
return touch.state.direction === props.direction;
|
|
139
|
+
});
|
|
140
|
+
const childCount = computed(() => state.children.length);
|
|
141
|
+
const size = computed(() => state[isVertical.value ? "height" : "width"]);
|
|
142
|
+
const trackSize = computed(() => childCount.value * size.value);
|
|
143
|
+
const minOffset = computed(() => {
|
|
144
|
+
if (state.rect) {
|
|
145
|
+
const base = isVertical.value ? state.rect.height : state.rect.width;
|
|
146
|
+
return base - size.value * childCount.value;
|
|
147
|
+
}
|
|
148
|
+
return 0;
|
|
149
|
+
});
|
|
150
|
+
const activePagination = computed(() => (state.active + childCount.value) % childCount.value);
|
|
151
|
+
const getStyle = () => {
|
|
152
|
+
state.style = {
|
|
153
|
+
transitionDuration: `${state.moving ? 0 : props.duration}ms`,
|
|
154
|
+
transform: `translate${isVertical.value ? "Y" : "X"}(${state.offset}px)`,
|
|
155
|
+
[isVertical.value ? "height" : "width"]: `${size.value * childCount.value}px`,
|
|
156
|
+
[isVertical.value ? "width" : "height"]: `${isVertical.value ? state.width : state.height}px`
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
const relation = (child) => {
|
|
160
|
+
if (child.proxy) {
|
|
161
|
+
state.children.push(child.proxy);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
const range = (num, min, max) => {
|
|
165
|
+
return Math.min(Math.max(num, min), max);
|
|
166
|
+
};
|
|
167
|
+
const requestFrame = (fn) => {
|
|
168
|
+
window.requestAnimationFrame.call(window, fn);
|
|
169
|
+
};
|
|
170
|
+
const getOffset = (active, offset = 0) => {
|
|
171
|
+
let currentPosition = active * size.value;
|
|
172
|
+
if (!props.loop) {
|
|
173
|
+
currentPosition = Math.min(currentPosition, -minOffset.value);
|
|
174
|
+
}
|
|
175
|
+
let targetOffset = offset - currentPosition;
|
|
176
|
+
if (!props.loop) {
|
|
177
|
+
targetOffset = range(targetOffset, minOffset.value, 0);
|
|
178
|
+
}
|
|
179
|
+
return targetOffset;
|
|
180
|
+
};
|
|
181
|
+
const getActive = (pace) => {
|
|
182
|
+
const { active } = state;
|
|
183
|
+
if (pace) {
|
|
184
|
+
if (props.loop) {
|
|
185
|
+
return range(active + pace, -1, childCount.value);
|
|
186
|
+
}
|
|
187
|
+
return range(active + pace, 0, childCount.value - 1);
|
|
188
|
+
}
|
|
189
|
+
return active;
|
|
190
|
+
};
|
|
191
|
+
const move = ({ pace = 0, offset = 0, isEmit = false }) => {
|
|
192
|
+
if (childCount.value <= 1)
|
|
193
|
+
return;
|
|
194
|
+
const { active } = state;
|
|
195
|
+
const targetActive = getActive(pace);
|
|
196
|
+
const targetOffset = getOffset(targetActive, offset);
|
|
197
|
+
if (props.loop) {
|
|
198
|
+
if (state.children[0] && targetOffset !== minOffset.value) {
|
|
199
|
+
const rightBound = targetOffset < minOffset.value;
|
|
200
|
+
state.children[0].setOffset(rightBound ? trackSize.value : 0);
|
|
201
|
+
}
|
|
202
|
+
if (state.children[childCount.value - 1] && targetOffset !== 0) {
|
|
203
|
+
const leftBound = targetOffset > 0;
|
|
204
|
+
state.children[childCount.value - 1].setOffset(leftBound ? -trackSize.value : 0);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
state.active = targetActive;
|
|
208
|
+
state.offset = targetOffset;
|
|
209
|
+
if (isEmit && active !== state.active) {
|
|
210
|
+
emit("change", activePagination.value);
|
|
211
|
+
}
|
|
212
|
+
getStyle();
|
|
213
|
+
};
|
|
214
|
+
const resettPosition = () => {
|
|
215
|
+
state.moving = true;
|
|
216
|
+
if (state.active <= -1) {
|
|
217
|
+
move({ pace: childCount.value });
|
|
218
|
+
}
|
|
219
|
+
if (state.active >= childCount.value) {
|
|
220
|
+
move({ pace: -childCount.value });
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const stopAutoPlay = () => {
|
|
224
|
+
clearTimeout(state.autoplayTimer);
|
|
225
|
+
};
|
|
226
|
+
const prev = () => {
|
|
227
|
+
resettPosition();
|
|
228
|
+
touch.reset();
|
|
229
|
+
requestFrame(() => {
|
|
230
|
+
requestFrame(() => {
|
|
231
|
+
state.moving = false;
|
|
232
|
+
move({
|
|
233
|
+
pace: -1,
|
|
234
|
+
isEmit: true
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
const next = () => {
|
|
240
|
+
resettPosition();
|
|
241
|
+
touch.reset();
|
|
242
|
+
requestFrame(() => {
|
|
243
|
+
requestFrame(() => {
|
|
244
|
+
state.moving = false;
|
|
245
|
+
move({
|
|
246
|
+
pace: 1,
|
|
247
|
+
isEmit: true
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
};
|
|
252
|
+
const to = (index) => {
|
|
253
|
+
resettPosition();
|
|
254
|
+
touch.reset();
|
|
255
|
+
requestFrame(() => {
|
|
256
|
+
requestFrame(() => {
|
|
257
|
+
state.moving = false;
|
|
258
|
+
let targetIndex;
|
|
259
|
+
if (props.loop && childCount.value === index) {
|
|
260
|
+
targetIndex = state.active === 0 ? 0 : index;
|
|
261
|
+
} else {
|
|
262
|
+
targetIndex = index % childCount.value;
|
|
263
|
+
}
|
|
264
|
+
move({
|
|
265
|
+
pace: targetIndex - state.active,
|
|
266
|
+
isEmit: true
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
const autoplay = () => {
|
|
272
|
+
if (props.autoPlay <= 0 || childCount.value <= 1)
|
|
273
|
+
return;
|
|
274
|
+
stopAutoPlay();
|
|
275
|
+
state.autoplayTimer = setTimeout(() => {
|
|
276
|
+
next();
|
|
277
|
+
autoplay();
|
|
278
|
+
}, Number(props.autoPlay));
|
|
279
|
+
};
|
|
280
|
+
const init = (active = +props.initPage) => {
|
|
281
|
+
stopAutoPlay();
|
|
282
|
+
state.rect = container.value.getBoundingClientRect();
|
|
283
|
+
active = Math.min(childCount.value - 1, active);
|
|
284
|
+
state.width = props.width ? +props.width : state.rect.width;
|
|
285
|
+
state.height = props.height ? +props.height : state.rect.height;
|
|
286
|
+
state.active = active;
|
|
287
|
+
state.offset = getOffset(state.active);
|
|
288
|
+
state.moving = true;
|
|
289
|
+
getStyle();
|
|
290
|
+
autoplay();
|
|
291
|
+
};
|
|
292
|
+
const onTouchStart = (e) => {
|
|
293
|
+
if (props.isPreventDefault)
|
|
294
|
+
e.preventDefault();
|
|
295
|
+
if (props.isStopPropagation)
|
|
296
|
+
e.stopPropagation();
|
|
297
|
+
if (!props.touchable)
|
|
298
|
+
return;
|
|
299
|
+
touch.start(e);
|
|
300
|
+
state.touchTime = Date.now();
|
|
301
|
+
stopAutoPlay();
|
|
302
|
+
resettPosition();
|
|
303
|
+
};
|
|
304
|
+
const onTouchMove = (e) => {
|
|
305
|
+
if (props.touchable && state.moving) {
|
|
306
|
+
touch.move(e);
|
|
307
|
+
if (isCorrectDirection.value) {
|
|
308
|
+
move({
|
|
309
|
+
offset: delTa.value
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
const onTouchEnd = (e) => {
|
|
315
|
+
if (!props.touchable || !state.moving)
|
|
316
|
+
return;
|
|
317
|
+
const speed = delTa.value / (Date.now() - state.touchTime);
|
|
318
|
+
const isShouldMove = Math.abs(speed) > 0.3 || Math.abs(delTa.value) > +(size.value / 2).toFixed(2);
|
|
319
|
+
if (isShouldMove && isCorrectDirection.value) {
|
|
320
|
+
let pace = 0;
|
|
321
|
+
const offset = isVertical.value ? touch.state.offsetY : touch.state.offsetX;
|
|
322
|
+
if (props.loop) {
|
|
323
|
+
pace = offset > 0 ? delTa.value > 0 ? -1 : 1 : 0;
|
|
324
|
+
} else {
|
|
325
|
+
pace = -Math[delTa.value > 0 ? "ceil" : "floor"](delTa.value / size.value);
|
|
326
|
+
}
|
|
327
|
+
move({
|
|
328
|
+
pace,
|
|
329
|
+
isEmit: true
|
|
330
|
+
});
|
|
331
|
+
} else if (delTa.value) {
|
|
332
|
+
move({ pace: 0 });
|
|
333
|
+
}
|
|
334
|
+
state.moving = false;
|
|
335
|
+
getStyle();
|
|
336
|
+
autoplay();
|
|
337
|
+
};
|
|
338
|
+
provide("parent", {
|
|
339
|
+
props,
|
|
340
|
+
size,
|
|
341
|
+
relation
|
|
342
|
+
});
|
|
343
|
+
useExpose({
|
|
344
|
+
prev,
|
|
345
|
+
next,
|
|
346
|
+
to
|
|
347
|
+
});
|
|
348
|
+
onMounted(() => {
|
|
349
|
+
nextTick(() => {
|
|
350
|
+
init();
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
onActivated(() => {
|
|
354
|
+
nextTick(() => {
|
|
355
|
+
init();
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
onDeactivated(() => {
|
|
359
|
+
stopAutoPlay();
|
|
360
|
+
});
|
|
361
|
+
onBeforeUnmount(() => {
|
|
362
|
+
stopAutoPlay();
|
|
363
|
+
});
|
|
364
|
+
watch(() => props.initPage, (val) => {
|
|
365
|
+
nextTick(() => {
|
|
366
|
+
init(Number(val));
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
watch(() => state.children.length, () => {
|
|
370
|
+
nextTick(() => {
|
|
371
|
+
init(state.active);
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
watch(() => props.autoPlay, (val) => {
|
|
375
|
+
val > 0 ? autoplay() : stopAutoPlay();
|
|
376
|
+
});
|
|
377
|
+
return {
|
|
378
|
+
state,
|
|
379
|
+
classes,
|
|
380
|
+
container,
|
|
381
|
+
componentName,
|
|
382
|
+
isVertical,
|
|
383
|
+
slots,
|
|
384
|
+
activePagination,
|
|
385
|
+
onTouchStart,
|
|
386
|
+
onTouchMove,
|
|
387
|
+
onTouchEnd
|
|
388
|
+
};
|
|
16
389
|
}
|
|
17
390
|
});
|
|
18
391
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
392
|
+
return openBlock(), createElementBlock("view", {
|
|
393
|
+
ref: "container",
|
|
394
|
+
class: normalizeClass(_ctx.classes),
|
|
395
|
+
onTouchstart: _cache[0] || (_cache[0] = (...args) => _ctx.onTouchStart && _ctx.onTouchStart(...args)),
|
|
396
|
+
onTouchmove: _cache[1] || (_cache[1] = (...args) => _ctx.onTouchMove && _ctx.onTouchMove(...args)),
|
|
397
|
+
onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args)),
|
|
398
|
+
onTouchcancel: _cache[3] || (_cache[3] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args))
|
|
399
|
+
}, [
|
|
400
|
+
createElementVNode("view", {
|
|
401
|
+
class: normalizeClass({
|
|
402
|
+
[`${_ctx.componentName}-inner`]: true,
|
|
403
|
+
[`${_ctx.componentName}-vertical`]: _ctx.isVertical
|
|
404
|
+
}),
|
|
405
|
+
style: normalizeStyle(_ctx.state.style)
|
|
406
|
+
}, [
|
|
22
407
|
renderSlot(_ctx.$slots, "default")
|
|
23
|
-
]),
|
|
24
|
-
|
|
25
|
-
|
|
408
|
+
], 6),
|
|
409
|
+
renderSlot(_ctx.$slots, "page"),
|
|
410
|
+
_ctx.paginationVisible && !_ctx.slots.page ? (openBlock(), createElementBlock("view", {
|
|
411
|
+
key: 0,
|
|
412
|
+
class: normalizeClass({
|
|
413
|
+
[`${_ctx.componentName}-pagination`]: true,
|
|
414
|
+
[`${_ctx.componentName}-pagination-vertical`]: _ctx.isVertical
|
|
415
|
+
})
|
|
416
|
+
}, [
|
|
417
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.state.children.length, (item, index) => {
|
|
418
|
+
return openBlock(), createElementBlock("i", {
|
|
419
|
+
style: normalizeStyle({
|
|
420
|
+
backgroundColor: _ctx.activePagination === index ? _ctx.paginationColor : "#ddd"
|
|
421
|
+
}),
|
|
422
|
+
key: index
|
|
423
|
+
}, null, 4);
|
|
424
|
+
}), 128))
|
|
425
|
+
], 2)) : createCommentVNode("", true)
|
|
426
|
+
], 34);
|
|
26
427
|
}
|
|
27
|
-
_sfc_main
|
|
28
|
-
export {
|
|
428
|
+
var Swiper = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
429
|
+
export { Swiper as default };
|
|
@@ -1,35 +1,60 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.14 Wed Dec 22 2021 20:49:10 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2021 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { getCurrentInstance, inject, reactive, computed, openBlock, createElementBlock, normalizeClass, normalizeStyle, renderSlot } from "vue";
|
|
7
7
|
import { c as createComponent } from "./component.js";
|
|
8
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
9
|
+
function useExpose(apis) {
|
|
10
|
+
const instance = getCurrentInstance();
|
|
11
|
+
if (instance) {
|
|
12
|
+
Object.assign(instance.proxy, apis);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
8
15
|
const { create, componentName } = createComponent("swiper-item");
|
|
9
|
-
|
|
16
|
+
const _sfc_main = create({
|
|
10
17
|
props: {},
|
|
11
18
|
setup(props, { slots }) {
|
|
19
|
+
const parent = inject("parent");
|
|
20
|
+
parent["relation"](getCurrentInstance());
|
|
21
|
+
const state = reactive({
|
|
22
|
+
offset: 0
|
|
23
|
+
});
|
|
12
24
|
const classes = computed(() => {
|
|
13
25
|
const prefixCls = componentName;
|
|
14
26
|
return {
|
|
15
27
|
[prefixCls]: true
|
|
16
28
|
};
|
|
17
29
|
});
|
|
30
|
+
const style = computed(() => {
|
|
31
|
+
const style2 = {};
|
|
32
|
+
const direction = parent == null ? void 0 : parent.props.direction;
|
|
33
|
+
if (parent == null ? void 0 : parent.size.value) {
|
|
34
|
+
style2[direction === "horizontal" ? "width" : "height"] = `${parent == null ? void 0 : parent.size.value}px`;
|
|
35
|
+
}
|
|
36
|
+
if (state.offset) {
|
|
37
|
+
style2["transform"] = `translate${direction === "horizontal" ? "X" : "Y"}(${state.offset}px)`;
|
|
38
|
+
}
|
|
39
|
+
return style2;
|
|
40
|
+
});
|
|
41
|
+
const setOffset = (offset) => {
|
|
42
|
+
state.offset = offset;
|
|
43
|
+
};
|
|
44
|
+
useExpose({ setOffset });
|
|
18
45
|
return {
|
|
46
|
+
style,
|
|
19
47
|
classes
|
|
20
48
|
};
|
|
21
49
|
}
|
|
22
50
|
});
|
|
23
51
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
default
|
|
29
|
-
|
|
30
|
-
]),
|
|
31
|
-
_: 3
|
|
32
|
-
}, 8, ["class"]);
|
|
52
|
+
return openBlock(), createElementBlock("view", {
|
|
53
|
+
class: normalizeClass(_ctx.classes),
|
|
54
|
+
style: normalizeStyle(_ctx.style)
|
|
55
|
+
}, [
|
|
56
|
+
renderSlot(_ctx.$slots, "default")
|
|
57
|
+
], 6);
|
|
33
58
|
}
|
|
34
|
-
_sfc_main
|
|
35
|
-
export {
|
|
59
|
+
var SwiperItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
60
|
+
export { SwiperItem as default };
|