@nutui/nutui 4.0.12-beta.1 → 4.0.12

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 (158) hide show
  1. package/dist/nutui.es.js +1 -1
  2. package/dist/nutui.js +1 -1
  3. package/dist/nutui.umd.js +1 -1
  4. package/dist/packages/_es/ActionSheet.js +111 -78
  5. package/dist/packages/_es/Address.js +375 -250
  6. package/dist/packages/_es/AddressList.js +354 -269
  7. package/dist/packages/_es/Animate.js +58 -41
  8. package/dist/packages/_es/Audio.js +197 -128
  9. package/dist/packages/_es/AudioOperate.js +71 -60
  10. package/dist/packages/_es/Avatar.js +89 -66
  11. package/dist/packages/_es/AvatarGroup.js +31 -23
  12. package/dist/packages/_es/Backtop.js +99 -59
  13. package/dist/packages/_es/Badge.js +47 -36
  14. package/dist/packages/_es/Barrage.js +147 -68
  15. package/dist/packages/_es/Button.js +66 -47
  16. package/dist/packages/_es/Calendar.js +157 -135
  17. package/dist/packages/_es/CalendarItem.js +6 -6
  18. package/dist/packages/_es/Card.js +56 -42
  19. package/dist/packages/_es/Cascader.js +474 -315
  20. package/dist/packages/_es/Category.js +39 -29
  21. package/dist/packages/_es/CategoryPane.js +83 -57
  22. package/dist/packages/_es/Cell.js +71 -56
  23. package/dist/packages/_es/CellGroup.js +27 -19
  24. package/dist/packages/_es/Checkbox.js +156 -109
  25. package/dist/packages/_es/CheckboxGroup.js +59 -38
  26. package/dist/packages/_es/CircleProgress.js +96 -67
  27. package/dist/packages/_es/Col.js +31 -23
  28. package/dist/packages/_es/Collapse.js +58 -33
  29. package/dist/packages/_es/CollapseItem.js +108 -78
  30. package/dist/packages/_es/Comment.js +279 -207
  31. package/dist/packages/_es/ConfigProvider.js +55 -37
  32. package/dist/packages/_es/Countdown.js +212 -100
  33. package/dist/packages/_es/Countup.js +445 -232
  34. package/dist/packages/_es/DatePicker.js +265 -162
  35. package/dist/packages/_es/Dialog.js +213 -161
  36. package/dist/packages/_es/Divider.js +57 -42
  37. package/dist/packages/_es/Drag.js +153 -70
  38. package/dist/packages/_es/Ecard.js +104 -64
  39. package/dist/packages/_es/Elevator.js +219 -143
  40. package/dist/packages/_es/Ellipsis.js +178 -95
  41. package/dist/packages/_es/Empty.js +39 -23
  42. package/dist/packages/_es/FixedNav.js +116 -93
  43. package/dist/packages/_es/Form.js +178 -107
  44. package/dist/packages/_es/FormItem.js +61 -48
  45. package/dist/packages/_es/Grid.js +6 -5
  46. package/dist/packages/_es/GridItem.js +84 -58
  47. package/dist/packages/_es/Image.js +130 -90
  48. package/dist/packages/_es/ImagePreview.js +412 -256
  49. package/dist/packages/_es/Indicator.js +34 -30
  50. package/dist/packages/_es/InfiniteLoading.js +136 -83
  51. package/dist/packages/_es/Input.js +264 -160
  52. package/dist/packages/_es/InputNumber.js +117 -81
  53. package/dist/packages/_es/Interceptor-956b24fc.js +29 -0
  54. package/dist/packages/_es/Invoice.js +130 -104
  55. package/dist/packages/_es/Layout.js +4 -3
  56. package/dist/packages/_es/List.js +215 -117
  57. package/dist/packages/_es/Menu.js +150 -95
  58. package/dist/packages/_es/MenuItem.js +154 -109
  59. package/dist/packages/_es/Navbar.js +119 -103
  60. package/dist/packages/_es/Noticebar.js +312 -197
  61. package/dist/packages/_es/Notify.js +166 -110
  62. package/dist/packages/_es/NumberKeyboard.js +202 -127
  63. package/dist/packages/_es/Overlay.js +80 -52
  64. package/dist/packages/_es/Pagination.js +100 -70
  65. package/dist/packages/_es/Picker.js +437 -275
  66. package/dist/packages/_es/Popover.js +225 -122
  67. package/dist/packages/_es/Popup.js +4 -4
  68. package/dist/packages/_es/Price.js +82 -44
  69. package/dist/packages/_es/Progress.js +79 -63
  70. package/dist/packages/_es/PullRefresh.js +173 -95
  71. package/dist/packages/_es/Radio.js +4 -4
  72. package/dist/packages/_es/RadioGroup.js +3 -3
  73. package/dist/packages/_es/Range.js +347 -204
  74. package/dist/packages/_es/Rate.js +141 -92
  75. package/dist/packages/_es/Row.js +27 -21
  76. package/dist/packages/_es/Searchbar.js +174 -123
  77. package/dist/packages/_es/ShortPassword.js +93 -69
  78. package/dist/packages/_es/SideNavbar.js +80 -49
  79. package/dist/packages/_es/SideNavbarItem.js +32 -22
  80. package/dist/packages/_es/Signature.js +146 -83
  81. package/dist/packages/_es/Skeleton.js +130 -110
  82. package/dist/packages/_es/Sku.js +343 -250
  83. package/dist/packages/_es/Step.js +86 -59
  84. package/dist/packages/_es/Steps.js +31 -26
  85. package/dist/packages/_es/Sticky.js +4 -4
  86. package/dist/packages/_es/SubSideNavbar.js +74 -52
  87. package/dist/packages/_es/Swipe.js +155 -83
  88. package/dist/packages/_es/Swiper.js +311 -174
  89. package/dist/packages/_es/SwiperItem.js +44 -28
  90. package/dist/packages/_es/Switch.js +68 -55
  91. package/dist/packages/_es/TabPane.js +41 -30
  92. package/dist/packages/_es/Tabbar.js +52 -41
  93. package/dist/packages/_es/TabbarItem.js +82 -61
  94. package/dist/packages/_es/Table.js +165 -109
  95. package/dist/packages/_es/Tabs.js +388 -240
  96. package/dist/packages/_es/Tag.js +61 -44
  97. package/dist/packages/_es/Textarea.js +124 -80
  98. package/dist/packages/_es/TimeDetail.js +76 -49
  99. package/dist/packages/_es/TimePannel.js +48 -34
  100. package/dist/packages/_es/TimeSelect.js +68 -47
  101. package/dist/packages/_es/Toast.js +218 -144
  102. package/dist/packages/_es/Tour.js +192 -138
  103. package/dist/packages/_es/TrendArrow.js +77 -57
  104. package/dist/packages/_es/Uploader.js +359 -234
  105. package/dist/packages/_es/Video.js +316 -191
  106. package/dist/packages/_es/Watermark.js +117 -84
  107. package/dist/packages/_es/_plugin-vue_export-helper-cc2b3d55.js +10 -0
  108. package/dist/packages/_es/common-b9a5e726.js +145 -0
  109. package/dist/packages/_es/component-81a4c1d0.js +145 -0
  110. package/dist/packages/_es/index-29892cda.js +33 -0
  111. package/dist/packages/_es/index-43c34ac6.js +30 -0
  112. package/dist/packages/_es/index-54d03fc1.js +8 -0
  113. package/dist/packages/_es/index-79c5dc33.js +10 -0
  114. package/dist/packages/_es/index-7a7385e4.js +67 -0
  115. package/dist/packages/_es/index-87422be8.js +942 -0
  116. package/dist/packages/_es/index-da0a7662.js +259 -0
  117. package/dist/packages/_es/index.vue_vue_type_script_lang-22dfc112.js +46 -0
  118. package/dist/packages/_es/index.vue_vue_type_script_lang-a8856969.js +97 -0
  119. package/dist/packages/_es/index.vue_vue_type_script_lang-cc5c4086.js +151 -0
  120. package/dist/packages/_es/mountComponent-8b24c346.js +39 -0
  121. package/dist/packages/_es/pxCheck-c6b9f6b7.js +6 -0
  122. package/dist/packages/_es/raf-729dad54.js +25 -0
  123. package/dist/packages/_es/renderIcon-3d0fd47c.js +9 -0
  124. package/dist/packages/locale/lang/baseLang-3a8457ac.js +5 -0
  125. package/dist/packages/locale/lang/en-US.js +39 -36
  126. package/dist/packages/locale/lang/id-ID.js +39 -36
  127. package/dist/packages/locale/lang/index.js +44 -22
  128. package/dist/packages/locale/lang/zh-CN.js +38 -35
  129. package/dist/packages/locale/lang/zh-TW.js +38 -35
  130. package/dist/resolver/index.js +26 -1
  131. package/dist/resolver/index.mjs +17 -14
  132. package/dist/smartips/web-types.json +1 -1
  133. package/dist/style.css +1 -1
  134. package/dist/styles/themes/default.scss +50 -50
  135. package/dist/styles/themes/jdb.scss +50 -50
  136. package/dist/styles/themes/jddkh.scss +50 -50
  137. package/dist/styles/themes/jdt.scss +50 -50
  138. package/dist/types/index.d.ts +1 -1
  139. package/package.json +2 -2
  140. package/dist/packages/_es/Interceptor-6e26b757.js +0 -18
  141. package/dist/packages/_es/_plugin-vue_export-helper-dad06003.js +0 -9
  142. package/dist/packages/_es/common-d218746f.js +0 -116
  143. package/dist/packages/_es/component-234624bc.js +0 -89
  144. package/dist/packages/_es/index-14dfadc4.js +0 -561
  145. package/dist/packages/_es/index-192a3ef6.js +0 -29
  146. package/dist/packages/_es/index-360c5092.js +0 -210
  147. package/dist/packages/_es/index-496e6e05.js +0 -24
  148. package/dist/packages/_es/index-50eed3d9.js +0 -7
  149. package/dist/packages/_es/index-53ec2d4d.js +0 -34
  150. package/dist/packages/_es/index-fadb0974.js +0 -8
  151. package/dist/packages/_es/index.vue_vue_type_script_lang-1139b29a.js +0 -43
  152. package/dist/packages/_es/index.vue_vue_type_script_lang-43b774dd.js +0 -77
  153. package/dist/packages/_es/index.vue_vue_type_script_lang-f44c159d.js +0 -110
  154. package/dist/packages/_es/mountComponent-6d4ff200.js +0 -23
  155. package/dist/packages/_es/pxCheck-38173291.js +0 -4
  156. package/dist/packages/_es/raf-a74f1a06.js +0 -16
  157. package/dist/packages/_es/renderIcon-47498b32.js +0 -5
  158. package/dist/packages/locale/lang/baseLang-0bdc6353.js +0 -5
