@nutui/nutui 4.0.11 → 4.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/dist/nutui.es.js +1 -1
  2. package/dist/nutui.js +2 -2
  3. package/dist/nutui.umd.js +1 -1
  4. package/dist/packages/_es/ActionSheet.js +111 -78
  5. package/dist/packages/_es/Address.js +375 -250
  6. package/dist/packages/_es/AddressList.js +354 -269
  7. package/dist/packages/_es/Animate.js +58 -41
  8. package/dist/packages/_es/Audio.js +197 -128
  9. package/dist/packages/_es/AudioOperate.js +71 -60
  10. package/dist/packages/_es/Avatar.js +89 -66
  11. package/dist/packages/_es/AvatarGroup.js +31 -23
  12. package/dist/packages/_es/Backtop.js +99 -59
  13. package/dist/packages/_es/Badge.js +47 -36
  14. package/dist/packages/_es/Barrage.js +147 -68
  15. package/dist/packages/_es/Button.js +66 -47
  16. package/dist/packages/_es/Calendar.js +157 -135
  17. package/dist/packages/_es/CalendarItem.js +6 -6
  18. package/dist/packages/_es/Card.js +56 -42
  19. package/dist/packages/_es/Cascader.js +474 -315
  20. package/dist/packages/_es/Category.js +39 -29
  21. package/dist/packages/_es/CategoryPane.js +83 -57
  22. package/dist/packages/_es/Cell.js +71 -56
  23. package/dist/packages/_es/CellGroup.js +27 -19
  24. package/dist/packages/_es/Checkbox.js +156 -109
  25. package/dist/packages/_es/CheckboxGroup.js +59 -38
  26. package/dist/packages/_es/CircleProgress.js +96 -67
  27. package/dist/packages/_es/Col.js +31 -23
  28. package/dist/packages/_es/Collapse.js +58 -33
  29. package/dist/packages/_es/CollapseItem.js +108 -78
  30. package/dist/packages/_es/Comment.js +279 -207
  31. package/dist/packages/_es/ConfigProvider.js +55 -37
  32. package/dist/packages/_es/Countdown.js +212 -100
  33. package/dist/packages/_es/Countup.js +445 -232
  34. package/dist/packages/_es/DatePicker.js +265 -162
  35. package/dist/packages/_es/Dialog.js +213 -161
  36. package/dist/packages/_es/Divider.js +57 -42
  37. package/dist/packages/_es/Drag.js +153 -70
  38. package/dist/packages/_es/Ecard.js +104 -64
  39. package/dist/packages/_es/Elevator.js +219 -143
  40. package/dist/packages/_es/Ellipsis.js +178 -95
  41. package/dist/packages/_es/Empty.js +39 -23
  42. package/dist/packages/_es/FixedNav.js +116 -93
  43. package/dist/packages/_es/Form.js +178 -107
  44. package/dist/packages/_es/FormItem.js +61 -48
  45. package/dist/packages/_es/Grid.js +6 -5
  46. package/dist/packages/_es/GridItem.js +84 -58
  47. package/dist/packages/_es/Image.js +130 -90
  48. package/dist/packages/_es/ImagePreview.js +412 -256
  49. package/dist/packages/_es/Indicator.js +34 -30
  50. package/dist/packages/_es/InfiniteLoading.js +136 -83
  51. package/dist/packages/_es/Input.js +264 -160
  52. package/dist/packages/_es/InputNumber.js +117 -81
  53. package/dist/packages/_es/Interceptor-956b24fc.js +29 -0
  54. package/dist/packages/_es/Invoice.js +130 -104
  55. package/dist/packages/_es/Layout.js +4 -3
  56. package/dist/packages/_es/List.js +215 -117
  57. package/dist/packages/_es/Menu.js +150 -95
  58. package/dist/packages/_es/MenuItem.js +154 -109
  59. package/dist/packages/_es/Navbar.js +119 -103
  60. package/dist/packages/_es/Noticebar.js +312 -197
  61. package/dist/packages/_es/Notify.js +166 -110
  62. package/dist/packages/_es/NumberKeyboard.js +202 -127
  63. package/dist/packages/_es/Overlay.js +80 -52
  64. package/dist/packages/_es/Pagination.js +100 -70
  65. package/dist/packages/_es/Picker.js +437 -275
  66. package/dist/packages/_es/Popover.js +225 -122
  67. package/dist/packages/_es/Popup.js +4 -4
  68. package/dist/packages/_es/Price.js +82 -44
  69. package/dist/packages/_es/Progress.js +79 -63
  70. package/dist/packages/_es/PullRefresh.js +173 -95
  71. package/dist/packages/_es/Radio.js +4 -4
  72. package/dist/packages/_es/RadioGroup.js +3 -3
  73. package/dist/packages/_es/Range.js +347 -204
  74. package/dist/packages/_es/Rate.js +141 -92
  75. package/dist/packages/_es/Row.js +27 -21
  76. package/dist/packages/_es/Searchbar.js +174 -123
  77. package/dist/packages/_es/ShortPassword.js +93 -69
  78. package/dist/packages/_es/SideNavbar.js +80 -49
  79. package/dist/packages/_es/SideNavbarItem.js +32 -22
  80. package/dist/packages/_es/Signature.js +146 -83
  81. package/dist/packages/_es/Skeleton.js +130 -110
  82. package/dist/packages/_es/Sku.js +343 -250
  83. package/dist/packages/_es/Step.js +86 -59
  84. package/dist/packages/_es/Steps.js +31 -26
  85. package/dist/packages/_es/Sticky.js +4 -4
  86. package/dist/packages/_es/SubSideNavbar.js +74 -52
  87. package/dist/packages/_es/Swipe.js +155 -83
  88. package/dist/packages/_es/Swiper.js +311 -174
  89. package/dist/packages/_es/SwiperItem.js +44 -28
  90. package/dist/packages/_es/Switch.js +68 -55
  91. package/dist/packages/_es/TabPane.js +41 -30
  92. package/dist/packages/_es/Tabbar.js +52 -41
  93. package/dist/packages/_es/TabbarItem.js +82 -61
  94. package/dist/packages/_es/Table.js +165 -109
  95. package/dist/packages/_es/Tabs.js +388 -240
  96. package/dist/packages/_es/Tag.js +61 -44
  97. package/dist/packages/_es/Textarea.js +124 -80
  98. package/dist/packages/_es/TimeDetail.js +76 -49
  99. package/dist/packages/_es/TimePannel.js +48 -34
  100. package/dist/packages/_es/TimeSelect.js +68 -47
  101. package/dist/packages/_es/Toast.js +218 -144
  102. package/dist/packages/_es/Tour.js +192 -138
  103. package/dist/packages/_es/TrendArrow.js +77 -57
  104. package/dist/packages/_es/Uploader.js +359 -234
  105. package/dist/packages/_es/Video.js +316 -191
  106. package/dist/packages/_es/Watermark.js +117 -84
  107. package/dist/packages/_es/_plugin-vue_export-helper-cc2b3d55.js +10 -0
  108. package/dist/packages/_es/common-b9a5e726.js +145 -0
  109. package/dist/packages/_es/component-81a4c1d0.js +145 -0
  110. package/dist/packages/_es/index-29892cda.js +33 -0
  111. package/dist/packages/_es/index-43c34ac6.js +30 -0
  112. package/dist/packages/_es/index-54d03fc1.js +8 -0
  113. package/dist/packages/_es/index-79c5dc33.js +10 -0
  114. package/dist/packages/_es/index-7a7385e4.js +67 -0
  115. package/dist/packages/_es/index-87422be8.js +942 -0
  116. package/dist/packages/_es/index-da0a7662.js +259 -0
  117. package/dist/packages/_es/index.vue_vue_type_script_lang-22dfc112.js +46 -0
  118. package/dist/packages/_es/index.vue_vue_type_script_lang-a8856969.js +97 -0
  119. package/dist/packages/_es/index.vue_vue_type_script_lang-cc5c4086.js +151 -0
  120. package/dist/packages/_es/mountComponent-8b24c346.js +39 -0
  121. package/dist/packages/_es/pxCheck-c6b9f6b7.js +6 -0
  122. package/dist/packages/_es/raf-729dad54.js +25 -0
  123. package/dist/packages/_es/renderIcon-3d0fd47c.js +9 -0
  124. package/dist/packages/locale/lang/baseLang-3a8457ac.js +5 -0
  125. package/dist/packages/locale/lang/en-US.js +39 -36
  126. package/dist/packages/locale/lang/id-ID.js +39 -36
  127. package/dist/packages/locale/lang/index.js +44 -22
  128. package/dist/packages/locale/lang/zh-CN.js +38 -35
  129. package/dist/packages/locale/lang/zh-TW.js +38 -35
  130. package/dist/resolver/index.js +26 -1
  131. package/dist/resolver/index.mjs +17 -14
  132. package/dist/smartips/web-types.json +1 -1
  133. package/dist/style.css +1 -1
  134. package/dist/styles/themes/default.scss +48 -48
  135. package/dist/styles/themes/jdb.scss +48 -48
  136. package/dist/styles/themes/jddkh.scss +48 -48
  137. package/dist/styles/themes/jdt.scss +48 -48
  138. package/dist/types/index.d.ts +1 -1
  139. package/package.json +3 -4
  140. package/dist/packages/_es/Interceptor-6e26b757.js +0 -18
  141. package/dist/packages/_es/_plugin-vue_export-helper-dad06003.js +0 -9
  142. package/dist/packages/_es/common-d218746f.js +0 -116
  143. package/dist/packages/_es/component-234624bc.js +0 -89
  144. package/dist/packages/_es/index-14dfadc4.js +0 -561
  145. package/dist/packages/_es/index-192a3ef6.js +0 -29
  146. package/dist/packages/_es/index-360c5092.js +0 -210
  147. package/dist/packages/_es/index-496e6e05.js +0 -24
  148. package/dist/packages/_es/index-50eed3d9.js +0 -7
  149. package/dist/packages/_es/index-53ec2d4d.js +0 -34
  150. package/dist/packages/_es/index-fadb0974.js +0 -8
  151. package/dist/packages/_es/index.vue_vue_type_script_lang-1139b29a.js +0 -43
  152. package/dist/packages/_es/index.vue_vue_type_script_lang-43b774dd.js +0 -77
  153. package/dist/packages/_es/index.vue_vue_type_script_lang-f44c159d.js +0 -110
  154. package/dist/packages/_es/mountComponent-6d4ff200.js +0 -23
  155. package/dist/packages/_es/pxCheck-38173291.js +0 -4
  156. package/dist/packages/_es/raf-a74f1a06.js +0 -16
  157. package/dist/packages/_es/renderIcon-47498b32.js +0 -5
  158. package/dist/packages/locale/lang/baseLang-0bdc6353.js +0 -5
