@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,94 +1,565 @@
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 { toRefs as e, reactive as o, computed as t, watch as i, onMounted as n, resolveComponent as s, openBlock as a, createBlock as l, withCtx as c, createElementVNode as r, withModifiers as p, createElementBlock as u, Fragment as m, renderList as g, createVNode as d, createCommentVNode as h, toDisplayString as f, normalizeStyle as v, render as y, h as w } from "vue";
7
- import { c as b, a as C } from "./component.js";
8
- import x from "./Popup.js";
9
- import T from "./Video.js";
10
- import I from "./Swiper.js";
11
- import S from "./SwiperItem.js";
12
- import j from "./Icon.js";
13
- import { _ as N } from "./plugin-vue_export-helper.js";
6
+ import { reactive, computed, watch, toRefs, resolveComponent, openBlock, createBlock, withCtx, createElementBlock, normalizeStyle, createElementVNode, createCommentVNode, createVNode, ref, onMounted, Fragment, renderList, toDisplayString, render, h } from "vue";
7
+ import { c as createComponent, a as isPromise } from "./component.js";
8
+ import Popup from "./Popup.js";
9
+ import Video from "./Video.js";
10
+ import Swiper from "./Swiper.js";
11
+ import SwiperItem from "./SwiperItem.js";
12
+ import _sfc_main$2 from "./Icon.js";
13
+ import { u as useTouch } from "./index4.js";
14
+ import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
14
15
  import "../locale/lang";
15
16
  import "./OverLay.js";
16
17
  import "./pxCheck.js";
17
18
  import "./index3.js";
