@nutui/nutui 3.1.22-beta.5 → 3.1.23-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +3 -4
  3. package/dist/nutui.es.js +20412 -4214
  4. package/dist/nutui.umd.js +20518 -4216
  5. package/dist/packages/_es/ActionSheet.js +149 -17
  6. package/dist/packages/_es/Address.js +535 -110
  7. package/dist/packages/_es/AddressList.js +615 -113
  8. package/dist/packages/_es/Animate.js +59 -17
  9. package/dist/packages/_es/Audio.js +257 -53
  10. package/dist/packages/_es/AudioOperate.js +100 -13
  11. package/dist/packages/_es/Avatar.js +162 -38
  12. package/dist/packages/_es/AvatarGroup.js +73 -14
  13. package/dist/packages/_es/BackTop.js +156 -43
  14. package/dist/packages/_es/Badge.js +86 -14
  15. package/dist/packages/_es/Barrage.js +120 -41
  16. package/dist/packages/_es/Button.js +128 -23
  17. package/dist/packages/_es/Calendar.js +246 -30
  18. package/dist/packages/_es/CalendarItem.js +1 -1
  19. package/dist/packages/_es/Card.js +107 -10
  20. package/dist/packages/_es/Cascader.js +496 -147
  21. package/dist/packages/_es/Category.js +58 -15
  22. package/dist/packages/_es/CategoryPane.js +111 -11
  23. package/dist/packages/_es/Cell.js +108 -21
  24. package/dist/packages/_es/CellGroup.js +44 -9
  25. package/dist/packages/_es/Checkbox.js +134 -29
  26. package/dist/packages/_es/CheckboxGroup.js +79 -29
  27. package/dist/packages/_es/CircleProgress.js +150 -28
  28. package/dist/packages/_es/Col.js +56 -14
  29. package/dist/packages/_es/Collapse.js +109 -32
  30. package/dist/packages/_es/CollapseItem.js +253 -59
  31. package/dist/packages/_es/Comment.js +434 -64
  32. package/dist/packages/_es/ConfigProvider.js +20 -8
  33. package/dist/packages/_es/CountDown.js +238 -56
  34. package/dist/packages/_es/CountUp.js +539 -140
  35. package/dist/packages/_es/DatePicker.js +315 -98
  36. package/dist/packages/_es/Dialog.js +289 -60
  37. package/dist/packages/_es/Divider.js +65 -13
  38. package/dist/packages/_es/Drag.js +197 -56
  39. package/dist/packages/_es/Ecard.js +159 -24
  40. package/dist/packages/_es/Elevator.js +255 -58
  41. package/dist/packages/_es/Ellipsis.js +200 -58
  42. package/dist/packages/_es/Empty.js +71 -12
  43. package/dist/packages/_es/FixedNav.js +122 -15
  44. package/dist/packages/_es/Form.js +151 -64
  45. package/dist/packages/_es/FormItem.js +114 -15
  46. package/dist/packages/_es/Grid.js +6 -5
  47. package/dist/packages/_es/GridItem.js +144 -33
  48. package/dist/packages/_es/Icon.js +40 -15
  49. package/dist/packages/_es/Image.js +137 -26
  50. package/dist/packages/_es/ImagePreview.js +547 -76
  51. package/dist/packages/_es/Indicator.js +62 -15
  52. package/dist/packages/_es/InfiniteLoading.js +249 -57
  53. package/dist/packages/_es/Input.js +433 -51
  54. package/dist/packages/_es/InputNumber.js +160 -41
  55. package/dist/packages/_es/Layout.js +5 -4
  56. package/dist/packages/_es/List.js +106 -18
  57. package/dist/packages/_es/Menu.js +168 -44
  58. package/dist/packages/_es/MenuItem.js +173 -37
  59. package/dist/packages/_es/Navbar.js +192 -30
  60. package/dist/packages/_es/NoticeBar.js +380 -74
  61. package/dist/packages/_es/Notify.js +227 -72
  62. package/dist/packages/_es/NumberKeyboard.js +272 -41
  63. package/dist/packages/_es/OldPicker.js +457 -130
  64. package/dist/packages/_es/OverLay.js +98 -24
  65. package/dist/packages/_es/Pagination.js +157 -39
  66. package/dist/packages/_es/Picker.js +454 -129
  67. package/dist/packages/_es/Popover.js +957 -318
  68. package/dist/packages/_es/Popup.js +299 -55
  69. package/dist/packages/_es/Price.js +118 -16
  70. package/dist/packages/_es/Progress.js +146 -14
  71. package/dist/packages/_es/PullRefresh.js +339 -84
  72. package/dist/packages/_es/Radio.js +90 -22
  73. package/dist/packages/_es/RadioGroup.js +37 -8
  74. package/dist/packages/_es/Range.js +408 -83
  75. package/dist/packages/_es/Rate.js +192 -36
  76. package/dist/packages/_es/Row.js +64 -22
  77. package/dist/packages/_es/SearchBar.js +238 -37
  78. package/dist/packages/_es/ShortPassword.js +225 -35
  79. package/dist/packages/_es/SideNavBar.js +81 -24
  80. package/dist/packages/_es/SideNavBarItem.js +46 -11
  81. package/dist/packages/_es/Signature.js +160 -41
  82. package/dist/packages/_es/Skeleton.js +136 -20
  83. package/dist/packages/_es/Sku.js +491 -84
  84. package/dist/packages/_es/Step.js +115 -20
  85. package/dist/packages/_es/Steps.js +53 -18
  86. package/dist/packages/_es/Sticky.js +138 -53
  87. package/dist/packages/_es/SubSideNavBar.js +82 -17
  88. package/dist/packages/_es/Swipe.js +178 -41
  89. package/dist/packages/_es/Swiper.js +433 -121
  90. package/dist/packages/_es/SwiperItem.js +53 -22
  91. package/dist/packages/_es/Switch.js +116 -21
  92. package/dist/packages/_es/TabPane.js +39 -12
  93. package/dist/packages/_es/Tabbar.js +72 -17
  94. package/dist/packages/_es/TabbarItem.js +151 -29
  95. package/dist/packages/_es/Table.js +178 -18
  96. package/dist/packages/_es/Tabs.js +202 -43
  97. package/dist/packages/_es/Tag.js +97 -20
  98. package/dist/packages/_es/TextArea.js +160 -42
  99. package/dist/packages/_es/TimeDetail.js +79 -18
  100. package/dist/packages/_es/TimePannel.js +48 -14
  101. package/dist/packages/_es/TimeSelect.js +112 -15
  102. package/dist/packages/_es/Toast.js +310 -71
  103. package/dist/packages/_es/Uploader.js +455 -104
  104. package/dist/packages/_es/Video.js +332 -74
  105. package/dist/packages/_es/common.js +128 -38
  106. package/dist/packages/_es/component.js +76 -35
  107. package/dist/packages/_es/index.js +6 -5
  108. package/dist/packages/_es/index2.js +30 -9
  109. package/dist/packages/_es/index3.js +8 -6
  110. package/dist/packages/_es/index4.js +64 -13
  111. package/dist/packages/_es/index5.js +780 -164
  112. package/dist/packages/_es/plugin-vue_export-helper.js +8 -7
  113. package/dist/packages/_es/pxCheck.js +5 -3
  114. package/dist/packages/_es/raf.js +15 -8
  115. package/dist/packages/imagepreview/index.scss +6 -1
  116. package/dist/packages/locale/lang/baseLang.js +3 -3
  117. package/dist/packages/locale/lang/en-US.js +105 -5
  118. package/dist/packages/locale/lang/id-ID.js +105 -5
  119. package/dist/packages/locale/lang/index.js +38 -16
  120. package/dist/packages/locale/lang/zh-CN.js +105 -5
  121. package/dist/packages/locale/lang/zh-TW.js +105 -5
  122. package/dist/packages/picker/index.scss +13 -0
  123. package/dist/smartips/attributes.json +8 -0
  124. package/dist/smartips/tags.json +3 -1
  125. package/dist/smartips/web-types.json +19 -1
  126. package/dist/style.css +1 -1
  127. package/dist/style.es.js +1 -1
  128. package/dist/styles/themes/default.scss +49 -49
  129. package/dist/styles/themes/jdb.scss +49 -49
  130. package/dist/styles/themes/jdt.scss +49 -49
  131. package/dist/styles/variables-jdb.scss +4 -1
  132. package/dist/styles/variables-jdt.scss +4 -1
  133. package/dist/styles/variables.scss +1 -1
  134. package/dist/types/__VUE/actionsheet/index.vue.d.ts +3 -3
  135. package/dist/types/__VUE/address/index.vue.d.ts +4 -4
  136. package/dist/types/__VUE/calendar/index.vue.d.ts +1 -1
  137. package/dist/types/__VUE/cascader/index.vue.d.ts +3 -3
  138. package/dist/types/__VUE/cell/index.vue.d.ts +2 -2
  139. package/dist/types/__VUE/checkbox/index.vue.d.ts +2 -2
  140. package/dist/types/__VUE/collapse/index.vue.d.ts +2 -2
  141. package/dist/types/__VUE/datepicker/index.vue.d.ts +2 -2
  142. package/dist/types/__VUE/dialog/index.vue.d.ts +2 -2
  143. package/dist/types/__VUE/ecard/index.vue.d.ts +2 -2
  144. package/dist/types/__VUE/fixednav/index.vue.d.ts +2 -2
  145. package/dist/types/__VUE/grid/index.vue.d.ts +3 -3
  146. package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +95 -0
  147. package/dist/types/__VUE/imagepreview/index.vue.d.ts +23 -25
  148. package/dist/types/__VUE/infiniteloading/index.vue.d.ts +6 -6
  149. package/dist/types/__VUE/input/index.vue.d.ts +2 -2
  150. package/dist/types/__VUE/menu/index.vue.d.ts +4 -4
  151. package/dist/types/__VUE/menuitem/index.vue.d.ts +1 -1
  152. package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +2 -2
  153. package/dist/types/__VUE/oldpicker/index.vue.d.ts +3 -3
  154. package/dist/types/__VUE/picker/index.vue.d.ts +3 -3
  155. package/dist/types/__VUE/popover/index.vue.d.ts +6 -6
  156. package/dist/types/__VUE/popup/index.vue.d.ts +4 -4
  157. package/dist/types/__VUE/range/index.vue.d.ts +1 -1
  158. package/dist/types/__VUE/rate/index.vue.d.ts +2 -2
  159. package/dist/types/__VUE/searchbar/index.vue.d.ts +2 -2
  160. package/dist/types/__VUE/shortpassword/index.vue.d.ts +1 -1
  161. package/dist/types/__VUE/sku/index.vue.d.ts +3 -3
  162. package/dist/types/__VUE/swipe/index.vue.d.ts +2 -2
  163. package/dist/types/__VUE/switch/index.vue.d.ts +2 -2
  164. package/dist/types/__VUE/tabbar/index.vue.d.ts +2 -2
  165. package/dist/types/__VUE/textarea/index.vue.d.ts +2 -2
  166. package/dist/types/__VUE/toast/index.vue.d.ts +1 -1
  167. package/dist/types/index.d.ts +1 -1
  168. package/package.json +1 -2