@@ -1,40 +1,53 @@
1
- var re = Object.defineProperty, me = Object.defineProperties;
2
- var ce = Object.getOwnPropertyDescriptors;
3
- var j = Object.getOwnPropertySymbols;
4
- var ue = Object.prototype.hasOwnProperty, pe = Object.prototype.propertyIsEnumerable;
5
- var M = Math.pow, H = (e, t, o) => t in e ? re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o, S = (e, t) => {
6
- for (var o in t || (t = {}))
7
- ue.call(t, o) && H(e, o, t[o]);
8
- if (j)
9
- for (var o of j(t))
10
- pe.call(t, o) && H(e, o, t[o]);
11
- return e;
12
- }, P = (e, t) => me(e, ce(t));
13
- var l = (e, t, o) => (H(e, typeof t != "symbol" ? t + "" : t, o), o);
14
- import { reactive as G, computed as w, watch as Z, toRefs as J, resolveComponent as y, openBlock as p, createBlock as I, withCtx as R, createElementVNode as K, normalizeStyle as fe, createElementBlock as k, createCommentVNode as N, ref as ge, onMounted as ve, Fragment as de, renderList as he, toDisplayString as q, normalizeClass as we, renderSlot as ye, createVNode as Ce, nextTick as be, h as Te } from "vue";
15
- import { c as Q, e as $, d as U, i as Se } from "./component-234624bc.js";
16
- import { u as Pe } from "./index-192a3ef6.js";
17
- import { u as $e } from "./index-53ec2d4d.js";
18
- import B from "./Video.js";
19
- import E from "./SwiperItem.js";
20
- import { _ } from "./_plugin-vue_export-helper-dad06003.js";
21
- import { CircleClose as Ie } from "@nutui/icons-vue";
22
- import { P as L } from "./index-360c5092.js";
23
- import A from "./Swiper.js";
24
- import { f as Ne } from "./Interceptor-6e26b757.js";
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __pow = Math.pow;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
+ var __publicField = (obj, key, value) => {
22
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
23
+ return value;
24
+ };
25
+ import { reactive, computed, watch, toRefs, resolveComponent, openBlock, createBlock, withCtx, createElementVNode, normalizeStyle, createElementBlock, createCommentVNode, ref, onMounted, Fragment, renderList, toDisplayString, normalizeClass, renderSlot, createVNode, nextTick, h } from "vue";
26
+ import { c as createComponent, e as clamp, d as preventDefault, i as isArray } from "./component-81a4c1d0.js";
27
+ import { u as useRect } from "./index-29892cda.js";
28
+ import { u as useTouch } from "./index-7a7385e4.js";
29
+ import Video from "./Video.js";
30
+ import SwiperItem from "./SwiperItem.js";
31
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
32
+ import { CircleClose } from "@nutui/icons-vue";
33
+ import { P as Popup } from "./index-da0a7662.js";
34
+ import Swiper from "./Swiper.js";
35
+ import { f as funInterceptor } from "./Interceptor-956b24fc.js";
25
36
  import "../locale/lang";