@@ -1,11 +1,12 @@
1
- import { ref as Q, reactive as Z, computed as s, provide as _, onDeactivated as ee, onBeforeUnmount as te, watch as E, nextTick as Y, openBlock as P, createElementBlock as b, normalizeClass as S, createElementVNode as ne, normalizeStyle as L, renderSlot as j, Fragment as oe, renderList as ae, createCommentVNode as ie } from "vue";
2
- import { c as le, e as B } from "./component-234624bc.js";
3
- import { u as re } from "./index-53ec2d4d.js";
4
- import { u as ue } from "./index-fadb0974.js";
5
- import { r as k } from "./raf-a74f1a06.js";
6
- import { _ as se } from "./_plugin-vue_export-helper-dad06003.js";
1
+ import { ref, reactive, computed, provide, onDeactivated, onBeforeUnmount, watch, nextTick, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, renderSlot, Fragment, renderList, createCommentVNode } from "vue";
2
+ import { c as createComponent, e as clamp } from "./component-81a4c1d0.js";
3
+ import { u as useTouch } from "./index-7a7385e4.js";
4
+ import { u as useExpose } from "./index-79c5dc33.js";
5
+ import { r as requestAniFrame } from "./raf-729dad54.js";
6
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
7
7
  import "../locale/lang";
