@nutui/nutui 3.1.22-beta.3 → 3.1.23-beta.0
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 +48 -0
- package/README.md +3 -4
- package/dist/nutui.es.js +20426 -4050
- package/dist/nutui.umd.js +20529 -4049
- package/dist/packages/_es/ActionSheet.js +149 -36
- package/dist/packages/_es/Address.js +535 -129
- package/dist/packages/_es/AddressList.js +615 -113
- package/dist/packages/_es/Animate.js +64 -0
- package/dist/packages/_es/Audio.js +257 -72
- package/dist/packages/_es/AudioOperate.js +100 -32
- package/dist/packages/_es/Avatar.js +162 -54
- package/dist/packages/_es/AvatarGroup.js +73 -14
- package/dist/packages/_es/BackTop.js +156 -43
- package/dist/packages/_es/Badge.js +86 -14
- package/dist/packages/_es/Barrage.js +120 -41
- package/dist/packages/_es/Button.js +128 -23
- package/dist/packages/_es/Calendar.js +246 -24
- package/dist/packages/_es/CalendarItem.js +2 -1
- package/dist/packages/_es/Card.js +107 -10
- package/dist/packages/_es/Cascader.js +496 -179
- package/dist/packages/_es/Category.js +58 -15
- package/dist/packages/_es/CategoryPane.js +111 -11
- package/dist/packages/_es/Cell.js +108 -21
- package/dist/packages/_es/CellGroup.js +44 -9
- package/dist/packages/_es/Checkbox.js +134 -29
- package/dist/packages/_es/CheckboxGroup.js +79 -29
- package/dist/packages/_es/CircleProgress.js +150 -28
- package/dist/packages/_es/Col.js +56 -14
- package/dist/packages/_es/Collapse.js +110 -24
- package/dist/packages/_es/CollapseItem.js +252 -80
- package/dist/packages/_es/Comment.js +434 -64
- package/dist/packages/_es/ConfigProvider.js +25 -0
- package/dist/packages/_es/CountDown.js +238 -75
- package/dist/packages/_es/CountUp.js +539 -159
- package/dist/packages/_es/DatePicker.js +315 -117
- package/dist/packages/_es/Dialog.js +289 -79
- package/dist/packages/_es/Divider.js +65 -32
- package/dist/packages/_es/Drag.js +197 -56
- package/dist/packages/_es/Ecard.js +159 -24
- package/dist/packages/_es/Elevator.js +255 -77
- package/dist/packages/_es/Ellipsis.js +206 -0
- package/dist/packages/_es/Empty.js +71 -12
- package/dist/packages/_es/FixedNav.js +122 -15
- package/dist/packages/_es/Form.js +151 -64
- package/dist/packages/_es/FormItem.js +114 -15
- package/dist/packages/_es/Grid.js +6 -5
- package/dist/packages/_es/GridItem.js +144 -33
- package/dist/packages/_es/Icon.js +40 -15
- package/dist/packages/_es/Image.js +142 -0
- package/dist/packages/_es/ImagePreview.js +547 -84
- package/dist/packages/_es/Indicator.js +62 -15
- package/dist/packages/_es/InfiniteLoading.js +249 -76
- package/dist/packages/_es/Input.js +433 -51
- package/dist/packages/_es/InputNumber.js +160 -41
- package/dist/packages/_es/Layout.js +5 -4
- package/dist/packages/_es/List.js +106 -37
- package/dist/packages/_es/Menu.js +168 -29
- package/dist/packages/_es/MenuItem.js +173 -34
- package/dist/packages/_es/Navbar.js +192 -30
- package/dist/packages/_es/NoticeBar.js +380 -93
- package/dist/packages/_es/Notify.js +227 -91
- package/dist/packages/_es/NumberKeyboard.js +272 -41
- package/dist/packages/_es/OldPicker.js +457 -149
- package/dist/packages/_es/OverLay.js +98 -40
- package/dist/packages/_es/Pagination.js +157 -39
- package/dist/packages/_es/Picker.js +460 -148
- package/dist/packages/_es/Popover.js +957 -337
- package/dist/packages/_es/Popup.js +299 -74
- package/dist/packages/_es/Price.js +118 -16
- package/dist/packages/_es/Progress.js +146 -14
- package/dist/packages/_es/PullRefresh.js +339 -100
- package/dist/packages/_es/Radio.js +90 -22
- package/dist/packages/_es/RadioGroup.js +37 -8
- package/dist/packages/_es/Range.js +408 -102
- package/dist/packages/_es/Rate.js +193 -16
- package/dist/packages/_es/Row.js +64 -22
- package/dist/packages/_es/SearchBar.js +238 -56
- package/dist/packages/_es/ShortPassword.js +225 -35
- package/dist/packages/_es/SideNavBar.js +81 -43
- package/dist/packages/_es/SideNavBarItem.js +46 -11
- package/dist/packages/_es/Signature.js +160 -60
- package/dist/packages/_es/Skeleton.js +136 -20
- package/dist/packages/_es/Sku.js +491 -103
- package/dist/packages/_es/Step.js +115 -39
- package/dist/packages/_es/Steps.js +53 -18
- package/dist/packages/_es/Sticky.js +138 -53
- package/dist/packages/_es/SubSideNavBar.js +82 -36
- package/dist/packages/_es/Swipe.js +178 -60
- package/dist/packages/_es/Swiper.js +433 -121
- package/dist/packages/_es/SwiperItem.js +53 -22
- package/dist/packages/_es/Switch.js +116 -21
- package/dist/packages/_es/TabPane.js +39 -12
- package/dist/packages/_es/Tabbar.js +72 -17
- package/dist/packages/_es/TabbarItem.js +151 -29
- package/dist/packages/_es/Table.js +178 -37
- package/dist/packages/_es/Tabs.js +202 -59
- package/dist/packages/_es/Tag.js +97 -20
- package/dist/packages/_es/TextArea.js +160 -42
- package/dist/packages/_es/TimeDetail.js +79 -37
- package/dist/packages/_es/TimePannel.js +48 -33
- package/dist/packages/_es/TimeSelect.js +112 -15
- package/dist/packages/_es/Toast.js +310 -90
- package/dist/packages/_es/Uploader.js +455 -120
- package/dist/packages/_es/Video.js +332 -93
- package/dist/packages/_es/common.js +128 -38
- package/dist/packages/_es/component.js +76 -35
- package/dist/packages/_es/index.js +6 -5
- package/dist/packages/_es/index2.js +30 -9
- package/dist/packages/_es/index3.js +8 -6
- package/dist/packages/_es/index4.js +64 -13
- package/dist/packages/_es/index5.js +783 -130
- package/dist/packages/_es/plugin-vue_export-helper.js +8 -7
- package/dist/packages/_es/pxCheck.js +5 -3
- package/dist/packages/_es/raf.js +15 -8
- package/dist/packages/animate/index.scss +299 -0
- package/dist/packages/cell/index.scss +7 -1
- package/dist/packages/checkbox/index.scss +10 -0
- package/dist/packages/configprovider/index.scss +2 -0
- package/dist/packages/ellipsis/index.scss +12 -0
- package/dist/packages/formitem/index.scss +12 -0
- package/dist/packages/griditem/index.scss +11 -0
- package/dist/packages/image/index.scss +39 -0
- package/dist/packages/imagepreview/index.scss +26 -2
- package/dist/packages/input/index.scss +13 -0
- package/dist/packages/inputnumber/index.scss +21 -0
- package/dist/packages/locale/lang/baseLang.js +3 -3
- package/dist/packages/locale/lang/en-US.js +105 -5
- package/dist/packages/locale/lang/id-ID.js +105 -5
- package/dist/packages/locale/lang/index.js +38 -16
- package/dist/packages/locale/lang/zh-CN.js +105 -5
- package/dist/packages/locale/lang/zh-TW.js +105 -5
- package/dist/packages/menu/index.scss +45 -36
- package/dist/packages/menuitem/index.scss +4 -0
- package/dist/packages/navbar/index.scss +9 -0
- package/dist/packages/pagination/index.scss +19 -0
- package/dist/packages/radio/index.scss +18 -0
- package/dist/packages/range/index.scss +19 -0
- package/dist/packages/rate/index.scss +1 -1
- package/dist/packages/searchbar/index.scss +21 -0
- package/dist/packages/switch/index.scss +1 -0
- package/dist/packages/tabbar/index.scss +5 -0
- package/dist/packages/tabbaritem/index.scss +7 -0
- package/dist/packages/tabpane/index.scss +5 -0
- package/dist/packages/tabs/index.scss +22 -0
- package/dist/packages/textarea/index.scss +8 -0
- package/dist/smartips/attributes.json +140 -4
- package/dist/smartips/tags.json +55 -6
- package/dist/smartips/web-types.json +6963 -0
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/styles/font/config.json +3 -1
- package/dist/styles/font/demo_index.html +49 -3
- package/dist/styles/font/iconfont.css +11 -3
- package/dist/styles/font/iconfont.js +15 -15
- package/dist/styles/font/iconfont.json +14 -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 +54 -50
- package/dist/styles/themes/jdb.scss +54 -50
- package/dist/styles/themes/jdt.scss +54 -50
- package/dist/styles/variables-jdb.scss +12 -0
- package/dist/styles/variables-jdt.scss +12 -0
- package/dist/styles/variables.scss +12 -0
- package/dist/types/__VUE/actionsheet/index.vue.d.ts +3 -3
- package/dist/types/__VUE/address/index.vue.d.ts +7 -7
- package/dist/types/__VUE/animate/index.vue.d.ts +48 -0
- package/dist/types/__VUE/animate/type.d.ts +6 -0
- package/dist/types/__VUE/avatar/index.vue.d.ts +3 -3
- package/dist/types/__VUE/calendar/index.vue.d.ts +1 -1
- package/dist/types/__VUE/calendaritem/index.vue.d.ts +10 -2
- package/dist/types/__VUE/cascader/index.vue.d.ts +2 -2
- package/dist/types/__VUE/circleprogress/index.vue.d.ts +2 -2
- package/dist/types/__VUE/collapse/index.vue.d.ts +3 -1
- package/dist/types/__VUE/configprovider/common.d.ts +20 -0
- package/dist/types/__VUE/configprovider/index.vue.d.ts +33 -0
- package/dist/types/__VUE/datepicker/index.vue.d.ts +2 -2
- package/dist/types/__VUE/dialog/index.vue.d.ts +2 -2
- package/dist/types/__VUE/ellipsis/index.vue.d.ts +72 -0
- package/dist/types/__VUE/fixednav/index.vue.d.ts +2 -2
- package/dist/types/__VUE/grid/index.vue.d.ts +2 -2
- package/dist/types/__VUE/image/index.vue.d.ts +105 -0
- package/dist/types/__VUE/image/type.d.ts +6 -0
- package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +95 -0
- package/dist/types/__VUE/imagepreview/index.vue.d.ts +56 -24
- package/dist/types/__VUE/menu/index.vue.d.ts +31 -4
- package/dist/types/__VUE/menuitem/index.vue.d.ts +12 -3
- package/dist/types/__VUE/noticebar/index.vue.d.ts +1 -1
- package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +2 -2
- package/dist/types/__VUE/oldpicker/index.vue.d.ts +4 -4
- package/dist/types/__VUE/picker/index.vue.d.ts +4 -4
- package/dist/types/__VUE/popover/index.vue.d.ts +8 -8
- package/dist/types/__VUE/popup/index.vue.d.ts +4 -4
- package/dist/types/__VUE/range/index.vue.d.ts +1 -1
- package/dist/types/__VUE/rate/common.d.ts +149 -0
- package/dist/types/__VUE/rate/index.vue.d.ts +17 -7
- package/dist/types/__VUE/row/index.vue.d.ts +2 -2
- package/dist/types/__VUE/shortpassword/index.vue.d.ts +2 -2
- package/dist/types/__VUE/sku/index.vue.d.ts +3 -3
- package/dist/types/__VUE/swipe/index.vue.d.ts +2 -2
- package/dist/types/__VUE/swiper/index.vue.d.ts +2 -2
- package/dist/types/__VUE/switch/index.vue.d.ts +2 -2
- package/dist/types/__VUE/timeselect/index.vue.d.ts +3 -2
- package/dist/types/__VUE/uploader/uploader.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/nutui.d.ts +5 -1
- package/package.json +5 -4
|
@@ -1,137 +1,449 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.0 Mon Jun 27 2022 17:55:50 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { reactive
|
|
7
|
-
import { c as
|
|
8
|
-
import { u as
|
|
9
|
-
import { _ as
|
|
6
|
+
import { reactive, ref, computed, provide, onDeactivated, onBeforeUnmount, watch, nextTick, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, renderSlot, Fragment, renderList, createCommentVNode } from "vue";
|
|
7
|
+
import { c as createComponent } from "./component.js";
|
|
8
|
+
import { u as useExpose } from "./index3.js";
|
|
9
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
10
10
|
import "../locale/lang";
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
const DISTANCE = 5;
|
|
12
|
+
function useTouch() {
|
|
13
|
+
const state = reactive({
|
|
14
|
+
startX: 0,
|
|
15
|
+
startY: 0,
|
|
16
|
+
deltaX: 0,
|
|
17
|
+
deltaY: 0,
|
|
18
|
+
offsetX: 0,
|
|
19
|
+
offsetY: 0,
|
|
20
|
+
direction: ""
|
|
21
|
+
});
|
|
22
|
+
const getDirection = (x, y) => {
|
|
23
|
+
if (x > y && x > DISTANCE)
|
|
24
|
+
return "horizontal";
|
|
25
|
+
if (y > x && y > DISTANCE)
|
|
26
|
+
return "vertical";
|
|
27
|
+
return "";
|
|
28
|
+
};
|
|
29
|
+
const reset = () => {
|
|
30
|
+
state.startX = 0;
|
|
31
|
+
state.startY = 0;
|
|
32
|
+
state.deltaX = 0;
|
|
33
|
+
state.deltaY = 0;
|
|
34
|
+
state.offsetX = 0;
|
|
35
|
+
state.offsetY = 0;
|
|
36
|
+
state.direction = "";
|
|
37
|
+
};
|
|
38
|
+
const start = (e) => {
|
|
39
|
+
reset();
|
|
40
|
+
state.startX = e.touches[0].clientX;
|
|
41
|
+
state.startY = e.touches[0].clientY;
|
|
42
|
+
};
|
|
43
|
+
const move = (e) => {
|
|
44
|
+
state.deltaX = e.touches[0].clientX - state.startX;
|
|
45
|
+
state.deltaY = e.touches[0].clientY - state.startY;
|
|
46
|
+
state.offsetX = Math.abs(state.deltaX);
|
|
47
|
+
state.offsetY = Math.abs(state.deltaY);
|
|
48
|
+
if (!state.direction) {
|
|
49
|
+
state.direction = getDirection(state.offsetX, state.offsetY);
|
|
26
50
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
};
|
|
52
|
+
return {
|
|
53
|
+
state,
|
|
54
|
+
start,
|
|
55
|
+
reset,
|
|
56
|
+
move
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const { create, componentName } = createComponent("swiper");
|
|
60
|
+
const _sfc_main = create({
|
|
61
|
+
props: {
|
|
62
|
+
width: {
|
|
63
|
+
type: [Number, String],
|
|
64
|
+
default: window.innerWidth
|
|
65
|
+
},
|
|
66
|
+
height: {
|
|
67
|
+
type: [Number, String],
|
|
68
|
+
default: 0
|
|
69
|
+
},
|
|
70
|
+
direction: {
|
|
71
|
+
type: [String],
|
|
72
|
+
default: "horizontal"
|
|
73
|
+
},
|
|
74
|
+
paginationVisible: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: false
|
|
77
|
+
},
|
|
78
|
+
paginationColor: {
|
|
79
|
+
type: String,
|
|
80
|
+
default: "#fff"
|
|
81
|
+
},
|
|
82
|
+
loop: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: true
|
|
85
|
+
},
|
|
86
|
+
duration: {
|
|
87
|
+
type: [Number, String],
|
|
88
|
+
default: 500
|
|
89
|
+
},
|
|
90
|
+
autoPlay: {
|
|
91
|
+
type: [Number, String],
|
|
92
|
+
default: 0
|
|
93
|
+
},
|
|
94
|
+
initPage: {
|
|
95
|
+
type: [Number, String],
|
|
96
|
+
default: 0
|
|
97
|
+
},
|
|
98
|
+
touchable: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
default: true
|
|
101
|
+
},
|
|
102
|
+
isPreventDefault: {
|
|
103
|
+
type: Boolean,
|
|
104
|
+
default: true
|
|
105
|
+
},
|
|
106
|
+
isStopPropagation: {
|
|
107
|
+
type: Boolean,
|
|
108
|
+
default: true
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
emits: ["change"],
|
|
112
|
+
setup(props, { emit, slots }) {
|
|
113
|
+
const container = ref();
|
|
114
|
+
const state = reactive({
|
|
115
|
+
active: 0,
|
|
116
|
+
num: 0,
|
|
117
|
+
rect: null,
|
|
118
|
+
width: 0,
|
|
119
|
+
height: 0,
|
|
120
|
+
moving: false,
|
|
121
|
+
offset: 0,
|
|
122
|
+
touchTime: 0,
|
|
123
|
+
autoplayTimer: 0,
|
|
124
|
+
children: [],
|
|
125
|
+
childrenVNode: [],
|
|
126
|
+
style: {}
|
|
127
|
+
});
|
|
128
|
+
const touch = useTouch();
|
|
129
|
+
const classes = computed(() => {
|
|
130
|
+
const prefixCls = componentName;
|
|
131
|
+
return {
|
|
132
|
+
[prefixCls]: true
|
|
133
|
+
};
|
|
134
|
+
});
|
|
135
|
+
const isVertical = computed(() => props.direction === "vertical");
|
|
136
|
+
const delTa = computed(() => {
|
|
137
|
+
return isVertical.value ? touch.state.deltaY : touch.state.deltaX;
|
|
138
|
+
});
|
|
139
|
+
const isCorrectDirection = computed(() => {
|
|
140
|
+
return touch.state.direction === props.direction;
|
|
141
|
+
});
|
|
142
|
+
const childCount = computed(() => state.children.length);
|
|
143
|
+
const size = computed(() => state[isVertical.value ? "height" : "width"]);
|
|
144
|
+
const trackSize = computed(() => childCount.value * size.value);
|
|
145
|
+
const minOffset = computed(() => {
|
|
146
|
+
if (state.rect) {
|
|
147
|
+
const base = isVertical.value ? state.rect.height : state.rect.width;
|
|
148
|
+
return base - size.value * childCount.value;
|
|
48
149
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
150
|
+
return 0;
|
|
151
|
+
});
|
|
152
|
+
const activePagination = computed(() => (state.active + childCount.value) % childCount.value);
|
|
153
|
+
const getStyle = () => {
|
|
154
|
+
state.style = {
|
|
155
|
+
transitionDuration: `${state.moving ? 0 : props.duration}ms`,
|
|
156
|
+
transform: `translate${isVertical.value ? "Y" : "X"}(${state.offset}px)`,
|
|
157
|
+
[isVertical.value ? "height" : "width"]: `${size.value * childCount.value}px`,
|
|
158
|
+
[isVertical.value ? "width" : "height"]: `${isVertical.value ? state.width : state.height}px`
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
const relation = (child) => {
|
|
162
|
+
var _a;
|
|
163
|
+
let children = [];
|
|
164
|
+
let slot = (_a = slots == null ? void 0 : slots.default) == null ? void 0 : _a.call(slots);
|
|
165
|
+
slot = slot.filter((item) => item.children && Array.isArray(item.children));
|
|
166
|
+
slot.forEach((item) => {
|
|
167
|
+
children = children.concat(item.children);
|
|
168
|
+
});
|
|
169
|
+
if (!state.childrenVNode.length) {
|
|
170
|
+
state.childrenVNode = children.slice();
|
|
171
|
+
child.proxy && state.children.push(child.proxy);
|
|
172
|
+
} else {
|
|
173
|
+
if (state.childrenVNode.length > children.length) {
|
|
174
|
+
state.children = state.children.filter((item) => child.proxy !== item);
|
|
175
|
+
} else if (state.childrenVNode.length < children.length) {
|
|
176
|
+
for (let i = 0; i < state.childrenVNode.length; i++) {
|
|
177
|
+
if (children[i].key !== state.childrenVNode[i].key) {
|
|
178
|
+
child.proxy && state.children.splice(i, 0, child.proxy);
|
|
179
|
+
child.vnode && state.childrenVNode.splice(i, 0, child.vnode);
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (state.childrenVNode.length !== children.length) {
|
|
184
|
+
child.proxy && state.children.push(child.proxy);
|
|
185
|
+
child.vnode && state.childrenVNode.push(child.vnode);
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
state.childrenVNode = children.slice();
|
|
189
|
+
child.proxy && state.children.push(child.proxy);
|
|
190
|
+
}
|
|
52
191
|
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
192
|
+
};
|
|
193
|
+
const range = (num, min, max) => {
|
|
194
|
+
return Math.min(Math.max(num, min), max);
|
|
195
|
+
};
|
|
196
|
+
const requestFrame = (fn) => {
|
|
197
|
+
window.requestAnimationFrame.call(window, fn);
|
|
198
|
+
};
|
|
199
|
+
const getOffset = (active, offset = 0) => {
|
|
200
|
+
let currentPosition = active * size.value;
|
|
201
|
+
if (!props.loop) {
|
|
202
|
+
currentPosition = Math.min(currentPosition, -minOffset.value);
|
|
203
|
+
}
|
|
204
|
+
let targetOffset = offset - currentPosition;
|
|
205
|
+
if (!props.loop) {
|
|
206
|
+
targetOffset = range(targetOffset, minOffset.value, 0);
|
|
207
|
+
}
|
|
208
|
+
return targetOffset;
|
|
209
|
+
};
|
|
210
|
+
const getActive = (pace) => {
|
|
211
|
+
const { active } = state;
|
|
212
|
+
if (pace) {
|
|
213
|
+
if (props.loop) {
|
|
214
|
+
return range(active + pace, -1, childCount.value);
|
|
215
|
+
}
|
|
216
|
+
return range(active + pace, 0, childCount.value - 1);
|
|
217
|
+
}
|
|
218
|
+
return active;
|
|
219
|
+
};
|
|
220
|
+
const move = ({ pace = 0, offset = 0, isEmit = false }) => {
|
|
221
|
+
if (childCount.value <= 1)
|
|
222
|
+
return;
|
|
223
|
+
const { active } = state;
|
|
224
|
+
const targetActive = getActive(pace);
|
|
225
|
+
const targetOffset = getOffset(targetActive, offset);
|
|
226
|
+
if (props.loop) {
|
|
227
|
+
if (state.children[0] && targetOffset !== minOffset.value) {
|
|
228
|
+
const rightBound = targetOffset < minOffset.value;
|
|
229
|
+
state.children[0].setOffset(rightBound ? trackSize.value : 0);
|
|
230
|
+
}
|
|
231
|
+
if (state.children[childCount.value - 1] && targetOffset !== 0) {
|
|
232
|
+
const leftBound = targetOffset > 0;
|
|
233
|
+
state.children[childCount.value - 1].setOffset(leftBound ? -trackSize.value : 0);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
state.active = targetActive;
|
|
237
|
+
state.offset = targetOffset;
|
|
238
|
+
if (isEmit && active !== state.active) {
|
|
239
|
+
emit("change", activePagination.value);
|
|
240
|
+
}
|
|
241
|
+
getStyle();
|
|
242
|
+
};
|
|
243
|
+
const resettPosition = () => {
|
|
244
|
+
state.moving = true;
|
|
245
|
+
if (state.active <= -1) {
|
|
246
|
+
move({ pace: childCount.value });
|
|
247
|
+
}
|
|
248
|
+
if (state.active >= childCount.value) {
|
|
249
|
+
move({ pace: -childCount.value });
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
const stopAutoPlay = () => {
|
|
253
|
+
clearTimeout(state.autoplayTimer);
|
|
254
|
+
};
|
|
255
|
+
const prev = () => {
|
|
256
|
+
resettPosition();
|
|
257
|
+
touch.reset();
|
|
258
|
+
requestFrame(() => {
|
|
259
|
+
requestFrame(() => {
|
|
260
|
+
state.moving = false;
|
|
261
|
+
move({
|
|
262
|
+
pace: -1,
|
|
263
|
+
isEmit: true
|
|
264
|
+
});
|
|
265
|
+
});
|
|
63
266
|
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
267
|
+
};
|
|
268
|
+
const next = () => {
|
|
269
|
+
resettPosition();
|
|
270
|
+
touch.reset();
|
|
271
|
+
requestFrame(() => {
|
|
272
|
+
requestFrame(() => {
|
|
273
|
+
state.moving = false;
|
|
274
|
+
move({
|
|
275
|
+
pace: 1,
|
|
276
|
+
isEmit: true
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
};
|
|
281
|
+
const to = (index) => {
|
|
282
|
+
resettPosition();
|
|
283
|
+
touch.reset();
|
|
284
|
+
requestFrame(() => {
|
|
285
|
+
requestFrame(() => {
|
|
286
|
+
state.moving = false;
|
|
287
|
+
let targetIndex;
|
|
288
|
+
if (props.loop && childCount.value === index) {
|
|
289
|
+
targetIndex = state.active === 0 ? 0 : index;
|
|
290
|
+
} else {
|
|
291
|
+
targetIndex = index % childCount.value;
|
|
85
292
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
} }), y({ prev: () => {
|
|
92
|
-
E(), v2.reset(), P(() => {
|
|
93
|
-
P(() => {
|
|
94
|
-
d2.moving = false, S({ pace: -1, isEmit: true });
|
|
293
|
+
move({
|
|
294
|
+
pace: targetIndex - state.active,
|
|
295
|
+
isEmit: true
|
|
296
|
+
});
|
|
297
|
+
});
|
|
95
298
|
});
|
|
299
|
+
};
|
|
300
|
+
const autoplay = () => {
|
|
301
|
+
if (props.autoPlay <= 0 || childCount.value <= 1)
|
|
302
|
+
return;
|
|
303
|
+
stopAutoPlay();
|
|
304
|
+
state.autoplayTimer = setTimeout(() => {
|
|
305
|
+
next();
|
|
306
|
+
autoplay();
|
|
307
|
+
}, Number(props.autoPlay));
|
|
308
|
+
};
|
|
309
|
+
const init = (active = +props.initPage) => {
|
|
310
|
+
stopAutoPlay();
|
|
311
|
+
state.rect = container.value.getBoundingClientRect();
|
|
312
|
+
active = Math.min(childCount.value - 1, active);
|
|
313
|
+
state.width = props.width ? +props.width : state.rect.width;
|
|
314
|
+
state.height = props.height ? +props.height : state.rect.height;
|
|
315
|
+
state.active = active;
|
|
316
|
+
state.offset = getOffset(state.active);
|
|
317
|
+
state.moving = true;
|
|
318
|
+
getStyle();
|
|
319
|
+
autoplay();
|
|
320
|
+
};
|
|
321
|
+
const onTouchStart = (e) => {
|
|
322
|
+
if (props.isPreventDefault)
|
|
323
|
+
e.preventDefault();
|
|
324
|
+
if (props.isStopPropagation)
|
|
325
|
+
e.stopPropagation();
|
|
326
|
+
if (!props.touchable)
|
|
327
|
+
return;
|
|
328
|
+
touch.start(e);
|
|
329
|
+
state.touchTime = Date.now();
|
|
330
|
+
stopAutoPlay();
|
|
331
|
+
resettPosition();
|
|
332
|
+
};
|
|
333
|
+
const onTouchMove = (e) => {
|
|
334
|
+
if (props.touchable && state.moving) {
|
|
335
|
+
touch.move(e);
|
|
336
|
+
if (isCorrectDirection.value) {
|
|
337
|
+
move({
|
|
338
|
+
offset: delTa.value
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
const onTouchEnd = (e) => {
|
|
344
|
+
if (!props.touchable || !state.moving)
|
|
345
|
+
return;
|
|
346
|
+
const speed = delTa.value / (Date.now() - state.touchTime);
|
|
347
|
+
const isShouldMove = Math.abs(speed) > 0.3 || Math.abs(delTa.value) > +(size.value / 2).toFixed(2);
|
|
348
|
+
if (isShouldMove && isCorrectDirection.value) {
|
|
349
|
+
let pace = 0;
|
|
350
|
+
const offset = isVertical.value ? touch.state.offsetY : touch.state.offsetX;
|
|
351
|
+
if (props.loop) {
|
|
352
|
+
pace = offset > 0 ? delTa.value > 0 ? -1 : 1 : 0;
|
|
353
|
+
} else {
|
|
354
|
+
pace = -Math[delTa.value > 0 ? "ceil" : "floor"](delTa.value / size.value);
|
|
355
|
+
}
|
|
356
|
+
move({
|
|
357
|
+
pace,
|
|
358
|
+
isEmit: true
|
|
359
|
+
});
|
|
360
|
+
} else if (delTa.value) {
|
|
361
|
+
move({ pace: 0 });
|
|
362
|
+
}
|
|
363
|
+
state.moving = false;
|
|
364
|
+
getStyle();
|
|
365
|
+
autoplay();
|
|
366
|
+
};
|
|
367
|
+
provide("parent", {
|
|
368
|
+
props,
|
|
369
|
+
size,
|
|
370
|
+
relation
|
|
371
|
+
});
|
|
372
|
+
useExpose({
|
|
373
|
+
prev,
|
|
374
|
+
next,
|
|
375
|
+
to
|
|
376
|
+
});
|
|
377
|
+
onDeactivated(() => {
|
|
378
|
+
stopAutoPlay();
|
|
96
379
|
});
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
380
|
+
onBeforeUnmount(() => {
|
|
381
|
+
stopAutoPlay();
|
|
382
|
+
});
|
|
383
|
+
watch(() => props.initPage, (val) => {
|
|
384
|
+
nextTick(() => {
|
|
385
|
+
init(Number(val));
|
|
102
386
|
});
|
|
103
387
|
});
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}), n(() => c2.initPage, (e2) => {
|
|
109
|
-
r(() => {
|
|
110
|
-
D(Number(e2));
|
|
388
|
+
watch(() => state.children.length, () => {
|
|
389
|
+
nextTick(() => {
|
|
390
|
+
init();
|
|
391
|
+
});
|
|
111
392
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
D();
|
|
393
|
+
watch(() => props.autoPlay, (val) => {
|
|
394
|
+
val > 0 ? autoplay() : stopAutoPlay();
|
|
115
395
|
});
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
396
|
+
return {
|
|
397
|
+
state,
|
|
398
|
+
classes,
|
|
399
|
+
container,
|
|
400
|
+
componentName,
|
|
401
|
+
isVertical,
|
|
402
|
+
slots,
|
|
403
|
+
activePagination,
|
|
404
|
+
onTouchStart,
|
|
405
|
+
onTouchMove,
|
|
406
|
+
onTouchEnd
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
411
|
+
return openBlock(), createElementBlock("view", {
|
|
412
|
+
ref: "container",
|
|
413
|
+
class: normalizeClass(_ctx.classes),
|
|
414
|
+
onTouchstart: _cache[0] || (_cache[0] = (...args) => _ctx.onTouchStart && _ctx.onTouchStart(...args)),
|
|
415
|
+
onTouchmove: _cache[1] || (_cache[1] = (...args) => _ctx.onTouchMove && _ctx.onTouchMove(...args)),
|
|
416
|
+
onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args)),
|
|
417
|
+
onTouchcancel: _cache[3] || (_cache[3] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args))
|
|
418
|
+
}, [
|
|
419
|
+
createElementVNode("view", {
|
|
420
|
+
class: normalizeClass({
|
|
421
|
+
[`${_ctx.componentName}-inner`]: true,
|
|
422
|
+
[`${_ctx.componentName}-vertical`]: _ctx.isVertical
|
|
423
|
+
}),
|
|
424
|
+
style: normalizeStyle(_ctx.state.style)
|
|
425
|
+
}, [
|
|
426
|
+
renderSlot(_ctx.$slots, "default")
|
|
427
|
+
], 6),
|
|
428
|
+
renderSlot(_ctx.$slots, "page"),
|
|
429
|
+
_ctx.paginationVisible && !_ctx.slots.page ? (openBlock(), createElementBlock("view", {
|
|
430
|
+
key: 0,
|
|
431
|
+
class: normalizeClass({
|
|
432
|
+
[`${_ctx.componentName}-pagination`]: true,
|
|
433
|
+
[`${_ctx.componentName}-pagination-vertical`]: _ctx.isVertical
|
|
434
|
+
})
|
|
435
|
+
}, [
|
|
436
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.state.children.length, (item, index) => {
|
|
437
|
+
return openBlock(), createElementBlock("i", {
|
|
438
|
+
style: normalizeStyle({
|
|
439
|
+
backgroundColor: _ctx.activePagination === index ? _ctx.paginationColor : "#ddd"
|
|
440
|
+
}),
|
|
441
|
+
class: normalizeClass({ active: _ctx.activePagination === index }),
|
|
442
|
+
key: index
|
|
443
|
+
}, null, 6);
|
|
444
|
+
}), 128))
|
|
445
|
+
], 2)) : createCommentVNode("", true)
|
|
446
|
+
], 34);
|
|
447
|
+
}
|
|
448
|
+
var Swiper = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
449
|
+
export { Swiper as default };
|
|
@@ -1,27 +1,58 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.0 Mon Jun 27 2022 17:55:50 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { inject
|
|
7
|
-
import { c as
|
|
8
|
-
import { u as
|
|
9
|
-
import { _ as
|
|
6
|
+
import { inject, getCurrentInstance, reactive, computed, onUnmounted, openBlock, createElementBlock, normalizeClass, normalizeStyle, renderSlot } from "vue";
|
|
7
|
+
import { c as createComponent } from "./component.js";
|
|
8
|
+
import { u as useExpose } from "./index3.js";
|
|
9
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
10
10
|
import "../locale/lang";
|
|
11
|
-
const { create
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
11
|
+
const { create, componentName } = createComponent("swiper-item");
|
|
12
|
+
const _sfc_main = create({
|
|
13
|
+
setup(props, { slots }) {
|
|
14
|
+
const parent = inject("parent");
|
|
15
|
+
parent["relation"](getCurrentInstance());
|
|
16
|
+
const state = reactive({
|
|
17
|
+
offset: 0
|
|
18
|
+
});
|
|
19
|
+
const classes = computed(() => {
|
|
20
|
+
const prefixCls = componentName;
|
|
21
|
+
return {
|
|
22
|
+
[prefixCls]: true
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
const style = computed(() => {
|
|
26
|
+
const style2 = {};
|
|
27
|
+
const direction = parent == null ? void 0 : parent.props.direction;
|
|
28
|
+
if (parent == null ? void 0 : parent.size.value) {
|
|
29
|
+
style2[direction === "horizontal" ? "width" : "height"] = `${parent == null ? void 0 : parent.size.value}px`;
|
|
30
|
+
}
|
|
31
|
+
if (state.offset) {
|
|
32
|
+
style2["transform"] = `translate${direction === "horizontal" ? "X" : "Y"}(${state.offset}px)`;
|
|
33
|
+
}
|
|
34
|
+
return style2;
|
|
35
|
+
});
|
|
36
|
+
const setOffset = (offset) => {
|
|
37
|
+
state.offset = offset;
|
|
38
|
+
};
|
|
39
|
+
onUnmounted(() => {
|
|
40
|
+
parent["relation"](getCurrentInstance(), "unmount");
|
|
41
|
+
});
|
|
42
|
+
useExpose({ setOffset });
|
|
43
|
+
return {
|
|
44
|
+
style,
|
|
45
|
+
classes
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
50
|
+
return openBlock(), createElementBlock("view", {
|
|
51
|
+
class: normalizeClass(_ctx.classes),
|
|
52
|
+
style: normalizeStyle(_ctx.style)
|
|
53
|
+
}, [
|
|
54
|
+
renderSlot(_ctx.$slots, "default")
|
|
55
|
+
], 6);
|
|
56
|
+
}
|
|
57
|
+
var SwiperItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
58
|
+
export { SwiperItem as default };
|