@nutui/nutui 3.1.6 → 3.1.7

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.
Files changed (92) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/nutui.d.ts +7 -1
  3. package/dist/nutui.es.js +1097 -517
  4. package/dist/nutui.umd.js +1158 -571
  5. package/dist/packages/_es/ActionSheet.js +158 -0
  6. package/dist/packages/_es/Address.js +525 -0
  7. package/dist/packages/_es/Avatar.js +87 -0
  8. package/dist/packages/_es/BackTop.js +159 -0
  9. package/dist/packages/_es/Badge.js +90 -0
  10. package/dist/packages/_es/Barrage.js +118 -0
  11. package/dist/packages/_es/Button.js +124 -0
  12. package/dist/packages/_es/Calendar.js +700 -0
  13. package/dist/packages/_es/Cell.js +95 -0
  14. package/dist/packages/_es/CellGroup.js +42 -0
  15. package/dist/packages/_es/Checkbox.js +109 -0
  16. package/dist/packages/_es/CheckboxGroup.js +62 -0
  17. package/dist/packages/_es/CircleProgress.js +109 -0
  18. package/dist/packages/_es/Col.js +53 -0
  19. package/dist/packages/_es/Collapse.js +89 -0
  20. package/dist/packages/_es/CollapseItem.js +257 -0
  21. package/dist/packages/_es/CountDown.js +224 -0
  22. package/dist/packages/_es/CountUp.js +547 -0
  23. package/dist/packages/_es/DatePicker.js +282 -0
  24. package/dist/packages/_es/Dialog.js +313 -0
  25. package/dist/packages/_es/Divider.js +49 -0
  26. package/dist/packages/_es/Drag.js +198 -0
  27. package/dist/packages/_es/Elevator.js +207 -0
  28. package/dist/packages/_es/FixedNav.js +127 -0
  29. package/dist/packages/_es/Icon.js +44 -0
  30. package/dist/packages/_es/ImagePreview.js +109 -0
  31. package/dist/packages/_es/InfiniteLoading.js +265 -0
  32. package/dist/packages/_es/Input.js +183 -0
  33. package/dist/packages/_es/InputNumber.js +172 -0
  34. package/dist/packages/_es/Layout.js +10 -0
  35. package/dist/packages/_es/MenuItem.js +180 -0
  36. package/dist/packages/_es/Navbar.js +160 -0
  37. package/dist/packages/_es/NoticeBar.js +389 -0
  38. package/dist/packages/_es/Notify.js +233 -0
  39. package/dist/packages/_es/NumberKeyboard.js +248 -0
  40. package/dist/packages/_es/OverLay.js +118 -0
  41. package/dist/packages/_es/Pagination.js +163 -0
  42. package/dist/packages/_es/Picker.js +485 -0
  43. package/dist/packages/_es/Popover.js +157 -0
  44. package/dist/packages/_es/Popup.js +268 -0
  45. package/dist/packages/_es/Price.js +104 -0
  46. package/dist/packages/_es/Progress.js +131 -0
  47. package/dist/packages/_es/Radio.js +72 -0
  48. package/dist/packages/_es/RadioGroup.js +37 -0
  49. package/dist/packages/_es/Range.js +350 -0
  50. package/dist/packages/_es/Rate.js +129 -0
  51. package/dist/packages/_es/Row.js +61 -0
  52. package/dist/packages/_es/ShortPassword.js +221 -0
  53. package/dist/packages/_es/Signature.js +167 -0
  54. package/dist/packages/_es/Step.js +116 -0
  55. package/dist/packages/_es/Steps.js +52 -0
  56. package/dist/packages/_es/Swipe.js +193 -0
  57. package/dist/packages/_es/Swiper.js +429 -0
  58. package/dist/packages/_es/SwiperItem.js +60 -0
  59. package/dist/packages/_es/Switch.js +90 -0
  60. package/dist/packages/_es/Tab.js +179 -0
  61. package/dist/packages/_es/TabPane.js +42 -0
  62. package/dist/packages/_es/TabPanel.js +30 -0
  63. package/dist/packages/_es/Tabbar.js +73 -0
  64. package/dist/packages/_es/TabbarItem.js +142 -0
  65. package/dist/packages/_es/Tag.js +98 -0
  66. package/dist/packages/_es/TextArea.js +127 -0
  67. package/dist/packages/_es/Toast.js +317 -0
  68. package/dist/packages/_es/Uploader.js +400 -0
  69. package/dist/packages/_es/Video.js +405 -0
  70. package/dist/packages/_es/component.js +26 -0
  71. package/dist/packages/_es/index.js +64 -0
  72. package/dist/packages/_es/index2.js +13 -0
  73. package/dist/packages/_es/plugin-vue_export-helper.js +12 -0
  74. package/dist/packages/_es/pxCheck.js +9 -0
  75. package/dist/packages/_es/raf.js +19 -0
  76. package/dist/packages/avatar/index.scss +0 -1
  77. package/dist/packages/badge/index.scss +35 -0
  78. package/dist/packages/calendar/index.scss +13 -0
  79. package/dist/packages/imagepreview/index.scss +48 -0
  80. package/dist/packages/input/index.scss +14 -7
  81. package/dist/packages/pagination/index.scss +51 -0
  82. package/dist/packages/popover/index.scss +159 -0
  83. package/dist/packages/shortpassword/index.scss +19 -7
  84. package/dist/packages/tabpane/index.scss +1 -0
  85. package/dist/packages/tabs/index.scss +1 -0
  86. package/dist/packages/tag/index.scss +47 -0
  87. package/dist/packages/uploader/index.scss +0 -1
  88. package/dist/style.css +1 -1
  89. package/dist/style.es.js +2 -1
  90. package/dist/styles/themes/default.scss +35 -28
  91. package/dist/styles/variables.scss +55 -32
  92. package/package.json +7 -7