8
- const { create: ce, componentName: M } = le("swiper"), fe = ce({
8
+ const { create, componentName } = createComponent("swiper");
9
+ const _sfc_main = create({
9
10
  props: {
10
11
  width: {
11
12
  type: [Number, String],
@@ -22,7 +23,7 @@ const { create: ce, componentName: M } = le("swiper"), fe = ce({
22
23
  },
23
24
  paginationVisible: {
24
25
  type: Boolean,
25
- default: !1
26
+ default: false
26
27
  },
27
28
  paginationColor: {
28
29
  type: String,
@@ -30,7 +31,7 @@ const { create: ce, componentName: M } = le("swiper"), fe = ce({
30
31
  },
31
32
  loop: {
32
33
  type: Boolean,
33
- default: !0
34
+ default: true
34
35
  },
35
36
  duration: {
36
37
  type: [Number, String],
@@ -46,225 +47,361 @@ const { create: ce, componentName: M } = le("swiper"), fe = ce({
46
47
  },
47
48
  touchable: {
48
49
  type: Boolean,
49
- default: !0
50
+ default: true
50
51
  },
51
52
  isPreventDefault: {
52
53
  type: Boolean,
53
- default: !0
54
+ default: true
54
55
  },
55
56
  isStopPropagation: {
56
57
  type: Boolean,
57
- default: !0
58
+ default: true
58
59
  }
59
60
  },
60
61
  emits: ["change"],
61
- setup(n, { emit: c, slots: p }) {
62
- const N = Q(), e = Z({
62
+ setup(props, { emit, slots }) {
63
+ const container = ref();
64
+ const state = reactive({
63
65
  active: 0,
64
66
  num: 0,
65
67
  rect: null,
66
68
  width: 0,
67
69
  height: 0,
68
- moving: !1,
70
+ moving: false,
69
71
  offset: 0,
70
72
  touchTime: 0,
71
73
  autoplayTimer: null,
72
74
  children: [],
73
75
  childrenVNode: [],
74
76
  style: {}
75
- }), f = re(), v = s(() => ({
76
- [M]: !0
77
- })), l = s(() => n.direction === "vertical"), q = s(() => {
78
- const t = M;
77
+ });
78
+ const touch = useTouch();
79
+ const classes = computed(() => {
80
+ const prefixCls = componentName;
79
81
  return {
80
- [`${t}-inner`]: !0,
81
- [`${t}-vertical`]: l.value
82
+ [prefixCls]: true
82
83
  };
83
- }), R = s(() => {
84
- const t = M;
84
+ });
85
+ const isVertical = computed(() => props.direction === "vertical");
86
+ const classesInner = computed(() => {
87
+ const prefixCls = componentName;
85
88
  return {
86
- [`${t}-pagination`]: !0,
87
- [`${t}-pagination-vertical`]: l.value
89
+ [`${prefixCls}-inner`]: true,
90
+ [`${prefixCls}-vertical`]: isVertical.value
88
91
  };
89
- }), h = s(() => l.value ? f.deltaY.value : f.deltaX.value), D = s(() => f.direction.value === n.direction), i = s(() => e.children.length), d = s(() => e[l.value ? "height" : "width"]), A = s(() => i.value * d.value), T = s(() => e.rect ? (l.value ? e.rect.height : e.rect.width) - d.value * i.value : 0), O = s(() => (e.active + i.value) % i.value), $ = () => {
90
- let t = 0;
91
- t = e.offset, e.style = {
92
- transitionDuration: `${e.moving ? 0 : n.duration}ms`,
93
- transform: `translate${l.value ? "Y" : "X"}(${t}px)`,
94
- [l.value ? "height" : "width"]: `${d.value * i.value}px`,
95
- [l.value ? "width" : "height"]: `${l.value ? e.width : e.height}px`
92
+ });
93
+ const classesPagination = computed(() => {
94
+ const prefixCls = componentName;
95
+ return {
96
+ [`${prefixCls}-pagination`]: true,
97
+ [`${prefixCls}-pagination-vertical`]: isVertical.value
98
+ };
99
+ });
100
+ const delTa = computed(() => {
101
+ return isVertical.value ? touch.deltaY.value : touch.deltaX.value;
102
+ });
103
+ const isCorrectDirection = computed(() => {
104
+ return touch.direction.value === props.direction;
105
+ });
106
+ const childCount = computed(() => state.children.length);
107
+ const size = computed(() => state[isVertical.value ? "height" : "width"]);
108
+ const trackSize = computed(() => childCount.value * size.value);
109
+ const minOffset = computed(() => {
110
+ if (state.rect) {
111
+ const base = isVertical.value ? state.rect.height : state.rect.width;
112
+ return base - size.value * childCount.value;
113
+ }
114
+ return 0;
115
+ });
116
+ const activePagination = computed(() => (state.active + childCount.value) % childCount.value);
117
+ const getStyle = () => {
118
+ let offset = 0;
119
+ offset = state.offset;
120
+ state.style = {
121
+ transitionDuration: `${state.moving ? 0 : props.duration}ms`,
122
+ transform: `translate${isVertical.value ? "Y" : "X"}(${offset}px)`,
123
+ [isVertical.value ? "height" : "width"]: `${size.value * childCount.value}px`,
124
+ [isVertical.value ? "width" : "height"]: `${isVertical.value ? state.width : state.height}px`
96
125
  };
97
- }, U = (t) => {
98
- var m;
99
- let o = [];
100
- const u = e.childrenVNode.length;
101
- let r = (m = p == null ? void 0 : p.default) == null ? void 0 : m.call(p);
102
- if (r = r.filter((a) => a.children && Array.isArray(a.children)), r.forEach((a) => {
103
- o = o.concat(a.children);
104
- }), !u)
105
- e.childrenVNode = o.slice(), t.proxy && e.children.push(t.proxy);
106
- else if (u > o.length)
107
- e.children = e.children.filter((a) => t.proxy !== a);
108
- else if (u < o.length) {
109
- for (let a = 0; a < u; a++)
110
- if (o[a].key !== e.childrenVNode[a].key) {
111
- t.proxy && e.children.splice(a, 0, t.proxy), t.vnode && e.childrenVNode.splice(a, 0, t.vnode);
112
- break;
126
+ };
127
+ const relation = (child) => {
128
+ var _a;
129
+ let children = [];
130
+ const childrenVNodeLen = state.childrenVNode.length;
131
+ let slot = (_a = slots == null ? void 0 : slots.default) == null ? void 0 : _a.call(slots);
132
+ slot = slot.filter((item) => item.children && Array.isArray(item.children));
133
+ slot.forEach((item) => {
134
+ children = children.concat(item.children);
135
+ });
136
+ if (!childrenVNodeLen) {
137
+ state.childrenVNode = children.slice();
138
+ child.proxy && state.children.push(child.proxy);
139
+ } else {
140
+ if (childrenVNodeLen > children.length) {
141
+ state.children = state.children.filter((item) => child.proxy !== item);
142
+ } else if (childrenVNodeLen < children.length) {
143
+ for (let i = 0; i < childrenVNodeLen; i++) {
144
+ if (children[i].key !== state.childrenVNode[i].key) {
145
+ child.proxy && state.children.splice(i, 0, child.proxy);
146
+ child.vnode && state.childrenVNode.splice(i, 0, child.vnode);
147
+ break;
148
+ }
113
149
  }
114
- u !== o.length && (t.proxy && e.children.push(t.proxy), t.vnode && e.childrenVNode.push(t.vnode));
115
- } else
116
- e.childrenVNode = o.slice(), t.proxy && e.children.push(t.proxy);
117
- }, z = (t, o = 0) => {
118
- let u = t * d.value;
119
- n.loop || (u = Math.min(u, -T.value));
120
- let r = o - u;
121
- return n.loop || (r = B(r, T.value, 0)), r;
122
- }, W = (t) => {
123
- const { active: o } = e;
124
- return t ? n.loop ? B(o + t, -1, i.value) : B(o + t, 0, i.value - 1) : o;
125
- }, g = ({ pace: t = 0, offset: o = 0, isEmit: u = !1 }) => {
126
- if (i.value <= 1)
150
+ if (childrenVNodeLen !== children.length) {
151
+ child.proxy && state.children.push(child.proxy);
152
+ child.vnode && state.childrenVNode.push(child.vnode);
153
+ }
154
+ } else {
155
+ state.childrenVNode = children.slice();
156
+ child.proxy && state.children.push(child.proxy);
157
+ }
158
+ }
159
+ };
160
+ const getOffset = (active, offset = 0) => {
161
+ let currentPosition = active * size.value;
162
+ if (!props.loop) {
163
+ currentPosition = Math.min(currentPosition, -minOffset.value);
164
+ }
165
+ let targetOffset = offset - currentPosition;
166
+ if (!props.loop) {
167
+ targetOffset = clamp(targetOffset, minOffset.value, 0);
168
+ }
169
+ return targetOffset;
170
+ };
171
+ const getActive = (pace) => {
172
+ const { active } = state;
173
+ if (pace) {
174
+ if (props.loop) {
175
+ return clamp(active + pace, -1, childCount.value);
176
+ }
177
+ return clamp(active + pace, 0, childCount.value - 1);
178
+ }
179
+ return active;
180
+ };
181
+ const move = ({ pace = 0, offset = 0, isEmit = false }) => {
182
+ if (childCount.value <= 1)
127
183
  return;
128
- const { active: r } = e, m = W(t), a = z(m, o);
129
- if (n.loop) {
130
- if (e.children[0] && a !== T.value) {
131
- const V = a < T.value;
132
- e.children[0].setOffset(V ? A.value : 0);
184
+ const { active } = state;
185
+ const targetActive = getActive(pace);
186
+ const targetOffset = getOffset(targetActive, offset);
187
+ if (props.loop) {
188
+ if (state.children[0] && targetOffset !== minOffset.value) {
189
+ const rightBound = targetOffset < minOffset.value;
190
+ state.children[0].setOffset(rightBound ? trackSize.value : 0);
133
191
  }
134
- if (e.children[i.value - 1] && a !== 0) {
135
- const V = a > 0;
136
- e.children[i.value - 1].setOffset(V ? -A.value : 0);
192
+ if (state.children[childCount.value - 1] && targetOffset !== 0) {
193
+ const leftBound = targetOffset > 0;
194
+ state.children[childCount.value - 1].setOffset(leftBound ? -trackSize.value : 0);
137
195
  }
138
196
  }
139
- e.active = m, e.offset = a, u && r !== e.active && c("change", O.value), $();
140
- }, C = () => {
141
- e.moving = !0, e.active <= -1 && g({ pace: i.value }), e.active >= i.value && g({ pace: -i.value });
142
- }, y = () => {
143
- e.autoplayTimer && clearTimeout(e.autoplayTimer);
144
- }, F = (t) => {
145
- C(), f.reset(), k(() => {
146
- k(() => {
147
- e.moving = !1, g({
148
- pace: t,
149
- isEmit: !0
197
+ state.active = targetActive;
198
+ state.offset = targetOffset;
199
+ if (isEmit && active !== state.active) {
200
+ emit("change", activePagination.value);
201
+ }
202
+ getStyle();
203
+ };
204
+ const resettPosition = () => {
205
+ state.moving = true;
206
+ if (state.active <= -1) {
207
+ move({ pace: childCount.value });
208
+ }
209
+ if (state.active >= childCount.value) {
210
+ move({ pace: -childCount.value });
211
+ }
212
+ };
213
+ const stopAutoPlay = () => {
214
+ if (state.autoplayTimer) {
215
+ clearTimeout(state.autoplayTimer);
216
+ }
217
+ };
218
+ const jump = (pace) => {
219
+ resettPosition();
220
+ touch.reset();
221
+ requestAniFrame(() => {
222
+ requestAniFrame(() => {
223
+ state.moving = false;
224
+ move({
225
+ pace,
226
+ isEmit: true
150
227
  });
151
228
  });
152
229
  });
153
- }, x = () => {
154
- F(-1);
155
- }, I = () => {
156
- F(1);
157
- }, G = (t) => {
158
- C(), f.reset(), k(() => {
159
- e.moving = !1;
160
- let o;
161
- n.loop && i.value === t ? o = e.active === 0 ? 0 : t : o = t % i.value, g({
162
- pace: o - e.active,
163
- isEmit: !0
230
+ };
231
+ const prev = () => {
232
+ jump(-1);
233
+ };
234
+ const next = () => {
235
+ jump(1);
236
+ };
237
+ const to = (index) => {
238
+ resettPosition();
239
+ touch.reset();
240
+ requestAniFrame(() => {
241
+ state.moving = false;
242
+ let targetIndex;
243
+ if (props.loop && childCount.value === index) {
244
+ targetIndex = state.active === 0 ? 0 : index;
245
+ } else {
246
+ targetIndex = index % childCount.value;
247
+ }
248
+ move({
249
+ pace: targetIndex - state.active,
250
+ isEmit: true
164
251
  });
165
252
  });
166
- }, w = () => {
167
- n.autoPlay <= 0 || i.value <= 1 || (y(), e.autoplayTimer = setTimeout(() => {
168
- I(), w();
169
- }, Number(n.autoPlay)));
170
- }, X = (t = +n.initPage) => {
171
- y(), e.rect = N.value.getBoundingClientRect(), t = Math.min(i.value - 1, t), e.width = n.width ? +n.width : e.rect.width, e.height = n.height ? +n.height : e.rect.height, e.active = t, e.offset = z(e.active), e.moving = !0, $(), w();
172
- }, H = (t) => {
173
- n.isPreventDefault && t.preventDefault(), n.isStopPropagation && t.stopPropagation(), n.touchable && (f.start(t), e.touchTime = Date.now(), y(), C());
174
- }, J = (t) => {
175
- n.touchable && e.moving && (f.move(t), D.value && g({
176
- offset: h.value
177
- }));
178
- }, K = (t) => {
179
- if (!n.touchable || !e.moving)
253
+ };
254
+ const autoplay = () => {
255
+ if (props.autoPlay <= 0 || childCount.value <= 1)
180
256
  return;
181
- const o = h.value / (Date.now() - e.touchTime);
182
- if ((Math.abs(o) > 0.3 || Math.abs(h.value) > +(d.value / 2).toFixed(2)) && D.value) {
183
- let r = 0;
184
- const m = l.value ? f.offsetY.value : f.offsetX.value;
185
- n.loop ? r = m > 0 ? h.value > 0 ? -1 : 1 : 0 : r = -Math[h.value > 0 ? "ceil" : "floor"](h.value / d.value), g({
186
- pace: r,
187
- isEmit: !0
257
+ stopAutoPlay();
258
+ state.autoplayTimer = setTimeout(() => {
259
+ next();
260
+ autoplay();
261
+ }, Number(props.autoPlay));
262
+ };
263
+ const init = (active = +props.initPage) => {
264
+ stopAutoPlay();
265
+ state.rect = container.value.getBoundingClientRect();
266
+ active = Math.min(childCount.value - 1, active);
267
+ state.width = props.width ? +props.width : state.rect.width;
268
+ state.height = props.height ? +props.height : state.rect.height;
269
+ state.active = active;
270
+ state.offset = getOffset(state.active);
271
+ state.moving = true;
272
+ getStyle();
273
+ autoplay();
274
+ };
275
+ const onTouchStart = (e) => {
276
+ if (props.isPreventDefault)
277
+ e.preventDefault();
278
+ if (props.isStopPropagation)
279
+ e.stopPropagation();
280
+ if (!props.touchable)
281
+ return;
282
+ touch.start(e);
283
+ state.touchTime = Date.now();
284
+ stopAutoPlay();
285
+ resettPosition();
286
+ };
287
+ const onTouchMove = (e) => {
288
+ if (props.touchable && state.moving) {
289
+ touch.move(e);
290
+ if (isCorrectDirection.value) {
291
+ move({
292
+ offset: delTa.value
293
+ });
294
+ }
295
+ }
296
+ };
297
+ const onTouchEnd = (e) => {
298
+ if (!props.touchable || !state.moving)
299
+ return;
300
+ const speed = delTa.value / (Date.now() - state.touchTime);
301
+ const isShouldMove = Math.abs(speed) > 0.3 || Math.abs(delTa.value) > +(size.value / 2).toFixed(2);
302
+ if (isShouldMove && isCorrectDirection.value) {
303
+ let pace = 0;
304
+ const offset = isVertical.value ? touch.offsetY.value : touch.offsetX.value;
305
+ if (props.loop) {
306
+ pace = offset > 0 ? delTa.value > 0 ? -1 : 1 : 0;
307
+ } else {
308
+ pace = -Math[delTa.value > 0 ? "ceil" : "floor"](delTa.value / size.value);
309
+ }
310
+ move({
311
+ pace,
312
+ isEmit: true
188
313
  });
189
- } else
190
- h.value && g({ pace: 0 });
191
- e.moving = !1, $(), w();
314
+ } else if (delTa.value) {
315
+ move({ pace: 0 });
316
+ }
317
+ state.moving = false;
318
+ getStyle();
319
+ autoplay();
192
320
  };
193
- return _("parent", {
194
- props: n,
195
- size: d,
196
- relation: U
197
- }), ue({
198
- prev: x,
199
- next: I,
200
- to: G
201
- }), ee(() => {
202
- y();
203
- }), te(() => {
204
- y();
205
- }), E(
206
- () => n.initPage,
207
- (t) => {
208
- Y(() => {
209
- X(Number(t));
321
+ provide("parent", {
322
+ props,
323
+ size,
324
+ relation
325
+ });
326
+ useExpose({
327
+ prev,
328
+ next,
329
+ to
330
+ });
331
+ onDeactivated(() => {
332
+ stopAutoPlay();
333
+ });
334
+ onBeforeUnmount(() => {
335
+ stopAutoPlay();
336
+ });
337
+ watch(
338
+ () => props.initPage,
339
+ (val) => {
340
+ nextTick(() => {
341
+ init(Number(val));
210
342
  });
211
343
  }
212
- ), E(
213
- () => e.children.length,
344
+ );
345
+ watch(
346
+ () => state.children.length,
214
347
  () => {
215
- Y(() => {
216
- X();
348
+ nextTick(() => {
349
+ init();
217
350
  });
218
351
  }
219
- ), E(
220
- () => n.autoPlay,
221
- (t) => {
222
- t > 0 ? w() : y();
352
+ );
353
+ watch(
354
+ () => props.autoPlay,
355
+ (val) => {
356
+ val > 0 ? autoplay() : stopAutoPlay();
223
357
  }
224
- ), {
225
- state: e,
226
- classes: v,
227
- classesInner: q,
228
- classesPagination: R,
229
- container: N,
230
- activePagination: O,
231
- onTouchStart: H,
232
- onTouchMove: J,
233
- onTouchEnd: K
358
+ );
359
+ return {
360
+ state,
361
+ classes,
362
+ classesInner,
363
+ classesPagination,
364
+ container,
365
+ activePagination,
366
+ onTouchStart,
367
+ onTouchMove,
368
+ onTouchEnd
234
369
  };
235
370
  }
236
371
  });
237
- function ve(n, c, p, N, e, f) {
238
- return P(), b("view", {
372
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
373
+ return openBlock(), createElementBlock("view", {
239
374
  ref: "container",
240
- class: S(n.classes),
241
- onTouchstart: c[0] || (c[0] = (...v) => n.onTouchStart && n.onTouchStart(...v)),
242
- onTouchmove: c[1] || (c[1] = (...v) => n.onTouchMove && n.onTouchMove(...v)),
243
- onTouchend: c[2] || (c[2] = (...v) => n.onTouchEnd && n.onTouchEnd(...v)),
244
- onTouchcancel: c[3] || (c[3] = (...v) => n.onTouchEnd && n.onTouchEnd(...v))
375
+ class: normalizeClass(_ctx.classes),
376
+ onTouchstart: _cache[0] || (_cache[0] = (...args) => _ctx.onTouchStart && _ctx.onTouchStart(...args)),
377
+ onTouchmove: _cache[1] || (_cache[1] = (...args) => _ctx.onTouchMove && _ctx.onTouchMove(...args)),
378
+ onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args)),
379
+ onTouchcancel: _cache[3] || (_cache[3] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args))
245
380
  }, [
246
- ne("view", {
247
- class: S(n.classesInner),
248
- style: L(n.state.style)
381
+ createElementVNode("view", {
382
+ class: normalizeClass(_ctx.classesInner),
383
+ style: normalizeStyle(_ctx.state.style)
249
384
  }, [
250
- j(n.$slots, "default")
385
+ renderSlot(_ctx.$slots, "default")
251
386
  ], 6),
252
- j(n.$slots, "page"),
253
- n.paginationVisible && !n.$slots.page ? (P(), b("view", {
387
+ renderSlot(_ctx.$slots, "page"),
388
+ _ctx.paginationVisible && !_ctx.$slots.page ? (openBlock(), createElementBlock("view", {
254
389
  key: 0,
255
- class: S(n.classesPagination)
390
+ class: normalizeClass(_ctx.classesPagination)
256
391
  }, [
257
- (P(!0), b(oe, null, ae(n.state.children.length, (v, l) => (P(), b("i", {
258
- style: L({
259
- backgroundColor: n.activePagination === l ? n.paginationColor : "#ddd"
260
- }),
261
- class: S({ active: n.activePagination === l }),
262
- key: l
263
- }, null, 6))), 128))
264
- ], 2)) : ie("", !0)
392
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.state.children.length, (item, index) => {
393
+ return openBlock(), createElementBlock("i", {
394
+ style: normalizeStyle({
395
+ backgroundColor: _ctx.activePagination === index ? _ctx.paginationColor : "#ddd"
396
+ }),
397
+ class: normalizeClass({ active: _ctx.activePagination === index }),
398
+ key: index
399
+ }, null, 6);
400
+ }), 128))
401
+ ], 2)) : createCommentVNode("", true)
265
402
  ], 34);
266
403
  }
267
- const we = /* @__PURE__ */ se(fe, [["render", ve]]);
404
+ const Swiper = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
268
405
  export {
269
- we as default
406
+ Swiper as default
270
407
  };
@@ -1,39 +1,55 @@
1
- import { inject as p, getCurrentInstance as c, reactive as m, computed as a, onUnmounted as u, openBlock as d, createElementBlock as $, normalizeClass as h, normalizeStyle as z, renderSlot as _ } from "vue";
2
- import { c as x } from "./component-234624bc.js";
3
- import { u as y } from "./index-fadb0974.js";
4
- import { _ as C } from "./_plugin-vue_export-helper-dad06003.js";
1
+ import { inject, getCurrentInstance, reactive, computed, onUnmounted, openBlock, createElementBlock, normalizeClass, normalizeStyle, renderSlot } from "vue";
2
+ import { c as createComponent } from "./component-81a4c1d0.js";
3
+ import { u as useExpose } from "./index-79c5dc33.js";
4
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
5
5
  import "../locale/lang";
6
- const { create: v, componentName: w } = x("swiper-item"), S = v({
7
- setup(s, { slots: l }) {
8
- const e = p("parent");
9
- e.relation(c());
10
- const o = m({
6
+ const { create, componentName } = createComponent("swiper-item");
7
+ const _sfc_main = create({
8
+ setup(props, { slots }) {
9
+ const parent = inject("parent");
10
+ parent["relation"](getCurrentInstance());
11
+ const state = reactive({
11
12
  offset: 0
12
- }), r = a(() => ({
13
- [w]: !0
14
- })), n = a(() => {
15
- const t = {}, i = e == null ? void 0 : e.props.direction;
16
- return e != null && e.size.value && (t[i === "horizontal" ? "width" : "height"] = `${e == null ? void 0 : e.size.value}px`), o.offset && (t.transform = `translate${i === "horizontal" ? "X" : "Y"}(${o.offset}px)`), t;
17
- }), f = (t) => {
18
- o.offset = t;
13
+ });
14
+ const classes = computed(() => {
15
+ const prefixCls = componentName;
16
+ return {
17
+ [prefixCls]: true
18
+ };
19
+ });
20
+ const style = computed(() => {
21
+ const style2 = {};
22
+ const direction = parent == null ? void 0 : parent.props.direction;
23
+ if (parent == null ? void 0 : parent.size.value) {
24
+ style2[direction === "horizontal" ? "width" : "height"] = `${parent == null ? void 0 : parent.size.value}px`;
25
+ }
26
+ if (state.offset) {
27
+ style2["transform"] = `translate${direction === "horizontal" ? "X" : "Y"}(${state.offset}px)`;
28
+ }
29
+ return style2;
30
+ });
31
+ const setOffset = (offset) => {
32
+ state.offset = offset;
19
33
  };
20
- return u(() => {
21
- e.relation(c(), "unmount");
22
- }), y({ setOffset: f }), {
23
- style: n,
24
- classes: r
34
+ onUnmounted(() => {
35
+ parent["relation"](getCurrentInstance(), "unmount");
36
+ });
37
+ useExpose({ setOffset });
38
+ return {
39
+ style,
40
+ classes
25
41
  };
26
42
  }
27
43
  });
28
- function g(s, l, e, o, r, n) {
29
- return d(), $("view", {
30
- class: h(s.classes),
31
- style: z(s.style)
44
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
45
+ return openBlock(), createElementBlock("view", {
46
+ class: normalizeClass(_ctx.classes),
47
+ style: normalizeStyle(_ctx.style)
32
48
  }, [
33
- _(s.$slots, "default")
49
+ renderSlot(_ctx.$slots, "default")
34
50
  ], 6);
35
51
  }
36
- const N = /* @__PURE__ */ C(S, [["render", g]]);
52
+ const SwiperItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
37
53
  export {
38
- N as default
54
+ SwiperItem as default
39
55
  };