@nutui/nutui 3.1.22 → 3.1.23-beta.2

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