@@ -0,0 +1,193 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ /*!
21
+ * @nutui/nutui v3.1.7 Thu Sep 30 2021 20:17:02 GMT+0800 (中国标准时间)
22
+ * (c) 2021 @jdf2e.
23
+ * Released under the MIT License.
24
+ */
25
+ import { u as useTouch } from "./index.js";
26
+ import { computed, ref, reactive, openBlock, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, renderSlot } from "vue";
27
+ import { c as createComponent } from "./component.js";
28
+ import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
29
+ const { componentName, create } = createComponent("swipe");
30
+ const _sfc_main = create({
31
+ props: {
32
+ name: {
33
+ type: String,
34
+ default: ""
35
+ },
36
+ disabled: {
37
+ type: Boolean,
38
+ default: false
39
+ }
40
+ },
41
+ emits: ["open", "close"],
42
+ setup(props, { emit }) {
43
+ const classes = computed(() => {
44
+ const prefixCls = componentName;
45
+ return {
46
+ [prefixCls]: true
47
+ };
48
+ });
49
+ const getRefWidth = (ref2) => {
50
+ var _a;
51
+ return ((_a = ref2.value) == null ? void 0 : _a.clientWidth) || 0;
52
+ };
53
+ const leftRef = ref(), leftRefWidth = computed(() => {
54
+ return getRefWidth(leftRef);
55
+ });
56
+ const rightRef = ref(), rightRefWidth = computed(() => {
57
+ return getRefWidth(rightRef);
58
+ });
59
+ let opened = false;
60
+ let position = "";
61
+ let oldPosition = "";
62
+ const state = reactive({
63
+ offset: 0,
64
+ moving: false
65
+ });
66
+ const open = (p = "") => {
67
+ opened = true;
68
+ if (p) {
69
+ state.offset = p === "left" ? -rightRefWidth.value : leftRefWidth.value;
70
+ }
71
+ emit("open", {
72
+ name: props.name,
73
+ position: position || p
74
+ });
75
+ };
76
+ const close = () => {
77
+ state.offset = 0;
78
+ opened = false;
79
+ emit("close", {
80
+ name: props.name,
81
+ position
82
+ });
83
+ };
84
+ const touchStyle = computed(() => {
85
+ return {
86
+ transform: `translate3d(${state.offset}px, 0, 0)`
87
+ };
88
+ });
89
+ const setoffset = (deltaX) => {
90
+ position = deltaX > 0 ? "right" : "left";
91
+ let offset = deltaX;
92
+ switch (position) {
93
+ case "left":
94
+ if (opened && oldPosition === position) {
95
+ offset = -rightRefWidth.value;
96
+ } else {
97
+ offset = Math.abs(deltaX) > rightRefWidth.value ? -rightRefWidth.value : deltaX;
98
+ }
99
+ break;
100
+ case "right":
101
+ if (opened && oldPosition === position) {
102
+ offset = leftRefWidth.value;
103
+ } else {
104
+ offset = Math.abs(deltaX) > leftRefWidth.value ? leftRefWidth.value : deltaX;
105
+ }
106
+ break;
107
+ }
108
+ state.offset = offset;
109
+ };
110
+ const touch = useTouch();
111
+ const touchMethods = {
112
+ onTouchStart(event) {
113
+ if (props.disabled)
114
+ return;
115
+ touch.start(event);
116
+ },
117
+ onTouchMove(event) {
118
+ if (props.disabled)
119
+ return;
120
+ if (touch.isVertical() == false) {
121
+ state.moving = true;
122
+ touch.move(event);
123
+ setoffset(touch.deltaX.value);
124
+ event.preventDefault();
125
+ }
126
+ },
127
+ onTouchEnd() {
128
+ if (state.moving) {
129
+ state.moving = false;
130
+ oldPosition = position;
131
+ switch (position) {
132
+ case "left":
133
+ if (Math.abs(state.offset) <= rightRefWidth.value / 2) {
134
+ close();
135
+ } else {
136
+ state.offset = -rightRefWidth.value;
137
+ open();
138
+ }
139
+ break;
140
+ case "right":
141
+ if (Math.abs(state.offset) <= leftRefWidth.value / 2) {
142
+ close();
143
+ } else {
144
+ state.offset = leftRefWidth.value;
145
+ open();
146
+ }
147
+ break;
148
+ }
149
+ }
150
+ }
151
+ };
152
+ return __spreadProps(__spreadValues({
153
+ classes,
154
+ touchStyle
155
+ }, touchMethods), {
156
+ leftRef,
157
+ rightRef,
158
+ open,
159
+ close
160
+ });
161
+ }
162
+ });
163
+ const _hoisted_1 = {
164
+ class: "nut-swipe__left",
165
+ ref: "leftRef"
166
+ };
167
+ const _hoisted_2 = { class: "nut-swipe__content" };
168
+ const _hoisted_3 = {
169
+ class: "nut-swipe__right",
170
+ ref: "rightRef"
171
+ };
172
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
173
+ return openBlock(), createElementBlock("view", {
174
+ class: normalizeClass(_ctx.classes),
175
+ style: normalizeStyle(_ctx.touchStyle),
176
+ onTouchstart: _cache[0] || (_cache[0] = (...args) => _ctx.onTouchStart && _ctx.onTouchStart(...args)),
177
+ onTouchmove: _cache[1] || (_cache[1] = (...args) => _ctx.onTouchMove && _ctx.onTouchMove(...args)),
178
+ onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args)),
179
+ onTouchcancel: _cache[3] || (_cache[3] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args))
180
+ }, [
181
+ createElementVNode("view", _hoisted_1, [
182
+ renderSlot(_ctx.$slots, "left")
183
+ ], 512),
184
+ createElementVNode("view", _hoisted_2, [
185
+ renderSlot(_ctx.$slots, "default")
186
+ ]),
187
+ createElementVNode("view", _hoisted_3, [
188
+ renderSlot(_ctx.$slots, "right")
189
+ ], 512)
190
+ ], 38);
191
+ }
192
+ var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
193
+ export { index as default };
@@ -0,0 +1,429 @@
1
+ /*!
2
+ * @nutui/nutui v3.1.7 Thu Sep 30 2021 20:17:02 GMT+0800 (中国标准时间)
3
+ * (c) 2021 @jdf2e.
4
+ * Released under the MIT License.
5
+ */
6
+ import { reactive, ref, computed, provide, onMounted, nextTick, onActivated, onDeactivated, onBeforeUnmount, watch, 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 "./index2.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
+ }
58
+ const { create, componentName } = createComponent("swiper");
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 = (index2) => {
253
+ resettPosition();
254
+ touch.reset();
255
+ requestFrame(() => {
256
+ requestFrame(() => {
257
+ state.moving = false;
258
+ let targetIndex;
259
+ if (props.loop && childCount.value === index2) {
260
+ targetIndex = state.active === 0 ? 0 : index2;
261
+ } else {
262
+ targetIndex = index2 % 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
+ };
389
+ }
390
+ });
391
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
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
+ }, [
407
+ renderSlot(_ctx.$slots, "default")
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, index2) => {
418
+ return openBlock(), createElementBlock("i", {
419
+ style: normalizeStyle({
420
+ backgroundColor: _ctx.activePagination === index2 ? _ctx.paginationColor : "#ddd"
421
+ }),
422
+ key: index2
423
+ }, null, 4);
424
+ }), 128))
425
+ ], 2)) : createCommentVNode("", true)
426
+ ], 34);
427
+ }
428
+ var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
429
+ export { index as default };
@@ -0,0 +1,60 @@
1
+ /*!
2
+ * @nutui/nutui v3.1.7 Thu Sep 30 2021 20:17:02 GMT+0800 (中国标准时间)
3
+ * (c) 2021 @jdf2e.
4
+ * Released under the MIT License.
5
+ */
6
+ import { getCurrentInstance, inject, reactive, computed, openBlock, createElementBlock, normalizeClass, normalizeStyle, renderSlot } from "vue";
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
+ }
15
+ const { create, componentName } = createComponent("swiper-item");
16
+ const _sfc_main = create({
17
+ props: {},
18
+ setup(props, { slots }) {
19
+ const parent = inject("parent");
20
+ parent["relation"](getCurrentInstance());
21
+ const state = reactive({
22
+ offset: 0
23
+ });
24
+ const classes = computed(() => {
25
+ const prefixCls = componentName;
26
+ return {
27
+ [prefixCls]: true
28
+ };
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 });
45
+ return {
46
+ style,
47
+ classes
48
+ };
49
+ }
50
+ });
51
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
52
+ return openBlock(), createElementBlock("view", {
53
+ class: normalizeClass(_ctx.classes),
54
+ style: normalizeStyle(_ctx.style)
55
+ }, [
56
+ renderSlot(_ctx.$slots, "default")
57
+ ], 6);
58
+ }
59
+ var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
60
+ export { index as default };