18
- const { componentName: k, create: E } = b("imagepreview"), P = E({ props: { show: { type: Boolean, default: false }, images: { type: Array, default: () => [] }, videos: { type: Array, default: () => [] }, contentClose: { type: Boolean, default: true }, initNo: { type: Number, default: 1 }, paginationVisible: { type: Boolean, default: false }, paginationColor: { type: String, default: "#fff" }, autoplay: { type: [Number, String], default: 3e3 }, isWrapTeleport: { type: Boolean, default: false }, showIndex: { type: Boolean, default: true }, closeable: { type: Boolean, default: false }, closeIcon: { type: String, default: "circle-close" }, closeIconPosition: { type: String, default: "top-right" }, beforeClose: Function }, emits: ["close", "change"], components: { [x.name]: x, [T.name]: T, [I.name]: I, [S.name]: S, [j.name]: j }, setup(s2, { emit: a2 }) {
19
- e(s2);
20
- const l2 = o({ showPop: false, active: 1, maxNo: 1, source: { src: "https://storage.jd.com/about/big-final.mp4?Expires=3730193075&AccessKey=3LoYX1dQWa6ZXzQl&Signature=ViMFjz%2BOkBxS%2FY1rjtUVqbopbJI%3D", type: "video/mp4" }, options: { muted: true, controls: true }, eleImg: null, store: { scale: 1, moveable: false }, lastTouchEndTime: 0 }), c2 = t(() => {
21
- let e2 = {};
22
- return s2.closeIconPosition == "top-right" ? e2.right = "10px" : e2.left = "10px", e2;
23
- }), r2 = () => {
24
- if (s2.beforeClose) {
25
- const e2 = s2.beforeClose.apply(null, l2.active);
26
- C(e2) ? e2.then((e3) => {
27
- e3 && p2();
28
- }) : e2 && p2();
29
- } else
30
- p2();
31
- }, p2 = () => {
32
- l2.showPop = false, l2.store.scale = 1, m2(), l2.active = 1, a2("close");
33
- }, u2 = (e2, o2) => Math.hypot(Math.abs(o2.x - e2.x), Math.abs(o2.y - e2.y)), m2 = () => {
34
- l2.eleImg.style.transform = "scale(" + l2.store.scale + ")";
35
- }, g2 = (e2) => {
36
- if (!l2.store.moveable)
37
- return;
38
- const o2 = l2.store;
39
- var t2 = e2.touches, i2 = t2[0], n2 = t2[1];
40
- if (n2) {
41
- const e3 = u2({ x: i2.pageX, y: i2.pageY }, { x: n2.pageX, y: n2.pageY }) / o2.oriDistance;
42
- o2.scale = o2.originScale * e3, o2.scale > 3 && (o2.scale = 3), m2();
19
+ const { componentName: componentName$1, create: create$1 } = createComponent("imagepreviewitem");
20
+ const _sfc_main$1 = create$1({
21
+ props: {
22
+ show: {
23
+ type: Boolean,
24
+ default: false
25
+ },
26
+ initNo: Number,
27
+ image: {
28
+ type: Object,
29
+ default: () => {
30
+ }
31
+ },
32
+ video: {
33
+ type: Array,
34
+ default: () => {
35
+ }
36
+ },
37
+ showIndex: {
38
+ type: Boolean,
39
+ default: true
40
+ },
41
+ rootWidth: {
42
+ type: Number,
43
+ default: 0
44
+ },
45
+ rootHeight: {
46
+ type: Number,
47
+ default: 0
48
+ },
49
+ minZoom: {
50
+ type: Number,
51
+ default: 1 / 3
52
+ },
53
+ maxZoom: {
54
+ type: Number,
55
+ default: 3
43
56
  }
44
- }, d2 = () => {
45
- l2.lastTouchEndTime = new Date().getTime();
46
- const e2 = l2.store;
47
- e2.moveable = false, (e2.scale < 1.1 && e2.scale > 1 || e2.scale < 1) && (e2.scale = 1, m2());
48
- };
49
- return i(() => s2.show, (e2) => {
50
- l2.showPop = e2, l2.eleImg = document.querySelector(".nut-imagepreview"), document.addEventListener("touchmove", g2), document.addEventListener("touchend", d2), document.addEventListener("touchcancel", d2);
51
- }), n(() => {
52
- l2.active = s2.initNo, l2.showPop = s2.show, l2.maxNo = s2.images.length + s2.videos.length;
53
- }), { ...e(l2), slideChangeEnd: function(e2) {
54
- l2.active = e2 + 1, a2("change", l2.active);
55
- }, onClose: r2, closeOnImg: () => {
56
- s2.contentClose && r2();
57
- }, onTouchStart: (e2) => {
58
- if (new Date().getTime() - l2.lastTouchEndTime < 300) {
59
- const e3 = l2.store;
60
- e3.scale > 1 ? e3.scale = 1 : e3.scale == 1 && (e3.scale = 2), m2();
57
+ },
58
+ emits: ["close", "scale"],
59
+ components: {
60
+ [Popup.name]: Popup,
61
+ [Video.name]: Video,
62
+ [Swiper.name]: Swiper,
63
+ [SwiperItem.name]: SwiperItem,
64
+ [_sfc_main$2.name]: _sfc_main$2
65
+ },
66
+ setup(props, { emit }) {
67
+ const state = reactive({
68
+ scale: 1,
69
+ moveX: 0,
70
+ moveY: 0,
71
+ moving: false,
72
+ zooming: false,
73
+ imageRatio: 0,
74
+ displayWidth: 0,
75
+ displayHeight: 0
76
+ });
77
+ const touch = useTouch();
78
+ const vertical = computed(() => {
79
+ const { rootWidth, rootHeight } = props;
80
+ const rootRatio = rootHeight / rootWidth;
81
+ return state.imageRatio > rootRatio;
82
+ });
83
+ const imageStyle = computed(() => {
84
+ const { scale, moveX, moveY, moving, zooming } = state;
85
+ const style = {
86
+ transitionDuration: zooming || moving ? "0s" : ".3s"
87
+ };
88
+ if (scale !== 1) {
89
+ const offsetX = moveX / scale;
90
+ const offsetY = moveY / scale;
91
+ style.transform = `scale(${scale}, ${scale}) translate(${offsetX}px, ${offsetY}px)`;
92
+ }
93
+ return style;
94
+ });
95
+ const maxMoveX = computed(() => {
96
+ if (state.imageRatio) {
97
+ const { rootWidth, rootHeight } = props;
98
+ const displayWidth = vertical.value ? rootHeight / state.imageRatio : rootWidth;
99
+ return Math.max(0, (state.scale * displayWidth - rootWidth) / 2);
100
+ }
101
+ return 0;
102
+ });
103
+ const maxMoveY = computed(() => {
104
+ if (state.imageRatio) {
105
+ const { rootWidth, rootHeight } = props;
106
+ const displayHeight = vertical.value ? rootHeight : rootWidth * state.imageRatio;
107
+ return Math.max(0, (state.scale * displayHeight - rootHeight) / 2);
108
+ }
109
+ return 0;
110
+ });
111
+ const imageLoad = (event) => {
112
+ const { naturalWidth, naturalHeight } = event.target;
113
+ state.imageRatio = naturalHeight / naturalWidth;
114
+ };
115
+ const resetScale = () => {
116
+ setScale(1);
117
+ state.moveX = 0;
118
+ state.moveY = 0;
119
+ };
120
+ const setScale = (scale) => {
121
+ scale = clamp(scale, +props.minZoom, +props.maxZoom + 1);
122
+ if (scale !== state.scale) {
123
+ state.scale = scale;
124
+ emit("scale", {
125
+ scale,
126
+ index: props.initNo
127
+ });
128
+ }
129
+ };
130
+ const toggleScale = () => {
131
+ const scale = state.scale > 1 ? 1 : 2;
132
+ setScale(scale);
133
+ state.moveX = 0;
134
+ state.moveY = 0;
135
+ };
136
+ const getDistance = (touches) => Math.sqrt((touches[0].clientX - touches[1].clientX) ** 2 + (touches[0].clientY - touches[1].clientY) ** 2);
137
+ let startMoveX;
138
+ let startMoveY;
139
+ let startScale;
140
+ let startDistance;
141
+ let doubleTapTimer;
142
+ let touchStartTime;
143
+ let fingerNum;
144
+ const onTouchStart = (event) => {
145
+ const { touches } = event;
146
+ const { offsetX } = touch;
147
+ touch.start(event);
148
+ fingerNum = touches.length;
149
+ startMoveX = state.moveX;
150
+ startMoveY = state.moveY;
151
+ touchStartTime = Date.now();
152
+ state.moving = fingerNum === 1 && state.scale !== 1;
153
+ state.zooming = fingerNum === 2 && !offsetX.value;
154
+ if (state.zooming) {
155
+ startScale = state.scale;
156
+ startDistance = getDistance(event.touches);
157
+ }
158
+ };
159
+ const onTouchMove = (event) => {
160
+ const { touches } = event;
161
+ touch.move(event);
162
+ if (state.moving || state.zooming) {
163
+ preventDefault(event, true);
164
+ }
165
+ if (state.moving) {
166
+ const { deltaX, deltaY } = touch;
167
+ const moveX = deltaX.value + startMoveX;
168
+ const moveY = deltaY.value + startMoveY;
169
+ state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
170
+ state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
171
+ }
172
+ if (state.zooming && touches.length === 2) {
173
+ const distance = getDistance(touches);
174
+ const scale = startScale * distance / startDistance;
175
+ setScale(scale);
176
+ }
177
+ };
178
+ const checkTap = () => {
179
+ if (fingerNum > 1) {
180
+ return;
181
+ }
182
+ const { offsetX, offsetY } = touch;
183
+ const deltaTime = Date.now() - touchStartTime;
184
+ const TAP_TIME = 250;
185
+ const TAP_OFFSET = 5;
186
+ if (offsetX.value < TAP_OFFSET && offsetY.value < TAP_OFFSET && deltaTime < TAP_TIME) {
187
+ if (doubleTapTimer) {
188
+ clearTimeout(doubleTapTimer);
189
+ doubleTapTimer = null;
190
+ toggleScale();
191
+ } else {
192
+ doubleTapTimer = setTimeout(() => {
193
+ emit("close");
194
+ doubleTapTimer = null;
195
+ }, TAP_TIME);
196
+ }
197
+ }
198
+ };
199
+ const onTouchEnd = (event) => {
200
+ let stopPropagation = false;
201
+ if (state.moving || state.zooming) {
202
+ stopPropagation = true;
203
+ if (state.moving && startMoveX === state.moveX && startMoveY === state.moveY) {
204
+ stopPropagation = false;
205
+ }
206
+ if (!event.touches.length) {
207
+ if (state.zooming) {
208
+ state.moveX = clamp(state.moveX, -maxMoveX.value, maxMoveX.value);
209
+ state.moveY = clamp(state.moveY, -maxMoveY.value, maxMoveY.value);
210
+ state.zooming = false;
211
+ }
212
+ state.moving = false;
213
+ startMoveX = 0;
214
+ startMoveY = 0;
215
+ startScale = 1;
216
+ if (state.scale < 1) {
217
+ resetScale();
218
+ }
219
+ if (state.scale > props.maxZoom) {
220
+ state.scale = +props.maxZoom;
221
+ }
222
+ }
223
+ }
224
+ preventDefault(event, stopPropagation);
225
+ checkTap();
226
+ touch.reset();
227
+ };
228
+ const preventDefault = (event, isStopPropagation) => {
229
+ if (typeof event.cancelable !== "boolean" || event.cancelable) {
230
+ event.preventDefault();
231
+ }
232
+ if (isStopPropagation) {
233
+ event.stopPropagation();
234
+ }
235
+ };
236
+ const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
237
+ watch(() => props.initNo, resetScale);
238
+ watch(() => props.show, (value) => {
239
+ if (!value) {
240
+ resetScale();
241
+ }
242
+ });
243
+ return {
244
+ ...toRefs(state),
245
+ onTouchStart,
246
+ onTouchMove,
247
+ onTouchEnd,
248
+ getDistance,
249
+ imageStyle,
250
+ imageLoad
251
+ };
252
+ }
253
+ });
254
+ const _hoisted_1$1 = ["src"];
255
+ const _hoisted_2$1 = {
256
+ key: 1,
257
+ class: "nut-imagepreview-box"
258
+ };
259
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
260
+ const _component_nut_video = resolveComponent("nut-video");
261
+ const _component_nut_swiper_item = resolveComponent("nut-swiper-item");
262
+ return openBlock(), createBlock(_component_nut_swiper_item, {
263
+ onTouchstart: _ctx.onTouchStart,
264
+ onTouchmove: _ctx.onTouchMove,
265
+ onTouchend: _ctx.onTouchEnd,
266
+ onTouchcancel: _ctx.onTouchEnd
267
+ }, {
268
+ default: withCtx(() => [
269
+ _ctx.image && _ctx.image.src ? (openBlock(), createElementBlock("view", {
270
+ key: 0,
271
+ style: normalizeStyle(_ctx.imageStyle),
272
+ class: "nut-imagepreview-box"
273
+ }, [
274
+ createElementVNode("img", {
275
+ src: _ctx.image.src,
276
+ class: "nut-imagepreview-img",
277
+ onLoad: _cache[0] || (_cache[0] = (...args) => _ctx.imageLoad && _ctx.imageLoad(...args))
278
+ }, null, 40, _hoisted_1$1)
279
+ ], 4)) : createCommentVNode("", true),
280
+ _ctx.video ? (openBlock(), createElementBlock("view", _hoisted_2$1, [
281
+ createVNode(_component_nut_video, {
282
+ source: _ctx.video.source,
283
+ options: _ctx.video.options
284
+ }, null, 8, ["source", "options"])
285
+ ])) : createCommentVNode("", true)
286
+ ]),
287
+ _: 1
288
+ }, 8, ["onTouchstart", "onTouchmove", "onTouchend", "onTouchcancel"]);
289
+ }
290
+ var ImagePreviewItem = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
291
+ const { componentName, create } = createComponent("imagepreview");
292
+ const _sfc_main = create({
293
+ props: {
294
+ show: {
295
+ type: Boolean,
296
+ default: false
297
+ },
298
+ images: {
299
+ type: Array,
300
+ default: () => []
301
+ },
302
+ videos: {
303
+ type: Array,
304
+ default: () => []
305
+ },
306
+ contentClose: {
307
+ type: Boolean,
308
+ default: true
309
+ },
310
+ initNo: {
311
+ type: Number,
312
+ default: 1
313
+ },
314
+ paginationVisible: {
315
+ type: Boolean,
316
+ default: false
317
+ },
318
+ paginationColor: {
319
+ type: String,
320
+ default: "#fff"
321
+ },
322
+ autoplay: {
323
+ type: [Number, String],
324
+ default: 0
325
+ },
326
+ isWrapTeleport: {
327
+ type: Boolean,
328
+ default: false
329
+ },
330
+ showIndex: {
331
+ type: Boolean,
332
+ default: true
333
+ },
334
+ closeable: {
335
+ type: Boolean,
336
+ default: false
337
+ },
338
+ closeIcon: {
339
+ type: String,
340
+ default: "circle-close"
341
+ },
342
+ closeIconPosition: {
343
+ type: String,
344
+ default: "top-right"
345
+ },
346
+ beforeClose: Function,
347
+ minZoom: {
348
+ type: Number,
349
+ default: 1 / 3
350
+ },
351
+ maxZoom: {
352
+ type: Number,
353
+ default: 3
61
354
  }
62
- var o2 = e2.touches, t2 = o2[0], i2 = o2[1];
63
- const n2 = l2.store;
64
- n2.moveable = true, i2 && (n2.oriDistance = u2({ x: t2.pageX, y: t2.pageY }, { x: i2.pageX, y: i2.pageY })), n2.originScale = n2.scale || 1;
65
- }, onTouchMove: g2, onTouchEnd: d2, getDistance: u2, scaleNow: m2, styles: c2 };
66
- } }), B = ["src"], D = { key: 0, class: "nut-imagepreview-index" };
67
- var O = N(P, [["render", function(e2, o2, t2, i2, n2, y2) {
68
- const w2 = s("nut-video"), b2 = s("nut-swiper-item"), C2 = s("nut-swiper"), x2 = s("nut-icon"), T2 = s("nut-popup");
69
- return a(), l(T2, { "pop-class": "custom-pop", visible: e2.showPop, "onUpdate:visible": o2[3] || (o2[3] = (o3) => e2.showPop = o3), isWrapTeleport: e2.isWrapTeleport, onClick: e2.onClose, style: { width: "100%" } }, { default: c(() => [r("view", { class: "nut-imagepreview", onClick: o2[0] || (o2[0] = p((...o3) => e2.closeOnImg && e2.closeOnImg(...o3), ["stop"])), onTouchstartCapture: o2[1] || (o2[1] = (...o3) => e2.onTouchStart && e2.onTouchStart(...o3)) }, [e2.showPop ? (a(), l(C2, { key: 0, "auto-play": e2.autoplay, class: "nut-imagepreview-swiper", loop: true, "is-preventDefault": false, direction: "horizontal", onChange: e2.slideChangeEnd, "init-page": e2.initNo > e2.maxNo ? e2.maxNo - 1 : e2.initNo - 1, "pagination-visible": e2.paginationVisible, "pagination-color": e2.paginationColor }, { default: c(() => [(a(true), u(m, null, g(e2.videos, (e3, o3) => (a(), l(b2, { key: o3 }, { default: c(() => [d(w2, { source: e3.source, options: e3.options }, null, 8, ["source", "options"])]), _: 2 }, 1024))), 128)), (a(true), u(m, null, g(e2.images, (e3, o3) => (a(), l(b2, { key: o3 }, { default: c(() => [r("img", { src: e3.src, class: "nut-imagepreview-img" }, null, 8, B)]), _: 2 }, 1024))), 128))]), _: 1 }, 8, ["auto-play", "onChange", "init-page", "pagination-visible", "pagination-color"])) : h("", true)], 32), e2.showIndex ? (a(), u("view", D, f(e2.active) + " / " + f(e2.images.length + e2.videos.length), 1)) : h("", true), e2.closeable ? (a(), u("view", { key: 1, class: "nut-imagepreview-close-icon", onClick: o2[2] || (o2[2] = (...o3) => e2.handleCloseIcon && e2.handleCloseIcon(...o3)), style: v(e2.styles) }, [d(x2, { name: e2.closeIcon, color: "#ffffff" }, null, 8, ["name"])], 4)) : h("", true)]), _: 1 }, 8, ["visible", "isWrapTeleport", "onClick"]);
70
- }]]);
71
- class V {
355
+ },
356
+ emits: ["close", "change"],
357
+ components: {
358
+ [Popup.name]: Popup,
359
+ [Video.name]: Video,
360
+ [Swiper.name]: Swiper,
361
+ [SwiperItem.name]: SwiperItem,
362
+ [_sfc_main$2.name]: _sfc_main$2,
363
+ ImagePreviewItem
364
+ },
365
+ setup(props, { emit }) {
366
+ toRefs(props);
367
+ const swipeRef = ref();
368
+ const state = reactive({
369
+ showPop: false,
370
+ active: 1,
371
+ maxNo: 1,
372
+ rootWidth: 0,
373
+ rootHeight: 0
374
+ });
375
+ const styles = computed(() => {
376
+ let style = {};
377
+ if (props.closeIconPosition == "top-right") {
378
+ style.right = "10px";
379
+ } else {
380
+ style.left = "10px";
381
+ }
382
+ return style;
383
+ });
384
+ const slideChangeEnd = function(page) {
385
+ state.active = page + 1;
386
+ emit("change", state.active);
387
+ };
388
+ const onClose = () => {
389
+ if (props.beforeClose) {
390
+ const returnVal = props.beforeClose.apply(null, state.active);
391
+ if (isPromise(returnVal)) {
392
+ returnVal.then((value) => {
393
+ if (value) {
394
+ closeDone();
395
+ }
396
+ });
397
+ } else if (returnVal) {
398
+ closeDone();
399
+ }
400
+ } else {
401
+ closeDone();
402
+ }
403
+ };
404
+ const closeDone = () => {
405
+ state.showPop = false;
406
+ state.active = 1;
407
+ emit("close");
408
+ };
409
+ const handleCloseIcon = () => {
410
+ onClose();
411
+ };
412
+ const init = () => {
413
+ setTimeout(() => {
414
+ state.rootHeight = swipeRef.value.offsetHeight;
415
+ state.rootWidth = swipeRef.value.offsetWidth;
416
+ }, 100);
417
+ };
418
+ watch(() => props.show, (val) => {
419
+ state.showPop = val;
420
+ init();
421
+ });
422
+ onMounted(() => {
423
+ state.active = props.initNo;
424
+ state.showPop = props.show;
425
+ state.maxNo = props.images.length + props.videos.length;
426
+ });
427
+ return {
428
+ swipeRef,
429
+ ...toRefs(state),
430
+ slideChangeEnd,
431
+ onClose,
432
+ handleCloseIcon,
433
+ styles
434
+ };
435
+ }
436
+ });
437
+ const _hoisted_1 = {
438
+ class: "nut-imagepreview",
439
+ ref: "swipeRef"
440
+ };
441
+ const _hoisted_2 = {
442
+ key: 0,
443
+ class: "nut-imagepreview-index"
444
+ };
445
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
446
+ const _component_image_preview_item = resolveComponent("image-preview-item");
447
+ const _component_nut_swiper = resolveComponent("nut-swiper");
448
+ const _component_nut_icon = resolveComponent("nut-icon");
449
+ const _component_nut_popup = resolveComponent("nut-popup");
450
+ return openBlock(), createBlock(_component_nut_popup, {
451
+ "pop-class": "custom-pop",
452
+ visible: _ctx.showPop,
453
+ "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => _ctx.showPop = $event),
454
+ isWrapTeleport: _ctx.isWrapTeleport,
455
+ onClick: _ctx.onClose,
456
+ style: { "width": "100%" }
457
+ }, {
458
+ default: withCtx(() => [
459
+ createElementVNode("view", _hoisted_1, [
460
+ _ctx.showPop ? (openBlock(), createBlock(_component_nut_swiper, {
461
+ key: 0,
462
+ "auto-play": _ctx.autoplay,
463
+ class: "nut-imagepreview-swiper",
464
+ loop: true,
465
+ "is-preventDefault": false,
466
+ direction: "horizontal",
467
+ onChange: _ctx.slideChangeEnd,
468
+ "init-page": _ctx.initNo > _ctx.maxNo ? _ctx.maxNo - 1 : _ctx.initNo - 1,
469
+ "pagination-visible": _ctx.paginationVisible,
470
+ "pagination-color": _ctx.paginationColor
471
+ }, {
472
+ default: withCtx(() => [
473
+ _ctx.videos.length ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(_ctx.videos, (item, index) => {
474
+ return openBlock(), createBlock(_component_image_preview_item, {
475
+ key: index,
476
+ video: item,
477
+ rootHeight: _ctx.rootHeight,
478
+ rootWidth: _ctx.rootWidth,
479
+ show: _ctx.showPop,
480
+ "init-no": _ctx.active,
481
+ onClose: _ctx.onClose,
482
+ maxZoom: _ctx.maxZoom,
483
+ minZoom: _ctx.minZoom
484
+ }, null, 8, ["video", "rootHeight", "rootWidth", "show", "init-no", "onClose", "maxZoom", "minZoom"]);
485
+ }), 128)) : createCommentVNode("", true),
486
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.images, (item, index) => {
487
+ return openBlock(), createBlock(_component_image_preview_item, {
488
+ key: index,
489
+ image: item,
490
+ rootHeight: _ctx.rootHeight,
491
+ rootWidth: _ctx.rootWidth,
492
+ show: _ctx.showPop,
493
+ "init-no": _ctx.active,
494
+ onClose: _ctx.onClose
495
+ }, null, 8, ["image", "rootHeight", "rootWidth", "show", "init-no", "onClose"]);
496
+ }), 128))
497
+ ]),
498
+ _: 1
499
+ }, 8, ["auto-play", "onChange", "init-page", "pagination-visible", "pagination-color"])) : createCommentVNode("", true)
500
+ ], 512),
501
+ _ctx.showIndex ? (openBlock(), createElementBlock("view", _hoisted_2, toDisplayString(_ctx.active) + " / " + toDisplayString(_ctx.images.length + _ctx.videos.length), 1)) : createCommentVNode("", true),
502
+ _ctx.closeable ? (openBlock(), createElementBlock("view", {
503
+ key: 1,
504
+ class: "nut-imagepreview-close-icon",
505
+ onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleCloseIcon && _ctx.handleCloseIcon(...args)),
506
+ style: normalizeStyle(_ctx.styles)
507
+ }, [
508
+ createVNode(_component_nut_icon, {
509
+ name: _ctx.closeIcon,
510
+ color: "#ffffff"
511
+ }, null, 8, ["name"])
512
+ ], 4)) : createCommentVNode("", true)
513
+ ]),
514
+ _: 1
515
+ }, 8, ["visible", "isWrapTeleport", "onClick"]);
516
+ }
517
+ var ImagePreview = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
518
+ class ImagePreviewOptions {
72
519
  constructor() {
73
- this.show = false, this.images = [], this.initNo = 1, this.paginationVisible = false, this.paginationColor = "", this.teleport = "body", this.onClose = () => {
520
+ this.show = false;
521
+ this.images = [];
522
+ this.initNo = 1;
523
+ this.paginationVisible = false;
524
+ this.paginationColor = "";
525
+ this.teleport = "body";
526
+ this.onClose = () => {
74
527
  };
75
528
  }
76
529
  }
77
- class X {
78
- constructor(e2) {
79
- this.options = new V();
80
- let o2 = Object.assign(this.options, e2), t2 = document.body, i2 = o2.teleport;
81
- i2 != "body" && (t2 = typeof i2 == "string" ? document.querySelector(i2) : o2.teleport);
82
- const n2 = document.createElement("view");
83
- n2.id = "imagepreview-" + new Date().getTime();
84
- const s2 = d({ setup: () => (o2.teleport = `#${n2.id}`, () => w(O, o2)) });
85
- t2.appendChild(n2), y(s2, n2);
530
+ class ImagePreviewFunction {
531
+ constructor(_options) {
532
+ this.options = new ImagePreviewOptions();
533
+ let options = Object.assign(this.options, _options);
534
+ let elWarp = document.body;
535
+ let teleport = options.teleport;
536
+ if (teleport != "body") {
537
+ if (typeof teleport == "string") {
538
+ elWarp = document.querySelector(teleport);
539
+ } else {
540
+ elWarp = options.teleport;
541
+ }
542
+ }
543
+ const root = document.createElement("view");
544
+ root.id = "imagepreview-" + new Date().getTime();
545
+ const Wrapper = {
546
+ setup() {
547
+ options.teleport = `#${root.id}`;
548
+ return () => {
549
+ return h(ImagePreview, options);
550
+ };
551
+ }
552
+ };
553
+ const instance = createVNode(Wrapper);
554
+ elWarp.appendChild(root);
555
+ render(instance, root);
86
556
  }
87
557
  }
88
- const Y = function(e2) {
89
- return new X(e2);
558
+ const _ImagePreview = function(options) {
559
+ return new ImagePreviewFunction(options);
90
560
  };
91
- Y.install = (e2) => {
92
- e2.use(O), e2.config.globalProperties.$imagepreview = Y;
561
+ _ImagePreview.install = (app) => {
562
+ app.use(ImagePreview);
563
+ app.config.globalProperties.$imagepreview = _ImagePreview;
93
564
  };
94
- export { O as ImagePreview, V as ImagePreviewOptions, Y as default };
565
+ export { ImagePreview, ImagePreviewOptions, _ImagePreview as default };