@@ -1,137 +1,449 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.22-beta.5 Fri Jun 24 2022 15:10:09 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.23-beta.1 Mon Jun 27 2022 21:39:05 GMT+0800 (中国标准时间)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
- import { reactive as e, ref as t, computed as a, provide as o, onDeactivated as i, onBeforeUnmount as l, watch as n, nextTick as r, openBlock as c, createElementBlock as u, normalizeClass as s, createElementVNode as h, normalizeStyle as d, renderSlot as v, Fragment as p, renderList as f, createCommentVNode as m } from "vue";
7
- import { c as g } from "./component.js";
8
- import { u as y } from "./index3.js";
9
- import { _ as N } from "./plugin-vue_export-helper.js";
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 { create: w, componentName: T } = g("swiper");
12
- var b = N(w({ props: { width: { type: [Number, String], default: window.innerWidth }, height: { type: [Number, String], default: 0 }, direction: { type: [String], default: "horizontal" }, paginationVisible: { type: Boolean, default: false }, paginationColor: { type: String, default: "#fff" }, loop: { type: Boolean, default: true }, duration: { type: [Number, String], default: 500 }, autoPlay: { type: [Number, String], default: 0 }, initPage: { type: [Number, String], default: 0 }, touchable: { type: Boolean, default: true }, isPreventDefault: { type: Boolean, default: true }, isStopPropagation: { type: Boolean, default: true } }, emits: ["change"], setup(c2, { emit: u2, slots: s2 }) {
13
- const h2 = t(), d2 = e({ active: 0, num: 0, rect: null, width: 0, height: 0, moving: false, offset: 0, touchTime: 0, autoplayTimer: 0, children: [], childrenVNode: [], style: {} }), v2 = function() {
14
- const t2 = e({ startX: 0, startY: 0, deltaX: 0, deltaY: 0, offsetX: 0, offsetY: 0, direction: "" }), a2 = () => {
15
- t2.startX = 0, t2.startY = 0, t2.deltaX = 0, t2.deltaY = 0, t2.offsetX = 0, t2.offsetY = 0, t2.direction = "";
16
- };
17
- return { state: t2, start: (e2) => {
18
- a2(), t2.startX = e2.touches[0].clientX, t2.startY = e2.touches[0].clientY;
19
- }, reset: a2, move: (e2) => {
20
- var a3, o2;
21
- t2.deltaX = e2.touches[0].clientX - t2.startX, t2.deltaY = e2.touches[0].clientY - t2.startY, t2.offsetX = Math.abs(t2.deltaX), t2.offsetY = Math.abs(t2.deltaY), t2.direction || (t2.direction = (a3 = t2.offsetX) > (o2 = t2.offsetY) && a3 > 5 ? "horizontal" : o2 > a3 && o2 > 5 ? "vertical" : "");
22
- } };
23
- }(), p2 = a(() => ({ [T]: true })), f2 = a(() => c2.direction === "vertical"), m2 = a(() => f2.value ? v2.state.deltaY : v2.state.deltaX), g2 = a(() => v2.state.direction === c2.direction), N2 = a(() => d2.children.length), w2 = a(() => d2[f2.value ? "height" : "width"]), b2 = a(() => N2.value * w2.value), x = a(() => {
24
- if (d2.rect) {
25
- return (f2.value ? d2.rect.height : d2.rect.width) - w2.value * N2.value;
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
- return 0;
28
- }), X = a(() => (d2.active + N2.value) % N2.value), Y = () => {
29
- d2.style = { transitionDuration: `${d2.moving ? 0 : c2.duration}ms`, transform: `translate${f2.value ? "Y" : "X"}(${d2.offset}px)`, [f2.value ? "height" : "width"]: w2.value * N2.value + "px", [f2.value ? "width" : "height"]: `${f2.value ? d2.width : d2.height}px` };
30
- }, V = (e2, t2, a2) => Math.min(Math.max(e2, t2), a2), P = (e2) => {
31
- window.requestAnimationFrame.call(window, e2);
32
- }, M = (e2, t2 = 0) => {
33
- let a2 = e2 * w2.value;
34
- c2.loop || (a2 = Math.min(a2, -x.value));
35
- let o2 = t2 - a2;
36
- return c2.loop || (o2 = V(o2, x.value, 0)), o2;
37
- }, S = ({ pace: e2 = 0, offset: t2 = 0, isEmit: a2 = false }) => {
38
- if (N2.value <= 1)
39
- return;
40
- const { active: o2 } = d2, i2 = ((e3) => {
41
- const { active: t3 } = d2;
42
- return e3 ? c2.loop ? V(t3 + e3, -1, N2.value) : V(t3 + e3, 0, N2.value - 1) : t3;
43
- })(e2), l2 = M(i2, t2);
44
- if (c2.loop) {
45
- if (d2.children[0] && l2 !== x.value) {
46
- const e3 = l2 < x.value;
47
- d2.children[0].setOffset(e3 ? b2.value : 0);
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
- if (d2.children[N2.value - 1] && l2 !== 0) {
50
- const e3 = l2 > 0;
51
- d2.children[N2.value - 1].setOffset(e3 ? -b2.value : 0);
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
- d2.active = i2, d2.offset = l2, a2 && o2 !== d2.active && u2("change", X.value), Y();
55
- }, E = () => {
56
- d2.moving = true, d2.active <= -1 && S({ pace: N2.value }), d2.active >= N2.value && S({ pace: -N2.value });
57
- }, $ = () => {
58
- clearTimeout(d2.autoplayTimer);
59
- }, k = () => {
60
- E(), v2.reset(), P(() => {
61
- P(() => {
62
- d2.moving = false, S({ pace: 1, isEmit: true });
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
- }, B = () => {
66
- c2.autoPlay <= 0 || N2.value <= 1 || ($(), d2.autoplayTimer = setTimeout(() => {
67
- k(), B();
68
- }, Number(c2.autoPlay)));
69
- }, D = (e2 = +c2.initPage) => {
70
- $(), d2.rect = h2.value.getBoundingClientRect(), e2 = Math.min(N2.value - 1, e2), d2.width = c2.width ? +c2.width : d2.rect.width, d2.height = c2.height ? +c2.height : d2.rect.height, d2.active = e2, d2.offset = M(d2.active), d2.moving = true, Y(), B();
71
- };
72
- return o("parent", { props: c2, size: w2, relation: (e2) => {
73
- var _a;
74
- let t2 = [], a2 = (_a = s2 == null ? void 0 : s2.default) == null ? void 0 : _a.call(s2);
75
- if (a2 = a2.filter((e3) => e3.children && Array.isArray(e3.children)), a2.forEach((e3) => {
76
- t2 = t2.concat(e3.children);
77
- }), d2.childrenVNode.length)
78
- if (d2.childrenVNode.length > t2.length)
79
- d2.children = d2.children.filter((t3) => e2.proxy !== t3);
80
- else if (d2.childrenVNode.length < t2.length) {
81
- for (let a3 = 0; a3 < d2.childrenVNode.length; a3++)
82
- if (t2[a3].key !== d2.childrenVNode[a3].key) {
83
- e2.proxy && d2.children.splice(a3, 0, e2.proxy), e2.vnode && d2.childrenVNode.splice(a3, 0, e2.vnode);
84
- break;
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
- d2.childrenVNode.length !== t2.length && (e2.proxy && d2.children.push(e2.proxy), e2.vnode && d2.childrenVNode.push(e2.vnode));
87
- } else
88
- d2.childrenVNode = t2.slice(), e2.proxy && d2.children.push(e2.proxy);
89
- else
90
- d2.childrenVNode = t2.slice(), e2.proxy && d2.children.push(e2.proxy);
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
- }, next: k, to: (e2) => {
98
- E(), v2.reset(), P(() => {
99
- P(() => {
100
- let t2;
101
- d2.moving = false, t2 = c2.loop && N2.value === e2 ? d2.active === 0 ? 0 : e2 : e2 % N2.value, S({ pace: t2 - d2.active, isEmit: true });
380
+ onBeforeUnmount(() => {
381
+ stopAutoPlay();
382
+ });
383
+ watch(() => props.initPage, (val) => {
384
+ nextTick(() => {
385
+ init(Number(val));
102
386
  });
103
387
  });
104
- } }), i(() => {
105
- $();
106
- }), l(() => {
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
- }), n(() => d2.children.length, () => {
113
- r(() => {
114
- D();
393
+ watch(() => props.autoPlay, (val) => {
394
+ val > 0 ? autoplay() : stopAutoPlay();
115
395
  });
116
- }), n(() => c2.autoPlay, (e2) => {
117
- e2 > 0 ? B() : $();
118
- }), { state: d2, classes: p2, container: h2, componentName: T, isVertical: f2, slots: s2, activePagination: X, onTouchStart: (e2) => {
119
- c2.isPreventDefault && e2.preventDefault(), c2.isStopPropagation && e2.stopPropagation(), c2.touchable && (v2.start(e2), d2.touchTime = Date.now(), $(), E());
120
- }, onTouchMove: (e2) => {
121
- c2.touchable && d2.moving && (v2.move(e2), g2.value && S({ offset: m2.value }));
122
- }, onTouchEnd: (e2) => {
123
- if (!c2.touchable || !d2.moving)
124
- return;
125
- const t2 = m2.value / (Date.now() - d2.touchTime);
126
- if ((Math.abs(t2) > 0.3 || Math.abs(m2.value) > +(w2.value / 2).toFixed(2)) && g2.value) {
127
- let e3 = 0;
128
- const t3 = f2.value ? v2.state.offsetY : v2.state.offsetX;
129
- e3 = c2.loop ? t3 > 0 ? m2.value > 0 ? -1 : 1 : 0 : -Math[m2.value > 0 ? "ceil" : "floor"](m2.value / w2.value), S({ pace: e3, isEmit: true });
130
- } else
131
- m2.value && S({ pace: 0 });
132
- d2.moving = false, Y(), B();
133
- } };
134
- } }), [["render", function(e2, t2, a2, o2, i2, l2) {
135
- return c(), u("view", { ref: "container", class: s(e2.classes), onTouchstart: t2[0] || (t2[0] = (...t3) => e2.onTouchStart && e2.onTouchStart(...t3)), onTouchmove: t2[1] || (t2[1] = (...t3) => e2.onTouchMove && e2.onTouchMove(...t3)), onTouchend: t2[2] || (t2[2] = (...t3) => e2.onTouchEnd && e2.onTouchEnd(...t3)), onTouchcancel: t2[3] || (t2[3] = (...t3) => e2.onTouchEnd && e2.onTouchEnd(...t3)) }, [h("view", { class: s({ [`${e2.componentName}-inner`]: true, [`${e2.componentName}-vertical`]: e2.isVertical }), style: d(e2.state.style) }, [v(e2.$slots, "default")], 6), v(e2.$slots, "page"), e2.paginationVisible && !e2.slots.page ? (c(), u("view", { key: 0, class: s({ [`${e2.componentName}-pagination`]: true, [`${e2.componentName}-pagination-vertical`]: e2.isVertical }) }, [(c(true), u(p, null, f(e2.state.children.length, (t3, a3) => (c(), u("i", { style: d({ backgroundColor: e2.activePagination === a3 ? e2.paginationColor : "#ddd" }), class: s({ active: e2.activePagination === a3 }), key: a3 }, null, 6))), 128))], 2)) : m("", true)], 34);
136
- }]]);
137
- export { b as default };
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.22-beta.5 Fri Jun 24 2022 15:10:09 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.23-beta.1 Mon Jun 27 2022 21:39:05 GMT+0800 (中国标准时间)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
- import { inject as e, getCurrentInstance as t, reactive as s, computed as o, onUnmounted as r, openBlock as n, createElementBlock as a, normalizeClass as l, normalizeStyle as i, renderSlot as f } from "vue";
7
- import { c as p } from "./component.js";
8
- import { u as m } from "./index3.js";
9
- import { _ as u } from "./plugin-vue_export-helper.js";
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: c, componentName: d } = p("swiper-item");
12
- var h = u(c({ setup(n2, { slots: a2 }) {
13
- const l2 = e("parent");
14
- l2.relation(t());
15
- const i2 = s({ offset: 0 }), f2 = o(() => ({ [d]: true })), p2 = o(() => {
16
- const e2 = {}, t2 = l2 == null ? void 0 : l2.props.direction;
17
- return (l2 == null ? void 0 : l2.size.value) && (e2[t2 === "horizontal" ? "width" : "height"] = `${l2 == null ? void 0 : l2.size.value}px`), i2.offset && (e2.transform = `translate${t2 === "horizontal" ? "X" : "Y"}(${i2.offset}px)`), e2;
18
- });
19
- return r(() => {
20
- l2.relation(t(), "unmount");
21
- }), m({ setOffset: (e2) => {
22
- i2.offset = e2;
23
- } }), { style: p2, classes: f2 };
24
- } }), [["render", function(e2, t2, s2, o2, r2, p2) {
25
- return n(), a("view", { class: l(e2.classes), style: i(e2.style) }, [f(e2.$slots, "default")], 6);
26
- }]]);
27
- export { h as default };
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 };