26
- import { C as Xe } from "./mountComponent-6d4ff200.js";
27
- import Ye from "./Overlay.js";
28
- import "./index-fadb0974.js";
29
- import "./raf-a74f1a06.js";
30
- const x = {
31
- show: { type: Boolean, default: !1 },
37
+ import { C as CreateComponent } from "./mountComponent-8b24c346.js";
38
+ import Overlay from "./Overlay.js";
39
+ import "./index-79c5dc33.js";
40
+ import "./raf-729dad54.js";
41
+ const baseProps = {
42
+ show: { type: Boolean, default: false },
32
43
  initNo: { type: Number, default: 0 },
33
- showIndex: { type: Boolean, default: !0 },
44
+ showIndex: { type: Boolean, default: true },
34
45
  minZoom: { type: Number, default: 1 / 3 },
35
46
  maxZoom: { type: Number, default: 3 }
36
- }, { create: ke } = Q("image-preview-item"), Ze = ke({
37
- props: P(S({}, x), {
47
+ };
48
+ const { create: create$1 } = createComponent("image-preview-item");
49
+ const _sfc_main$1 = create$1({
50
+ props: __spreadProps(__spreadValues({}, baseProps), {
38
51
  image: {
39
52
  type: Object,
40
53
  default: () => ({})
@@ -53,150 +66,253 @@ const x = {
53
66
  },
54
67
  contentClose: {
55
68
  type: Boolean,
56
- default: !0
69
+ default: true
57
70
  }
58
71
  }),
59
72
  emits: ["close", "scale"],
60
73
  components: {
61
- [B.name]: B,
62
- [E.name]: E
74
+ [Video.name]: Video,
75
+ [SwiperItem.name]: SwiperItem
63
76
  },
64
- setup(e, { emit: t }) {
65
- const o = G({
77
+ setup(props, { emit }) {
78
+ const state = reactive({
66
79
  scale: 1,
67
80
  moveX: 0,
68
81
  moveY: 0,
69
- moving: !1,
70
- zooming: !1,
82
+ moving: false,
83
+ zooming: false,
71
84
  imageRatio: 0,
72
85
  displayWidth: 0,
73
86
  displayHeight: 0
74
- }), a = $e(), v = w(() => {
75
- const { rootWidth: n, rootHeight: s } = e, r = s / n;
76
- return o.imageRatio > r;
77
- }), C = w(() => {
78
- const n = e.image;
79
- if (n && n.src) {
80
- const { scale: s, moveX: r, moveY: f, moving: h, zooming: z } = o, F = {
81
- transitionDuration: z || h ? "0s" : ".3s"
87
+ });
88
+ const touch = useTouch();
89
+ const vertical = computed(() => {
90
+ const { rootWidth, rootHeight } = props;
91
+ const rootRatio = rootHeight / rootWidth;
92
+ return state.imageRatio > rootRatio;
93
+ });
94
+ const imageStyle = computed(() => {
95
+ const images = props.image;
96
+ if (images && images.src) {
97
+ const { scale, moveX, moveY, moving, zooming } = state;
98
+ const style = {
99
+ transitionDuration: zooming || moving ? "0s" : ".3s"
82
100
  };
83
- if (s !== 1) {
84
- const ae = r / s, le = f / s;
85
- F.transform = `scale(${s}, ${s}) translate(${ae}px, ${le}px)`;
101
+ if (scale !== 1) {
102
+ const offsetX = moveX / scale;
103
+ const offsetY = moveY / scale;
104
+ style.transform = `scale(${scale}, ${scale}) translate(${offsetX}px, ${offsetY}px)`;
86
105
  }
87
- return F;
106
+ return style;
88
107
  }
89
108
  return {};
90
- }), c = w(() => {
91
- if (o.imageRatio) {
92
- const { rootWidth: n, rootHeight: s } = e, r = v.value ? s / o.imageRatio : n;
93
- return Math.max(0, (o.scale * r - n) / 2);
109
+ });
110
+ const maxMoveX = computed(() => {
111
+ if (state.imageRatio) {
112
+ const { rootWidth, rootHeight } = props;
113
+ const displayWidth = vertical.value ? rootHeight / state.imageRatio : rootWidth;
114
+ return Math.max(0, (state.scale * displayWidth - rootWidth) / 2);
94
115
  }
95
116
  return 0;
96
- }), u = w(() => {
97
- if (o.imageRatio) {
98
- const { rootWidth: n, rootHeight: s } = e, r = v.value ? s : n * o.imageRatio;
99
- return Math.max(0, (o.scale * r - s) / 2);
117
+ });
118
+ const maxMoveY = computed(() => {
119
+ if (state.imageRatio) {
120
+ const { rootWidth, rootHeight } = props;
121
+ const displayHeight = vertical.value ? rootHeight : rootWidth * state.imageRatio;
122
+ return Math.max(0, (state.scale * displayHeight - rootHeight) / 2);
100
123
  }
101
124
  return 0;
102
- }), m = (n) => {
103
- const { naturalWidth: s, naturalHeight: r } = n.target;
104
- o.imageRatio = r / s;
105
- }, g = () => {
106
- i(1), o.moveX = 0, o.moveY = 0;
107
- }, i = (n) => {
108
- n = $(n, +e.minZoom, +e.maxZoom + 1), n !== o.scale && (o.scale = n, t("scale", {
109
- scale: n,
110
- index: e.initNo
111
- }));
112
- }, d = () => {
113
- const n = o.scale > 1 ? 1 : 2;
114
- i(n), o.moveX = 0, o.moveY = 0;
115
- }, D = (n) => Math.sqrt(M(n[0].clientX - n[1].clientX, 2) + M(n[0].clientY - n[1].clientY, 2));
116
- let X, Y, W, V, b, O, T;
117
- const oe = (n) => {
118
- const { touches: s } = n, { offsetX: r } = a;
119
- a.start(n), T = s.length, X = o.moveX, Y = o.moveY, O = Date.now(), o.moving = T === 1 && o.scale !== 1, o.zooming = T === 2 && !r.value, o.zooming && (W = o.scale, V = D(n.touches));
120
- }, te = (n) => {
121
- const { touches: s } = n;
122
- if (a.move(n), (o.moving || o.zooming) && U(n, !0), o.moving) {
123
- const { deltaX: r, deltaY: f } = a, h = r.value + X, z = f.value + Y;
124
- o.moveX = $(h, -c.value, c.value), o.moveY = $(z, -u.value, u.value);
125
+ });
126
+ const imageLoad = (event) => {
127
+ const { naturalWidth, naturalHeight } = event.target;
128
+ state.imageRatio = naturalHeight / naturalWidth;
129
+ };
130
+ const resetScale = () => {
131
+ setScale(1);
132
+ state.moveX = 0;
133
+ state.moveY = 0;
134
+ };
135
+ const setScale = (scale) => {
136
+ scale = clamp(scale, +props.minZoom, +props.maxZoom + 1);
137
+ if (scale !== state.scale) {
138
+ state.scale = scale;
139
+ emit("scale", {
140
+ scale,
141
+ index: props.initNo
142
+ });
125
143
  }
126
- if (o.zooming && s.length === 2) {
127
- const r = D(s), f = W * r / V;
128
- i(f);
144
+ };
145
+ const toggleScale = () => {
146
+ const scale = state.scale > 1 ? 1 : 2;
147
+ setScale(scale);
148
+ state.moveX = 0;
149
+ state.moveY = 0;
150
+ };
151
+ const getDistance = (touches) => Math.sqrt(__pow(touches[0].clientX - touches[1].clientX, 2) + __pow(touches[0].clientY - touches[1].clientY, 2));
152
+ let startMoveX;
153
+ let startMoveY;
154
+ let startScale;
155
+ let startDistance;
156
+ let doubleTapTimer;
157
+ let touchStartTime;
158
+ let fingerNum;
159
+ const onTouchStart = (event) => {
160
+ const { touches } = event;
161
+ const { offsetX } = touch;
162
+ touch.start(event);
163
+ fingerNum = touches.length;
164
+ startMoveX = state.moveX;
165
+ startMoveY = state.moveY;
166
+ touchStartTime = Date.now();
167
+ state.moving = fingerNum === 1 && state.scale !== 1;
168
+ state.zooming = fingerNum === 2 && !offsetX.value;
169
+ if (state.zooming) {
170
+ startScale = state.scale;
171
+ startDistance = getDistance(event.touches);
172
+ }
173
+ };
174
+ const onTouchMove = (event) => {
175
+ const { touches } = event;
176
+ touch.move(event);
177
+ if (state.moving || state.zooming) {
178
+ preventDefault(event, true);
179
+ }
180
+ if (state.moving) {
181
+ const { deltaX, deltaY } = touch;
182
+ const moveX = deltaX.value + startMoveX;
183
+ const moveY = deltaY.value + startMoveY;
184
+ state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
185
+ state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
186
+ }
187
+ if (state.zooming && touches.length === 2) {
188
+ const distance = getDistance(touches);
189
+ const scale = startScale * distance / startDistance;
190
+ setScale(scale);
129
191
  }
130
- }, ne = () => {
131
- if (T == 1 && e.video && e.video.source || T > 1)
192
+ };
193
+ const checkTap = () => {
194
+ if (fingerNum == 1 && props.video && props.video.source) {
195
+ return;
196
+ }
197
+ if (fingerNum > 1) {
132
198
  return;
133
- const { offsetX: n, offsetY: s } = a, r = Date.now() - O, f = 250, h = 5;
134
- n.value < h && s.value < h && r < f && (b ? (clearTimeout(b), b = null, d()) : b = setTimeout(() => {
135
- e.contentClose && t("close"), b = null;
136
- }, f));
137
- }, ie = (n) => {
138
- let s = !1;
139
- (o.moving || o.zooming) && (s = !0, o.moving && X === o.moveX && Y === o.moveY && (s = !1), n.touches.length || (o.zooming && (o.moveX = $(o.moveX, -c.value, c.value), o.moveY = $(o.moveY, -u.value, u.value), o.zooming = !1), o.moving = !1, X = 0, Y = 0, W = 1, o.scale < 1 && g(), o.scale > e.maxZoom && (o.scale = +e.maxZoom))), U(n, s), ne(), a.reset();
140
- }, se = () => {
141
- t("close");
199
+ }
200
+ const { offsetX, offsetY } = touch;
201
+ const deltaTime = Date.now() - touchStartTime;
202
+ const TAP_TIME = 250;
203
+ const TAP_OFFSET = 5;
204
+ if (offsetX.value < TAP_OFFSET && offsetY.value < TAP_OFFSET && deltaTime < TAP_TIME) {
205
+ if (doubleTapTimer) {
206
+ clearTimeout(doubleTapTimer);
207
+ doubleTapTimer = null;
208
+ toggleScale();
209
+ } else {
210
+ doubleTapTimer = setTimeout(() => {
211
+ if (props.contentClose) {
212
+ emit("close");
213
+ }
214
+ doubleTapTimer = null;
215
+ }, TAP_TIME);
216
+ }
217
+ }
142
218
  };
143
- return Z(() => e.initNo, g), Z(
144
- () => e.show,
145
- (n) => {
146
- n || g();
219
+ const onTouchEnd = (event) => {
220
+ let stopPropagation = false;
221
+ if (state.moving || state.zooming) {
222
+ stopPropagation = true;
223
+ if (state.moving && startMoveX === state.moveX && startMoveY === state.moveY) {
224
+ stopPropagation = false;
225
+ }
226
+ if (!event.touches.length) {
227
+ if (state.zooming) {
228
+ state.moveX = clamp(state.moveX, -maxMoveX.value, maxMoveX.value);
229
+ state.moveY = clamp(state.moveY, -maxMoveY.value, maxMoveY.value);
230
+ state.zooming = false;
231
+ }
232
+ state.moving = false;
233
+ startMoveX = 0;
234
+ startMoveY = 0;
235
+ startScale = 1;
236
+ if (state.scale < 1) {
237
+ resetScale();
238
+ }
239
+ if (state.scale > props.maxZoom) {
240
+ state.scale = +props.maxZoom;
241
+ }
242
+ }
147
243
  }
148
- ), P(S({}, J(o)), {
149
- onTouchStart: oe,
150
- onTouchMove: te,
151
- onTouchEnd: ie,
152
- getDistance: D,
153
- imageStyle: C,
154
- imageLoad: m,
155
- closeSwiper: se
244
+ preventDefault(event, stopPropagation);
245
+ checkTap();
246
+ touch.reset();
247
+ };
248
+ const closeSwiper = () => {
249
+ emit("close");
250
+ };
251
+ watch(() => props.initNo, resetScale);
252
+ watch(
253
+ () => props.show,
254
+ (value) => {
255
+ if (!value) {
256
+ resetScale();
257
+ }
258
+ }
259
+ );
260
+ return __spreadProps(__spreadValues({}, toRefs(state)), {
261
+ onTouchStart,
262
+ onTouchMove,
263
+ onTouchEnd,
264
+ getDistance,
265
+ imageStyle,
266
+ imageLoad,
267
+ closeSwiper
156
268
  });
157
269
  }
158
- }), De = ["src"];
159
- function We(e, t, o, a, v, C) {
160
- const c = y("nut-video"), u = y("nut-swiper-item");
161
- return p(), I(u, { onClick: e.closeSwiper }, {
162
- default: R(() => [
163
- K("view", {
164
- style: fe(e.imageStyle),
270
+ });
271
+ const _hoisted_1$1 = ["src"];
272
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
273
+ const _component_nut_video = resolveComponent("nut-video");
274
+ const _component_nut_swiper_item = resolveComponent("nut-swiper-item");
275
+ return openBlock(), createBlock(_component_nut_swiper_item, { onClick: _ctx.closeSwiper }, {
276
+ default: withCtx(() => [
277
+ createElementVNode("view", {
278
+ style: normalizeStyle(_ctx.imageStyle),
165
279
  class: "nut-image-preview-box",
166
- onTouchstart: t[1] || (t[1] = (...m) => e.onTouchStart && e.onTouchStart(...m)),
167
- onTouchmove: t[2] || (t[2] = (...m) => e.onTouchMove && e.onTouchMove(...m)),
168
- onTouchend: t[3] || (t[3] = (...m) => e.onTouchEnd && e.onTouchEnd(...m)),
169
- onTouchcancel: t[4] || (t[4] = (...m) => e.onTouchEnd && e.onTouchEnd(...m))
280
+ onTouchstart: _cache[1] || (_cache[1] = (...args) => _ctx.onTouchStart && _ctx.onTouchStart(...args)),
281
+ onTouchmove: _cache[2] || (_cache[2] = (...args) => _ctx.onTouchMove && _ctx.onTouchMove(...args)),
282
+ onTouchend: _cache[3] || (_cache[3] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args)),
283
+ onTouchcancel: _cache[4] || (_cache[4] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args))
170
284
  }, [
171
- e.image && e.image.src ? (p(), k("img", {
285
+ _ctx.image && _ctx.image.src ? (openBlock(), createElementBlock("img", {
172
286
  key: 0,
173
- src: e.image.src,
287
+ src: _ctx.image.src,
174
288
  class: "nut-image-preview-img",
175
- onLoad: t[0] || (t[0] = (...m) => e.imageLoad && e.imageLoad(...m))
176
- }, null, 40, De)) : N("", !0),
177
- e.video && e.video.source ? (p(), I(c, {
289
+ onLoad: _cache[0] || (_cache[0] = (...args) => _ctx.imageLoad && _ctx.imageLoad(...args))
290
+ }, null, 40, _hoisted_1$1)) : createCommentVNode("", true),
291
+ _ctx.video && _ctx.video.source ? (openBlock(), createBlock(_component_nut_video, {
178
292
  key: 1,
179
- source: e.video.source,
180
- options: e.video.options
181
- }, null, 8, ["source", "options"])) : N("", !0)
293
+ source: _ctx.video.source,
294
+ options: _ctx.video.options
295
+ }, null, 8, ["source", "options"])) : createCommentVNode("", true)
182
296
  ], 36)
183
297
  ]),
184
298
  _: 1
185
299
  }, 8, ["onClick"]);
186
300
  }
187
- const ze = /* @__PURE__ */ _(Ze, [["render", We]]), { create: He } = Q("image-preview"), Me = He({
188
- props: P(S({}, x), {
301
+ const ImagePreviewItem = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
302
+ const { create } = createComponent("image-preview");
303
+ const _sfc_main = create({
304
+ props: __spreadProps(__spreadValues({}, baseProps), {
189
305
  images: { type: Array, default: () => [] },
190
306
  videos: { type: Array, default: () => [] },
191
- contentClose: { type: Boolean, default: !0 },
192
- paginationVisible: { type: Boolean, default: !1 },
307
+ contentClose: { type: Boolean, default: true },
308
+ paginationVisible: { type: Boolean, default: false },
193
309
  paginationColor: { type: String, default: "#fff" },
194
310
  autoplay: { type: [Number, String], default: 0 },
195
311
  teleport: { type: [String, Element], default: "body" },
196
- teleportDisable: { ype: Boolean, default: !1 },
312
+ teleportDisable: { ype: Boolean, default: false },
197
313
  closeable: {
198
314
  type: Boolean,
199
- default: !1
315
+ default: false
200
316
  },
201
317
  closeIconPosition: {
202
318
  type: String,
@@ -206,172 +322,212 @@ const ze = /* @__PURE__ */ _(Ze, [["render", We]]), { create: He } = Q("image-pr
206
322
  beforeClose: Function,
207
323
  isLoop: {
208
324
  type: Boolean,
209
- default: !0
325
+ default: true
210
326
  }
211
327
  }),
212
328
  emits: ["close", "change"],
213
329
  components: {
214
- ImagePreviewItem: ze,
215
- CircleClose: Ie,
216
- [L.name]: L,
217
- [A.name]: A
330
+ ImagePreviewItem,
331
+ CircleClose,
332
+ [Popup.name]: Popup,
333
+ [Swiper.name]: Swiper
218
334
  },
219
- setup(e, { emit: t }) {
220
- const o = ge(), a = G({
221
- showPop: e.show,
335
+ setup(props, { emit }) {
336
+ const swipeRef = ref();
337
+ const state = reactive({
338
+ showPop: props.show,
222
339
  active: 0,
223
340
  rootWidth: 0,
224
341
  rootHeight: 0
225
- }), v = w(() => {
226
- const i = "nut-image-preview-close";
227
- return `nut-image-preview-close-icon ${e.closeIconPosition == "top-right" ? `${i}-right` : `${i}-left`}`;
228
- }), C = w(() => Se(e.videos) ? [].concat(e.videos).concat(e.images) : e.images), c = (i) => {
229
- i !== a.active && (a.active = i, t("change", a.active));
230
- }, u = () => {
231
- Ne(e.beforeClose, {
232
- args: [a.active],
233
- done: () => m()
342
+ });
343
+ const iconClasses = computed(() => {
344
+ const pre = "nut-image-preview-close";
345
+ const iconn = props.closeIconPosition == "top-right" ? `${pre}-right` : `${pre}-left`;
346
+ return `nut-image-preview-close-icon ${iconn}`;
347
+ });
348
+ const mergeImages = computed(() => {
349
+ if (isArray(props.videos)) {
350
+ return [].concat(props.videos).concat(props.images);
351
+ }
352
+ return props.images;
353
+ });
354
+ const setActive = (active) => {
355
+ if (active !== state.active) {
356
+ state.active = active;
357
+ emit("change", state.active);
358
+ }
359
+ };
360
+ const onClose = () => {
361
+ funInterceptor(props.beforeClose, {
362
+ args: [state.active],
363
+ done: () => closeDone()
234
364
  });
235
- }, m = () => {
236
- a.showPop = !1, t("close");
237
- }, g = () => {
238
- if (o.value) {
239
- const i = Pe(o.value);
240
- a.rootHeight = i.height, a.rootWidth = i.width;
365
+ };
366
+ const closeDone = () => {
367
+ state.showPop = false;
368
+ emit("close");
369
+ };
370
+ const init = () => {
371
+ if (swipeRef.value) {
372
+ const rect = useRect(swipeRef.value);
373
+ state.rootHeight = rect.height;
374
+ state.rootWidth = rect.width;
241
375
  }
242
376
  };
243
- return Z(
244
- () => e.show,
245
- (i) => {
246
- a.showPop = i, i && (c(e.initNo), g());
377
+ watch(
378
+ () => props.show,
379
+ (val) => {
380
+ state.showPop = val;
381
+ if (val) {
382
+ setActive(props.initNo);
383
+ init();
384
+ }
247
385
  }
248
- ), Z(
249
- () => e.initNo,
250
- (i) => {
251
- i != a.active && c(i);
386
+ );
387
+ watch(
388
+ () => props.initNo,
389
+ (val) => {
390
+ if (val != state.active)
391
+ setActive(val);
252
392
  }
253
- ), ve(() => {
254
- c(e.initNo);
255
- }), P(S({
256
- swipeRef: o
257
- }, J(a)), {
258
- onClose: u,
259
- mergeImages: C,
260
- setActive: c,
261
- iconClasses: v
393
+ );
394
+ onMounted(() => {
395
+ setActive(props.initNo);
396
+ });
397
+ return __spreadProps(__spreadValues({
398
+ swipeRef
399
+ }, toRefs(state)), {
400
+ onClose,
401
+ mergeImages,
402
+ setActive,
403
+ iconClasses
262
404
  });
263
405
  }
264
- }), Re = {
406
+ });
407
+ const _hoisted_1 = {
265
408
  class: "nut-image-preview",
266
409
  ref: "swipeRef"
267
- }, Be = {
410
+ };
411
+ const _hoisted_2 = {
268
412
  key: 0,
269
413
  class: "nut-image-preview-index"
270
414
  };
271
- function Ee(e, t, o, a, v, C) {
272
- const c = y("image-preview-item"), u = y("nut-swiper"), m = y("CircleClose"), g = y("nut-popup");
273
- return p(), I(g, {
415
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
416
+ const _component_image_preview_item = resolveComponent("image-preview-item");
417
+ const _component_nut_swiper = resolveComponent("nut-swiper");
418
+ const _component_CircleClose = resolveComponent("CircleClose");
419
+ const _component_nut_popup = resolveComponent("nut-popup");
420
+ return openBlock(), createBlock(_component_nut_popup, {
274
421
  "pop-class": "nut-image-preview-custom-pop",
275
- visible: e.showPop,
276
- "onUpdate:visible": t[1] || (t[1] = (i) => e.showPop = i),
277
- teleportDisable: e.teleportDisable,
278
- teleport: e.teleport,
279
- onClosed: e.onClose,
422
+ visible: _ctx.showPop,
423
+ "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => _ctx.showPop = $event),
424
+ teleportDisable: _ctx.teleportDisable,
425
+ teleport: _ctx.teleport,
426
+ onClosed: _ctx.onClose,
280
427
  "lock-scroll": ""
281
428
  }, {
282
- default: R(() => [
283
- K("view", Re, [
284
- e.showPop ? (p(), I(u, {
429
+ default: withCtx(() => [
430
+ createElementVNode("view", _hoisted_1, [
431
+ _ctx.showPop ? (openBlock(), createBlock(_component_nut_swiper, {
285
432
  key: 0,
286
- "auto-play": e.autoplay,
433
+ "auto-play": _ctx.autoplay,
287
434
  class: "nut-image-preview-swiper",
288
- loop: e.isLoop,
289
- "is-preventDefault": !1,
435
+ loop: _ctx.isLoop,
436
+ "is-preventDefault": false,
290
437
  direction: "horizontal",
291
- onChange: e.setActive,
292
- "init-page": e.initNo,
293
- "pagination-visible": e.paginationVisible,
294
- "pagination-color": e.paginationColor
438
+ onChange: _ctx.setActive,
439
+ "init-page": _ctx.initNo,
440
+ "pagination-visible": _ctx.paginationVisible,
441
+ "pagination-color": _ctx.paginationColor
295
442
  }, {
296
- default: R(() => [
297
- (p(!0), k(de, null, he(e.mergeImages, (i, d) => (p(), I(c, {
298
- key: d,
299
- video: d < e.videos.length ? i : {},
300
- image: d >= e.videos.length ? i : {},
301
- rootHeight: e.rootHeight,
302
- rootWidth: e.rootWidth,
303
- show: e.showPop,
304
- "init-no": e.active + 1,
305
- onClose: e.onClose,
306
- "content-close": e.contentClose,
307
- maxZoom: e.maxZoom,
308
- minZoom: e.minZoom
309
- }, null, 8, ["video", "image", "rootHeight", "rootWidth", "show", "init-no", "onClose", "content-close", "maxZoom", "minZoom"]))), 128))
443
+ default: withCtx(() => [
444
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.mergeImages, (item, index) => {
445
+ return openBlock(), createBlock(_component_image_preview_item, {
446
+ key: index,
447
+ video: index < _ctx.videos.length ? item : {},
448
+ image: index >= _ctx.videos.length ? item : {},
449
+ rootHeight: _ctx.rootHeight,
450
+ rootWidth: _ctx.rootWidth,
451
+ show: _ctx.showPop,
452
+ "init-no": _ctx.active + 1,
453
+ onClose: _ctx.onClose,
454
+ "content-close": _ctx.contentClose,
455
+ maxZoom: _ctx.maxZoom,
456
+ minZoom: _ctx.minZoom
457
+ }, null, 8, ["video", "image", "rootHeight", "rootWidth", "show", "init-no", "onClose", "content-close", "maxZoom", "minZoom"]);
458
+ }), 128))
310
459
  ]),
311
460
  _: 1
312
- }, 8, ["auto-play", "loop", "onChange", "init-page", "pagination-visible", "pagination-color"])) : N("", !0)
461
+ }, 8, ["auto-play", "loop", "onChange", "init-page", "pagination-visible", "pagination-color"])) : createCommentVNode("", true)
313
462
  ], 512),
314
- e.showIndex ? (p(), k("view", Be, q(e.active + 1) + " / " + q(e.mergeImages.length), 1)) : N("", !0),
315
- e.closeable ? (p(), k("view", {
463
+ _ctx.showIndex ? (openBlock(), createElementBlock("view", _hoisted_2, toDisplayString(_ctx.active + 1) + " / " + toDisplayString(_ctx.mergeImages.length), 1)) : createCommentVNode("", true),
464
+ _ctx.closeable ? (openBlock(), createElementBlock("view", {
316
465
  key: 1,
317
- class: we(e.iconClasses),
318
- onClick: t[0] || (t[0] = (...i) => e.onClose && e.onClose(...i))
466
+ class: normalizeClass(_ctx.iconClasses),
467
+ onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClose && _ctx.onClose(...args))
319
468
  }, [
320
- ye(e.$slots, "close-icon", {}, () => [
321
- Ce(m, { color: "#ffffff" })
469
+ renderSlot(_ctx.$slots, "close-icon", {}, () => [
470
+ createVNode(_component_CircleClose, { color: "#ffffff" })
322
471
  ])
323
- ], 2)) : N("", !0)
472
+ ], 2)) : createCommentVNode("", true)
324
473
  ]),
325
474
  _: 3
326
475
  }, 8, ["visible", "teleportDisable", "teleport", "onClosed"]);
327
476
  }
328
- const ee = /* @__PURE__ */ _(Me, [["render", Ee]]);
329
- class Le {
477
+ const ImagePreview = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
478
+ class ImagePreviewOptions {
330
479
  constructor() {
331
- l(this, "show", !1);
332
- l(this, "images", []);
333
- l(this, "videos", []);
334
- l(this, "contentClose", !0);
335
- l(this, "initNo", 0);
336
- l(this, "paginationVisible", !1);
337
- l(this, "paginationColor", "");
338
- l(this, "autoplay", 0);
339
- l(this, "isWrapTeleport", !1);
340
- l(this, "showIndex", !0);
341
- l(this, "closeable", !1);
342
- l(this, "closeIcon", "circle-close");
343
- l(this, "closeIconPosition", "top-right");
344
- l(this, "beforeClose");
345
- l(this, "maxZoom", 3);
346
- l(this, "minZoom", 1 / 3);
347
- l(this, "isLoop", !0);
348
- l(this, "teleport", "body");
480
+ __publicField(this, "show", false);
481
+ __publicField(this, "images", []);
482
+ __publicField(this, "videos", []);
483
+ __publicField(this, "contentClose", true);
484
+ __publicField(this, "initNo", 0);
485
+ __publicField(this, "paginationVisible", false);
486
+ __publicField(this, "paginationColor", "");
487
+ __publicField(this, "autoplay", 0);
488
+ __publicField(this, "isWrapTeleport", false);
489
+ __publicField(this, "showIndex", true);
490
+ __publicField(this, "closeable", false);
491
+ __publicField(this, "closeIcon", "circle-close");
492
+ __publicField(this, "closeIconPosition", "top-right");
493
+ __publicField(this, "beforeClose");
494
+ __publicField(this, "maxZoom", 3);
495
+ __publicField(this, "minZoom", 1 / 3);
496
+ __publicField(this, "isLoop", true);
497
+ __publicField(this, "teleport", "body");
349
498
  }
350
499
  }
351
- class Ae {
352
- constructor(t) {
353
- l(this, "options", new Le());
354
- const o = Object.assign(this.options, t), { unmount: a } = Xe(o, {
500
+ class ImagePreviewFunction {
501
+ constructor(_options) {
502
+ __publicField(this, "options", new ImagePreviewOptions());
503
+ const options = Object.assign(this.options, _options);
504
+ const { unmount } = CreateComponent(options, {
355
505
  name: "image-preview",
356
- components: [L, B, A, E, Ye],
357
- wrapper: () => ({
358
- setup() {
359
- return () => (o.onClose = () => {
360
- o.show = !1, be(() => {
361
- a();
362
- });
363
- }, Te(ee, o));
364
- }
365
- })
506
+ components: [Popup, Video, Swiper, SwiperItem, Overlay],
507
+ wrapper: () => {
508
+ return {
509
+ setup() {
510
+ return () => {
511
+ options.onClose = () => {
512
+ options.show = false;
513
+ nextTick(() => {
514
+ unmount();
515
+ });
516
+ };
517
+ return h(ImagePreview, options);
518
+ };
519
+ }
520
+ };
521
+ }
366
522
  });
367
523
  }
368
524
  }
369
- const Ve = (e) => new Ae(e);
370
- Ve.install = (e) => {
371
- e.use(ee);
525
+ const showImagePreview = (options) => new ImagePreviewFunction(options);
526
+ showImagePreview.install = (app) => {
527
+ app.use(ImagePreview);
372
528
  };
373
529
  export {
374
- Le as ImagePreviewOptions,
375
- ee as default,
376
- Ve as showImagePreview
530
+ ImagePreviewOptions,
531
+ ImagePreview as default,
532
+ showImagePreview
377
533
  };