zartui 3.0.3 → 3.0.5

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 (220) hide show
  1. package/README.md +25 -0
  2. package/es/action-sheet/index.css +1 -1
  3. package/es/avatar/Avatar.d.ts +5 -1
  4. package/es/avatar/Avatar.mjs +9 -4
  5. package/es/avatar/index.css +1 -1
  6. package/es/avatar/index.d.ts +4 -1
  7. package/es/badge/Badge.d.ts +1 -1
  8. package/es/badge/index.d.ts +1 -1
  9. package/es/button/index.css +1 -1
  10. package/es/calendar/Calendar.mjs +2 -2
  11. package/es/calendar/index.css +1 -1
  12. package/es/cascader/index.css +1 -1
  13. package/es/cell/index.css +1 -1
  14. package/es/cell-group/CellGroup.d.ts +1 -1
  15. package/es/cell-group/index.d.ts +1 -1
  16. package/es/checkbox/index.css +1 -1
  17. package/es/col/Col.d.ts +1 -1
  18. package/es/col/index.d.ts +1 -1
  19. package/es/collapse-item/CollapseItem.d.ts +1 -1
  20. package/es/collapse-item/index.d.ts +1 -1
  21. package/es/config-provider/ConfigProvider.d.ts +1 -1
  22. package/es/config-provider/index.d.ts +2 -2
  23. package/es/dialog/index.css +1 -1
  24. package/es/divider/Divider.d.ts +1 -1
  25. package/es/divider/index.d.ts +1 -1
  26. package/es/dropdown-menu/DropdownMenu.d.ts +1 -1
  27. package/es/dropdown-menu/index.d.ts +1 -1
  28. package/es/empty/Empty.d.ts +1 -1
  29. package/es/empty/index.d.ts +1 -1
  30. package/es/field/index.css +1 -1
  31. package/es/grid/Grid.d.ts +1 -1
  32. package/es/grid/index.d.ts +1 -1
  33. package/es/grid-item/GridItem.d.ts +1 -1
  34. package/es/grid-item/index.css +1 -1
  35. package/es/grid-item/index.d.ts +1 -1
  36. package/es/icon/Icon.d.ts +1 -1
  37. package/es/icon/config.mjs +3 -2
  38. package/es/icon/index.css +1 -1
  39. package/es/icon/index.d.ts +1 -1
  40. package/es/image-preview/ImagePreview.d.ts +2 -1
  41. package/es/image-preview/ImagePreview.mjs +9 -4
  42. package/es/image-preview/ImagePreviewItem.d.ts +2 -1
  43. package/es/image-preview/ImagePreviewItem.mjs +22 -13
  44. package/es/image-preview/index.css +1 -1
  45. package/es/image-preview/index.d.ts +2 -1
  46. package/es/index.d.ts +1 -1
  47. package/es/index.mjs +1 -1
  48. package/es/lazyload/vue-lazyload/lazy-image.mjs +5 -5
  49. package/es/loading/Loading.d.ts +1 -1
  50. package/es/loading/index.d.ts +1 -1
  51. package/es/media-picker/MediaPicker.mjs +1 -1
  52. package/es/media-picker/image/DefaultAudioIcon.d.ts +1 -1
  53. package/es/media-picker/image/DefaultFileIcon.d.ts +1 -1
  54. package/es/media-picker/image/DefaultVideoIcon.d.ts +1 -1
  55. package/es/media-picker/image/DeleteIcon.d.ts +1 -1
  56. package/es/media-picker/image/PickFileIcon.d.ts +1 -1
  57. package/es/media-picker/image/PickPhotoIcon.d.ts +1 -1
  58. package/es/media-picker/image/TakeAudioIcon.d.ts +1 -1
  59. package/es/media-picker/image/TakePhotoIcon.d.ts +1 -1
  60. package/es/media-picker/image/TakeVideoIcon.d.ts +1 -1
  61. package/es/media-picker/util/media-util.d.ts +17 -2
  62. package/es/media-picker/util/media-util.mjs +137 -10
  63. package/es/media-picker/watermark/image-processor.mjs +28 -3
  64. package/es/media-picker/watermark/watermark.mjs +3 -3
  65. package/es/multiple-picker/MultiplePicker.mjs +1 -2
  66. package/es/multiple-picker/index.css +1 -1
  67. package/es/multiple-picker/types.d.ts +2 -1
  68. package/es/nav-bar/index.css +1 -1
  69. package/es/overlay/Overlay.d.ts +1 -1
  70. package/es/overlay/index.d.ts +1 -1
  71. package/es/picker/PickerColumn.mjs +5 -4
  72. package/es/picker/index.css +1 -1
  73. package/es/popup/Popup.d.ts +26 -0
  74. package/es/popup/Popup.mjs +12 -10
  75. package/es/popup/index.css +1 -1
  76. package/es/popup/index.d.ts +18 -0
  77. package/es/radio/index.css +1 -1
  78. package/es/row/Row.d.ts +1 -1
  79. package/es/row/index.d.ts +1 -1
  80. package/es/search/index.css +1 -1
  81. package/es/skeleton/Skeleton.d.ts +1 -1
  82. package/es/skeleton/index.d.ts +1 -1
  83. package/es/step/Step.d.ts +1 -1
  84. package/es/step/index.d.ts +1 -1
  85. package/es/stepper/Stepper.d.ts +1 -1
  86. package/es/stepper/Stepper.mjs +1 -2
  87. package/es/stepper/index.d.ts +1 -1
  88. package/es/style/base.css +1 -1
  89. package/es/style/css-variables.css +1 -1
  90. package/es/swipe/Swipe.mjs +1 -3
  91. package/es/swipe-item/SwipeItem.d.ts +1 -1
  92. package/es/swipe-item/index.d.ts +1 -1
  93. package/es/tab/Tab.d.ts +1 -1
  94. package/es/tab/index.d.ts +1 -1
  95. package/es/tabbar-item/index.css +1 -1
  96. package/es/tabs/TabsTitle.d.ts +1 -1
  97. package/es/tabs/index.css +1 -1
  98. package/es/time-picker/index.css +1 -1
  99. package/es/toast/index.css +1 -1
  100. package/es/utils/constant.d.ts +1 -0
  101. package/es/utils/constant.mjs +3 -1
  102. package/es/utils/mount-component.d.ts +1 -1
  103. package/lib/action-sheet/index.css +1 -1
  104. package/lib/avatar/Avatar.d.ts +5 -1
  105. package/lib/avatar/Avatar.js +9 -4
  106. package/lib/avatar/index.css +1 -1
  107. package/lib/avatar/index.d.ts +4 -1
  108. package/lib/badge/Badge.d.ts +1 -1
  109. package/lib/badge/index.d.ts +1 -1
  110. package/lib/button/index.css +1 -1
  111. package/lib/calendar/Calendar.js +2 -2
  112. package/lib/calendar/index.css +1 -1
  113. package/lib/cascader/index.css +1 -1
  114. package/lib/cell/index.css +1 -1
  115. package/lib/cell-group/CellGroup.d.ts +1 -1
  116. package/lib/cell-group/index.d.ts +1 -1
  117. package/lib/checkbox/index.css +1 -1
  118. package/lib/col/Col.d.ts +1 -1
  119. package/lib/col/index.d.ts +1 -1
  120. package/lib/collapse-item/CollapseItem.d.ts +1 -1
  121. package/lib/collapse-item/index.d.ts +1 -1
  122. package/lib/config-provider/ConfigProvider.d.ts +1 -1
  123. package/lib/config-provider/index.d.ts +2 -2
  124. package/lib/dialog/index.css +1 -1
  125. package/lib/divider/Divider.d.ts +1 -1
  126. package/lib/divider/index.d.ts +1 -1
  127. package/lib/dropdown-menu/DropdownMenu.d.ts +1 -1
  128. package/lib/dropdown-menu/index.d.ts +1 -1
  129. package/lib/empty/Empty.d.ts +1 -1
  130. package/lib/empty/index.d.ts +1 -1
  131. package/lib/field/index.css +1 -1
  132. package/lib/grid/Grid.d.ts +1 -1
  133. package/lib/grid/index.d.ts +1 -1
  134. package/lib/grid-item/GridItem.d.ts +1 -1
  135. package/lib/grid-item/index.css +1 -1
  136. package/lib/grid-item/index.d.ts +1 -1
  137. package/lib/icon/Icon.d.ts +1 -1
  138. package/lib/icon/config.js +3 -2
  139. package/lib/icon/index.css +1 -1
  140. package/lib/icon/index.d.ts +1 -1
  141. package/lib/image-preview/ImagePreview.d.ts +2 -1
  142. package/lib/image-preview/ImagePreview.js +9 -4
  143. package/lib/image-preview/ImagePreviewItem.d.ts +2 -1
  144. package/lib/image-preview/ImagePreviewItem.js +21 -12
  145. package/lib/image-preview/index.css +1 -1
  146. package/lib/image-preview/index.d.ts +2 -1
  147. package/lib/index.css +1 -1
  148. package/lib/index.d.ts +1 -1
  149. package/lib/index.js +1 -1
  150. package/lib/lazyload/vue-lazyload/lazy-image.js +6 -6
  151. package/lib/loading/Loading.d.ts +1 -1
  152. package/lib/loading/index.d.ts +1 -1
  153. package/lib/media-picker/MediaPicker.js +1 -1
  154. package/lib/media-picker/image/DefaultAudioIcon.d.ts +1 -1
  155. package/lib/media-picker/image/DefaultFileIcon.d.ts +1 -1
  156. package/lib/media-picker/image/DefaultVideoIcon.d.ts +1 -1
  157. package/lib/media-picker/image/DeleteIcon.d.ts +1 -1
  158. package/lib/media-picker/image/PickFileIcon.d.ts +1 -1
  159. package/lib/media-picker/image/PickPhotoIcon.d.ts +1 -1
  160. package/lib/media-picker/image/TakeAudioIcon.d.ts +1 -1
  161. package/lib/media-picker/image/TakePhotoIcon.d.ts +1 -1
  162. package/lib/media-picker/image/TakeVideoIcon.d.ts +1 -1
  163. package/lib/media-picker/util/media-util.d.ts +17 -2
  164. package/lib/media-picker/util/media-util.js +137 -10
  165. package/lib/media-picker/watermark/image-processor.js +22 -2
  166. package/lib/media-picker/watermark/watermark.js +5 -5
  167. package/lib/multiple-picker/MultiplePicker.js +1 -2
  168. package/lib/multiple-picker/index.css +1 -1
  169. package/lib/multiple-picker/types.d.ts +2 -1
  170. package/lib/nav-bar/index.css +1 -1
  171. package/lib/overlay/Overlay.d.ts +1 -1
  172. package/lib/overlay/index.d.ts +1 -1
  173. package/lib/picker/PickerColumn.js +5 -4
  174. package/lib/picker/index.css +1 -1
  175. package/lib/popup/Popup.d.ts +26 -0
  176. package/lib/popup/Popup.js +11 -9
  177. package/lib/popup/index.css +1 -1
  178. package/lib/popup/index.d.ts +18 -0
  179. package/lib/radio/index.css +1 -1
  180. package/lib/row/Row.d.ts +1 -1
  181. package/lib/row/index.d.ts +1 -1
  182. package/lib/search/index.css +1 -1
  183. package/lib/skeleton/Skeleton.d.ts +1 -1
  184. package/lib/skeleton/index.d.ts +1 -1
  185. package/lib/step/Step.d.ts +1 -1
  186. package/lib/step/index.d.ts +1 -1
  187. package/lib/stepper/Stepper.d.ts +1 -1
  188. package/lib/stepper/Stepper.js +1 -2
  189. package/lib/stepper/index.d.ts +1 -1
  190. package/lib/style/base.css +1 -1
  191. package/lib/style/css-variables.css +1 -1
  192. package/lib/swipe/Swipe.js +1 -3
  193. package/lib/swipe-item/SwipeItem.d.ts +1 -1
  194. package/lib/swipe-item/index.d.ts +1 -1
  195. package/lib/tab/Tab.d.ts +1 -1
  196. package/lib/tab/index.d.ts +1 -1
  197. package/lib/tabbar-item/index.css +1 -1
  198. package/lib/tabs/TabsTitle.d.ts +1 -1
  199. package/lib/tabs/index.css +1 -1
  200. package/lib/time-picker/index.css +1 -1
  201. package/lib/toast/index.css +1 -1
  202. package/lib/utils/constant.d.ts +1 -0
  203. package/lib/utils/constant.js +3 -1
  204. package/lib/utils/mount-component.d.ts +1 -1
  205. package/lib/web-types.json +1 -1
  206. package/lib/zartui.cjs.js +217 -144
  207. package/lib/zartui.es.js +215 -142
  208. package/lib/zartui.js +251 -112
  209. package/lib/zartui.min.js +1 -1
  210. package/package.json +4 -3
  211. package/es/media-picker/util/orientation-util.d.ts +0 -37
  212. package/es/media-picker/util/orientation-util.mjs +0 -118
  213. package/es/tabbar/image/common-normal.png +0 -0
  214. package/es/utils/date.d.ts +0 -29
  215. package/es/utils/date.mjs +0 -96
  216. package/lib/media-picker/util/orientation-util.d.ts +0 -37
  217. package/lib/media-picker/util/orientation-util.js +0 -137
  218. package/lib/tabbar/image/common-normal.png +0 -0
  219. package/lib/utils/date.d.ts +0 -29
  220. package/lib/utils/date.js +0 -115
package/lib/zartui.es.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { useWindowSize, useRect, onMountedOrActivated, getScrollParent, useEventListener, useToggle, raf, useScrollParent, useChildren, usePageVisibility, doubleRaf, useParent, useCustomFieldValue, useClickAway, CUSTOM_FIELD_INJECTION_KEY, inBrowser as inBrowser$1 } from "@zartui/use";
2
2
  import { unref, ref, reactive, defineComponent, computed, createVNode, watch, onActivated, onDeactivated, onBeforeUnmount, provide, inject, mergeProps, getCurrentInstance, Transition, withDirectives, vShow, nextTick, onMounted, Teleport, Fragment, resolveDirective, onBeforeUpdate, onUnmounted, createApp, createTextVNode, watchEffect, withKeys, onUpdated, h } from "vue";
3
+ import { DATE_FORMAT, formatDate } from "@zartui/date-utils";
3
4
  import { offsetModifier, createPopper } from "@zartui/popperjs";
4
5
  const isDef = (val) => val !== void 0 && val !== null;
5
6
  const isFunction = (val) => typeof val === "function";
@@ -367,6 +368,7 @@ const BORDER_TOP_BOTTOM = `${BORDER}--top-bottom`;
367
368
  const HAPTICS_FEEDBACK = "zt-haptics-feedback";
368
369
  const ELLIPSIS = "zt-ellipsis";
369
370
  const FORM_KEY = Symbol("zt-form");
371
+ const LONG_PRESS_START_TIME = 500;
370
372
  function callInterceptor(interceptor, {
371
373
  args = [],
372
374
  done,
@@ -814,6 +816,8 @@ const popupProps$2 = extend({}, popupSharedProps, {
814
816
  safeAreaInsetTop: Boolean,
815
817
  safeAreaInsetBottom: Boolean,
816
818
  sliderContentHeight: makeNumberProp(60),
819
+ minDragHeight: makeStringProp("40px"),
820
+ maxDragHeight: makeStringProp("85vh"),
817
821
  slideable: Boolean
818
822
  });
819
823
  const [name$16, bem$13] = createNamespace("popup");
@@ -831,15 +835,13 @@ var stdin_default$1x = defineComponent({
831
835
  let opened;
832
836
  let shouldReopen;
833
837
  const root = ref();
834
- const positionY = ref(0);
835
838
  let timerId = setInterval(() => {
836
839
  }, 0);
837
- const touchHeight = ref(0);
838
840
  const contentStyle = ref(`height:${props.sliderContentHeight}px;`);
839
- const touchAreaHeight = ref(40);
840
841
  const zIndex = ref();
841
- const touchPoint = ref(0);
842
842
  const popupRef = ref();
843
+ let touchPoint = 0;
844
+ const touchAreaHeight = unitToPx(props.minDragHeight);
843
845
  const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
844
846
  const style = computed(() => {
845
847
  const style2 = {
@@ -886,13 +888,14 @@ var stdin_default$1x = defineComponent({
886
888
  event.preventDefault();
887
889
  }
888
890
  const h2 = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
889
- positionY.value = event.touches[0].clientY;
891
+ const positionY = event.touches[0].clientY || 0;
892
+ let touchHeight = 0;
890
893
  timerId = setTimeout(() => {
891
- if (positionY.value === 0 || positionY.value < h2 * 0.15) {
894
+ if (positionY === 0 || positionY < h2 - unitToPx(props.maxDragHeight)) {
892
895
  return;
893
896
  }
894
- touchHeight.value = positionY.value - touchAreaHeight.value > h2 - touchAreaHeight.value ? h2 - touchAreaHeight.value + touchPoint.value : positionY.value;
895
- contentStyle.value = `height:${h2 - touchHeight.value - touchAreaHeight.value + touchPoint.value}px;`;
897
+ touchHeight = positionY - touchAreaHeight > h2 - touchAreaHeight ? h2 - touchAreaHeight + touchPoint : positionY;
898
+ contentStyle.value = `height:${h2 - touchHeight - touchAreaHeight + touchPoint}px;`;
896
899
  }, 10);
897
900
  };
898
901
  const startMove = (event) => {
@@ -900,7 +903,7 @@ var stdin_default$1x = defineComponent({
900
903
  if (timerId) {
901
904
  clearInterval(timerId);
902
905
  }
903
- touchPoint.value = event.touches[0].clientY - (((_b = (_a = popupRef.value) == null ? void 0 : _a.getBoundingClientRect()) == null ? void 0 : _b.top) || 0);
906
+ touchPoint = event.touches[0].clientY - (((_b = (_a = popupRef.value) == null ? void 0 : _a.getBoundingClientRect()) == null ? void 0 : _b.top) || 0);
904
907
  };
905
908
  const endMove = () => {
906
909
  clearInterval(timerId);
@@ -977,6 +980,7 @@ var stdin_default$1x = defineComponent({
977
980
  "onKeydown": onKeydown
978
981
  }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), renderCloseIcon(), createVNode("div", {
979
982
  "class": bem$13("slider-title"),
983
+ "style": `height:${touchAreaHeight}px;`,
980
984
  "ref": root
981
985
  }, [createVNode("div", {
982
986
  "class": bem$13("slider-bar")
@@ -1472,7 +1476,8 @@ const avatarProps = {
1472
1476
  size: makeStringProp("medium"),
1473
1477
  shape: makeStringProp("square"),
1474
1478
  text: String,
1475
- textBgColor: String
1479
+ textBgColor: String,
1480
+ border: Boolean
1476
1481
  };
1477
1482
  var stdin_default$1p = defineComponent({
1478
1483
  name: name$12,
@@ -1485,7 +1490,7 @@ var stdin_default$1p = defineComponent({
1485
1490
  if (len === 1) {
1486
1491
  return props.text;
1487
1492
  } else if (len > 1) {
1488
- return props.text.substring(len - 2, 2);
1493
+ return props.text.substring(len - 2, len);
1489
1494
  }
1490
1495
  }
1491
1496
  return "";
@@ -1506,7 +1511,9 @@ var stdin_default$1p = defineComponent({
1506
1511
  }
1507
1512
  });
1508
1513
  const renderText = () => createVNode("div", {
1509
- "class": bem$$("img", classArr.value),
1514
+ "class": bem$$("img", [classArr.value, {
1515
+ border: props.border
1516
+ }]),
1510
1517
  "style": style.value
1511
1518
  }, [headText.value]);
1512
1519
  return () => {
@@ -1515,7 +1522,9 @@ var stdin_default$1p = defineComponent({
1515
1522
  }
1516
1523
  return createVNode(stdin_default$1q, {
1517
1524
  "round": props.shape === "round",
1518
- "class": bem$$("img", classArr.value),
1525
+ "class": bem$$("img", [classArr.value, {
1526
+ border: props.border
1527
+ }]),
1519
1528
  "style": style.value,
1520
1529
  "src": props.src
1521
1530
  }, {
@@ -2734,7 +2743,7 @@ var stdin_default$1i = defineComponent({
2734
2743
  "onClick": onCancel,
2735
2744
  "style": {
2736
2745
  marginRight: "4px",
2737
- backgroundColor: "white"
2746
+ backgroundColor: "transparent"
2738
2747
  }
2739
2748
  }, {
2740
2749
  default: () => [text || "\u53D6\u6D88"]
@@ -2755,7 +2764,7 @@ var stdin_default$1i = defineComponent({
2755
2764
  };
2756
2765
  const renderFooter = () => createVNode("div", {
2757
2766
  "class": [bem$Z("footer"), {
2758
- "van-safe-area-bottom": props.safeAreaInsetBottom
2767
+ "zt-safe-area-bottom": props.safeAreaInsetBottom
2759
2768
  }]
2760
2769
  }, [renderFooterButton()]);
2761
2770
  const renderCalendar = () => createVNode("div", {
@@ -3108,8 +3117,7 @@ var stdin_default$1f = defineComponent({
3108
3117
  const touch = useTouch();
3109
3118
  const {
3110
3119
  children,
3111
- linkChildren,
3112
- unlinkChildren
3120
+ linkChildren
3113
3121
  } = useChildren(SWIPE_KEY);
3114
3122
  const count = computed(() => children.length);
3115
3123
  const size = computed(() => state[props.vertical ? "height" : "width"]);
@@ -3409,7 +3417,6 @@ var stdin_default$1f = defineComponent({
3409
3417
  onMounted(initialize);
3410
3418
  onActivated(() => initialize(state.active));
3411
3419
  onPopupReopen(() => {
3412
- unlinkChildren();
3413
3420
  initialize(state.active);
3414
3421
  });
3415
3422
  onDeactivated(stopAutoplay);
@@ -5255,8 +5262,9 @@ var stdin_default$$ = defineComponent({
5255
5262
  }
5256
5263
  currentOffset.value = offset;
5257
5264
  };
5265
+ const isReadonly = () => props.readonly || !props.options.length;
5258
5266
  const onClickOption = (index) => {
5259
- if (moving || props.readonly) {
5267
+ if (moving || isReadonly()) {
5260
5268
  return;
5261
5269
  }
5262
5270
  transitionEndTrigger = null;
@@ -5281,7 +5289,7 @@ var stdin_default$$ = defineComponent({
5281
5289
  }
5282
5290
  };
5283
5291
  const onTouchStart = (event) => {
5284
- if (props.readonly) {
5292
+ if (isReadonly()) {
5285
5293
  return;
5286
5294
  }
5287
5295
  touch.start(event);
@@ -5296,7 +5304,7 @@ var stdin_default$$ = defineComponent({
5296
5304
  transitionEndTrigger = null;
5297
5305
  };
5298
5306
  const onTouchMove = (event) => {
5299
- if (props.readonly) {
5307
+ if (isReadonly()) {
5300
5308
  return;
5301
5309
  }
5302
5310
  touch.move(event);
@@ -5312,7 +5320,7 @@ var stdin_default$$ = defineComponent({
5312
5320
  }
5313
5321
  };
5314
5322
  const onTouchEnd = () => {
5315
- if (props.readonly) {
5323
+ if (isReadonly()) {
5316
5324
  return;
5317
5325
  }
5318
5326
  const distance = currentOffset.value - momentumOffset;
@@ -9200,9 +9208,10 @@ var stdin_default$H = defineComponent({
9200
9208
  rootWidth: makeRequiredProp(Number),
9201
9209
  rootHeight: makeRequiredProp(Number)
9202
9210
  },
9203
- emits: ["scale", "close"],
9211
+ emits: ["scale", "close", "longPress"],
9204
9212
  setup(props, {
9205
- emit
9213
+ emit,
9214
+ slots
9206
9215
  }) {
9207
9216
  const state = reactive({
9208
9217
  scale: 1,
@@ -9346,16 +9355,20 @@ var stdin_default$H = defineComponent({
9346
9355
  const deltaTime = Date.now() - touchStartTime;
9347
9356
  const TAP_TIME = 250;
9348
9357
  const TAP_OFFSET = 5;
9349
- if (offsetX.value < TAP_OFFSET && offsetY.value < TAP_OFFSET && deltaTime < TAP_TIME) {
9350
- if (doubleTapTimer) {
9351
- clearTimeout(doubleTapTimer);
9352
- doubleTapTimer = null;
9353
- toggleScale();
9354
- } else {
9355
- doubleTapTimer = setTimeout(() => {
9356
- emit("close");
9358
+ if (offsetX.value < TAP_OFFSET && offsetY.value < TAP_OFFSET) {
9359
+ if (deltaTime < TAP_TIME) {
9360
+ if (doubleTapTimer) {
9361
+ clearTimeout(doubleTapTimer);
9357
9362
  doubleTapTimer = null;
9358
- }, TAP_TIME);
9363
+ toggleScale();
9364
+ } else {
9365
+ doubleTapTimer = setTimeout(() => {
9366
+ emit("close");
9367
+ doubleTapTimer = null;
9368
+ }, TAP_TIME);
9369
+ }
9370
+ } else if (deltaTime > LONG_PRESS_START_TIME) {
9371
+ emit("longPress");
9359
9372
  }
9360
9373
  }
9361
9374
  };
@@ -9421,7 +9434,11 @@ var stdin_default$H = defineComponent({
9421
9434
  "onTouchend": onTouchEnd,
9422
9435
  "onTouchcancel": onTouchEnd
9423
9436
  }, {
9424
- default: () => [createVNode(Image$1, {
9437
+ default: () => [slots.image ? createVNode("div", {
9438
+ "class": bem$s("image-wrap")
9439
+ }, [slots.image({
9440
+ src: props.src
9441
+ })]) : createVNode(Image$1, {
9425
9442
  "src": props.src,
9426
9443
  "fit": "contain",
9427
9444
  "class": bem$s("image", {
@@ -9460,7 +9477,7 @@ const imagePreviewProps = {
9460
9477
  var stdin_default$G = defineComponent({
9461
9478
  name: name$r,
9462
9479
  props: imagePreviewProps,
9463
- emits: ["scale", "close", "closed", "change", "update:show"],
9480
+ emits: ["scale", "close", "closed", "change", "longPress", "update:show"],
9464
9481
  setup(props, {
9465
9482
  emit,
9466
9483
  slots
@@ -9536,7 +9553,7 @@ var stdin_default$G = defineComponent({
9536
9553
  "indicatorColor": "white",
9537
9554
  "onChange": setActive
9538
9555
  }, {
9539
- default: () => [props.images.map((image) => createVNode(stdin_default$H, {
9556
+ default: () => [props.images.map((image, index) => createVNode(stdin_default$H, {
9540
9557
  "src": image.url,
9541
9558
  "show": props.show,
9542
9559
  "active": state.active,
@@ -9545,8 +9562,13 @@ var stdin_default$G = defineComponent({
9545
9562
  "rootWidth": state.rootWidth,
9546
9563
  "rootHeight": state.rootHeight,
9547
9564
  "onScale": emitScale,
9548
- "onClose": emitClose
9549
- }, null))]
9565
+ "onClose": emitClose,
9566
+ "onLongPress": () => emit("longPress", {
9567
+ index
9568
+ })
9569
+ }, {
9570
+ image: slots.image
9571
+ }))]
9550
9572
  });
9551
9573
  const renderClose = () => {
9552
9574
  if (props.closeable) {
@@ -10357,6 +10379,47 @@ function getUniqueFileName(file, suffix = "") {
10357
10379
  )}`;
10358
10380
  return suffix ? name2 + "." + suffix : name2;
10359
10381
  }
10382
+ function adjustImgOrientation(ctx, img, orientation, width, height) {
10383
+ switch (orientation) {
10384
+ case 3:
10385
+ ctx.rotate(180 * Math.PI / 180);
10386
+ ctx.drawImage(img, -width, -height, width, height);
10387
+ break;
10388
+ case 6:
10389
+ ctx.rotate(90 * Math.PI / 180);
10390
+ ctx.drawImage(img, 0, -width, height, width);
10391
+ break;
10392
+ case 8:
10393
+ ctx.rotate(270 * Math.PI / 180);
10394
+ ctx.drawImage(img, -height, 0, height, width);
10395
+ break;
10396
+ case 2:
10397
+ ctx.translate(width, 0);
10398
+ ctx.scale(-1, 1);
10399
+ ctx.drawImage(img, 0, 0, width, height);
10400
+ break;
10401
+ case 4:
10402
+ ctx.translate(width, 0);
10403
+ ctx.scale(-1, 1);
10404
+ ctx.rotate(180 * Math.PI / 180);
10405
+ ctx.drawImage(img, -width, -height, width, height);
10406
+ break;
10407
+ case 5:
10408
+ ctx.translate(width, 0);
10409
+ ctx.scale(-1, 1);
10410
+ ctx.rotate(90 * Math.PI / 180);
10411
+ ctx.drawImage(img, 0, -width, height, width);
10412
+ break;
10413
+ case 7:
10414
+ ctx.translate(width, 0);
10415
+ ctx.scale(-1, 1);
10416
+ ctx.rotate(270 * Math.PI / 180);
10417
+ ctx.drawImage(img, -height, 0, height, width);
10418
+ break;
10419
+ default:
10420
+ ctx.drawImage(img, 0, 0, width, height);
10421
+ }
10422
+ }
10360
10423
  function file2DataURL(file) {
10361
10424
  return new Promise((resolve, reject) => {
10362
10425
  const a = new FileReader();
@@ -10385,7 +10448,7 @@ function file2Image(file) {
10385
10448
  }).catch(reject);
10386
10449
  });
10387
10450
  }
10388
- function image2Canvas(img, width, height) {
10451
+ function image2Canvas(img, type, orientation, width, height) {
10389
10452
  const canvas = document.createElement("canvas");
10390
10453
  const _width = width || img.width;
10391
10454
  const _height = height || img.height;
@@ -10393,9 +10456,12 @@ function image2Canvas(img, width, height) {
10393
10456
  canvas.height = _height;
10394
10457
  const ctx = canvas.getContext("2d");
10395
10458
  if (ctx) {
10396
- ctx.fillStyle = "#fff";
10459
+ ctx.fillStyle = "transparent";
10460
+ if (type === "image/jpeg") {
10461
+ ctx.fillStyle = "#fff";
10462
+ }
10397
10463
  ctx.fillRect(0, 0, _width, _height);
10398
- ctx.drawImage(img, 0, 0, _width, _height);
10464
+ adjustImgOrientation(ctx, img, orientation, _width, _height);
10399
10465
  return Promise.resolve(canvas);
10400
10466
  }
10401
10467
  return Promise.reject(new Error("canvas getContext return null"));
@@ -10421,7 +10487,74 @@ function canvas2Image(canvas, type = "image/jpeg", quality = 0.8) {
10421
10487
  image.src = canvas.toDataURL(type, quality);
10422
10488
  return Promise.resolve(image);
10423
10489
  }
10490
+ function getStringFromCharCode(dataView, start, length) {
10491
+ let str = "";
10492
+ let i;
10493
+ length += start;
10494
+ for (i = start; i < length; i += 1) {
10495
+ str += String.fromCharCode(dataView.getUint8(i));
10496
+ }
10497
+ return str;
10498
+ }
10499
+ function getOrientation(arrayBuffer) {
10500
+ const dataView = new DataView(arrayBuffer);
10501
+ let orientation;
10502
+ try {
10503
+ let littleEndian;
10504
+ let app1Start;
10505
+ let ifdStart;
10506
+ if (dataView.getUint8(0) === 255 && dataView.getUint8(1) === 216) {
10507
+ const length = dataView.byteLength;
10508
+ let offset = 2;
10509
+ while (offset + 1 < length) {
10510
+ if (dataView.getUint8(offset) === 255 && dataView.getUint8(offset + 1) === 225) {
10511
+ app1Start = offset;
10512
+ break;
10513
+ }
10514
+ offset += 1;
10515
+ }
10516
+ }
10517
+ if (app1Start) {
10518
+ const exifIDCode = app1Start + 4;
10519
+ const tiffOffset = app1Start + 10;
10520
+ if (getStringFromCharCode(dataView, exifIDCode, 4) === "Exif") {
10521
+ const endianness = dataView.getUint16(tiffOffset);
10522
+ littleEndian = endianness === 18761;
10523
+ if (littleEndian || endianness === 19789) {
10524
+ if (dataView.getUint16(tiffOffset + 2, littleEndian) === 42) {
10525
+ const firstIFDOffset = dataView.getUint32(
10526
+ tiffOffset + 4,
10527
+ littleEndian
10528
+ );
10529
+ if (firstIFDOffset >= 8) {
10530
+ ifdStart = tiffOffset + firstIFDOffset;
10531
+ }
10532
+ }
10533
+ }
10534
+ }
10535
+ }
10536
+ if (ifdStart) {
10537
+ const _length = dataView.getUint16(ifdStart, littleEndian);
10538
+ let _offset;
10539
+ let i;
10540
+ for (i = 0; i < _length; i += 1) {
10541
+ _offset = ifdStart + i * 12 + 2;
10542
+ if (dataView.getUint16(_offset, littleEndian) === 274) {
10543
+ _offset += 8;
10544
+ orientation = dataView.getUint16(_offset, littleEndian);
10545
+ dataView.setUint16(_offset, 1, littleEndian);
10546
+ break;
10547
+ }
10548
+ }
10549
+ }
10550
+ } catch (e) {
10551
+ orientation = 1;
10552
+ }
10553
+ return orientation;
10554
+ }
10424
10555
  function resize(img, {
10556
+ inputType = "image/jpeg",
10557
+ orientation = 1,
10425
10558
  imageWidth = -1,
10426
10559
  imageHeight = -1,
10427
10560
  sideLengthLimit = 640,
@@ -10439,14 +10572,18 @@ function resize(img, {
10439
10572
  } else {
10440
10573
  return Promise.reject(new Error("image width/height \u65E0\u6548"));
10441
10574
  }
10442
- const targetWidth = imageWidth * scale;
10443
- const targetHeight = imageHeight * scale;
10575
+ const targetWidth = scale > 1 ? imageWidth : imageWidth * scale;
10576
+ const targetHeight = scale > 1 ? imageHeight : imageHeight * scale;
10444
10577
  if (resultType === "image") {
10445
- return image2Canvas(img, targetWidth, targetHeight).then(
10446
- (canvas) => canvas2Image(canvas)
10447
- );
10578
+ return image2Canvas(
10579
+ img,
10580
+ inputType,
10581
+ orientation,
10582
+ targetWidth,
10583
+ targetHeight
10584
+ ).then((canvas) => canvas2Image(canvas));
10448
10585
  }
10449
- return image2Canvas(img, targetWidth, targetHeight);
10586
+ return image2Canvas(img, inputType, orientation, targetWidth, targetHeight);
10450
10587
  }
10451
10588
  class ResizeOptions {
10452
10589
  constructor(maxSideLength) {
@@ -10486,86 +10623,6 @@ const parseDecimal = (obj, defaultValue) => {
10486
10623
  }
10487
10624
  return result;
10488
10625
  };
10489
- const FORMAT = {
10490
- FORMAT_HM: "HH:mm",
10491
- FORMAT_MDHM: "MM-dd HH:mm",
10492
- FORMAT_MD_CN: "MM\u6708dd\u65E5",
10493
- FORMAT_MD: "MM-dd",
10494
- FORMAT_YMD: "yyyy-MM-dd",
10495
- FORMAT_YMD_SLASH: "yyyy/MM/dd",
10496
- FORMAT_YM: "yyyy-MM",
10497
- FORMAT_YMDHM: "yyyy-MM-dd HH:mm",
10498
- FORMAT_YMDHMS: "yyyy-MM-dd HH:mm:ss",
10499
- FORMAT_YMDHMSMS: "yyyy-MM-dd HH:mm:ss msms",
10500
- FORMAT_YM_CN: "yyyy\u5E74MM\u6708",
10501
- FORMAT_YMD_CN: "yyyy\u5E74MM\u6708dd\u65E5",
10502
- FORMAT_YMDH_CN: "yyyy\u5E74MM\u6708dd\u65E5 HH\u65F6",
10503
- FORMAT_MDH_CN: "MM\u6708dd\u65E5 HH\u65F6",
10504
- FORMAT_YMDHM_CN: "yyyy\u5E74MM\u6708dd\u65E5 HH\u65F6mm\u5206",
10505
- FORMAT_YMDHMS_CN: "yyyy\u5E74MM\u6708dd\u65E5 HH\u65F6mm\u5206ss\u79D2"
10506
- };
10507
- const __formatNumber__ = function(number) {
10508
- if (number < 10) {
10509
- return "0" + number;
10510
- }
10511
- return number + "";
10512
- };
10513
- function createDate(dateObj) {
10514
- if (!isDef(dateObj)) {
10515
- return null;
10516
- }
10517
- if (typeof dateObj === "number") {
10518
- return new Date(dateObj);
10519
- }
10520
- if (typeof dateObj === "string") {
10521
- dateObj = dateObj.replace(/-/g, "/");
10522
- if (dateObj.length === 7) {
10523
- dateObj += "/01";
10524
- }
10525
- return new Date(dateObj);
10526
- }
10527
- if (isDate(dateObj)) {
10528
- return dateObj;
10529
- }
10530
- return null;
10531
- }
10532
- function formatDate(dateObj, formatType = FORMAT.FORMAT_YMDHMS) {
10533
- const date = createDate(dateObj);
10534
- if (date) {
10535
- date.getFullYear();
10536
- let formatResult = formatType.replace(
10537
- "yyyy",
10538
- __formatNumber__(date.getFullYear())
10539
- );
10540
- formatResult = formatResult.replace(
10541
- "yy",
10542
- String(date.getFullYear()).substring(2)
10543
- );
10544
- formatResult = formatResult.replace(
10545
- "MM",
10546
- __formatNumber__(date.getMonth() + 1)
10547
- );
10548
- formatResult = formatResult.replace("dd", __formatNumber__(date.getDate()));
10549
- formatResult = formatResult.replace(
10550
- "HH",
10551
- __formatNumber__(date.getHours())
10552
- );
10553
- formatResult = formatResult.replace(
10554
- "mm",
10555
- __formatNumber__(date.getMinutes())
10556
- );
10557
- formatResult = formatResult.replace(
10558
- "ss",
10559
- __formatNumber__(date.getSeconds())
10560
- );
10561
- formatResult = formatResult.replace(
10562
- "msms",
10563
- __formatNumber__(date.getMilliseconds())
10564
- );
10565
- return formatResult;
10566
- }
10567
- return null;
10568
- }
10569
10626
  const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
10570
10627
  const subString = (str, startIndex, length) => {
10571
10628
  if (!isDef(length)) {
@@ -10790,7 +10847,7 @@ function buildContent(contentConfigString, watermarkContext) {
10790
10847
  const regexResult = scanner.next(dateRegex);
10791
10848
  if (regexResult) {
10792
10849
  const matchResults = regexResult;
10793
- let format = FORMAT.FORMAT_YMD;
10850
+ let format = DATE_FORMAT.FORMAT_YMD;
10794
10851
  if (matchResults && matchResults.length >= 2) {
10795
10852
  if (isValidString(matchResults[1])) {
10796
10853
  format = matchResults[1];
@@ -10805,7 +10862,7 @@ function buildContent(contentConfigString, watermarkContext) {
10805
10862
  if (watermarkContext) {
10806
10863
  const value = formatDate(
10807
10864
  watermarkContext.watermarkTime,
10808
- FORMAT.FORMAT_HM
10865
+ DATE_FORMAT.FORMAT_HM
10809
10866
  );
10810
10867
  content += value;
10811
10868
  }
@@ -11159,7 +11216,6 @@ function checkWatermarkConfigSupported(watermarkConfigString) {
11159
11216
  }
11160
11217
  return true;
11161
11218
  }
11162
- const DEFAULT_IMAGE_TYPE = "image/jpeg";
11163
11219
  const DEFAULT_JPEG_QUALITY = 0.8;
11164
11220
  const MIN_JPEG_QUALITY = 0.1;
11165
11221
  const JPEG_QUALITY_STEP = 0.05;
@@ -11172,9 +11228,29 @@ class ImageProcessor {
11172
11228
  }
11173
11229
  process() {
11174
11230
  const filename = this.file.name;
11231
+ let fileType = this.file.type;
11175
11232
  const { lastModified } = this.file;
11233
+ let orientation = 1;
11234
+ if (this.file.size > this.compressOptions.photoFileSizeLimit * 1024) {
11235
+ fileType = "image/jpeg";
11236
+ }
11237
+ if (isIOS$1() && fileType === "image/jpeg") {
11238
+ const reader = new FileReader();
11239
+ reader.readAsArrayBuffer(this.file);
11240
+ reader.onload = function(_ref) {
11241
+ const { target } = _ref;
11242
+ if (target == null ? void 0 : target.result) {
11243
+ orientation = getOrientation(target == null ? void 0 : target.result);
11244
+ }
11245
+ };
11246
+ }
11247
+ if (fileType === "image/gif") {
11248
+ fileType = "image/png";
11249
+ }
11176
11250
  return file2Image(this.file).then(
11177
11251
  (img) => resize(img, {
11252
+ inputType: fileType,
11253
+ orientation,
11178
11254
  sideLengthLimit: this.resizeOptions.maxSideLength,
11179
11255
  resultType: "canvas"
11180
11256
  })
@@ -11187,7 +11263,7 @@ class ImageProcessor {
11187
11263
  canvas,
11188
11264
  exportFilename,
11189
11265
  lastModified,
11190
- DEFAULT_IMAGE_TYPE,
11266
+ fileType,
11191
11267
  DEFAULT_JPEG_QUALITY
11192
11268
  );
11193
11269
  });
@@ -11719,7 +11795,7 @@ var stdin_default$t = defineComponent({
11719
11795
  if (media.showSrc) {
11720
11796
  return createVNode(stdin_default$1q, {
11721
11797
  "src": media.showSrc,
11722
- "fit": "fill",
11798
+ "fit": "cover",
11723
11799
  "radius": "4"
11724
11800
  }, null);
11725
11801
  } else if (media.type === "video") {
@@ -12014,8 +12090,7 @@ var stdin_default$r = defineComponent({
12014
12090
  "size": "normal",
12015
12091
  "block": true,
12016
12092
  "style": {
12017
- marginRigth: "4px",
12018
- backgroundColor: "white"
12093
+ marginRigth: "4px"
12019
12094
  },
12020
12095
  "onClick": onCancel
12021
12096
  }, {
@@ -14179,7 +14254,6 @@ var stdin_default$b = defineComponent({
14179
14254
  const Step = withInstall(stdin_default$b);
14180
14255
  const [name$5, bem$5] = createNamespace("stepper");
14181
14256
  const LONG_PRESS_INTERVAL = 200;
14182
- const LONG_PRESS_START_TIME = 600;
14183
14257
  const isEqual = (value1, value2) => String(value1) === String(value2);
14184
14258
  const stepperProps = {
14185
14259
  min: makeNumericProp(1),
@@ -15989,15 +16063,14 @@ var stdin_default$1 = (lazyManager) => ({
15989
16063
  default: "img"
15990
16064
  }
15991
16065
  },
15992
- render(h2) {
15993
- return h2(
16066
+ render() {
16067
+ var _a, _b;
16068
+ return h(
15994
16069
  this.tag,
15995
16070
  {
15996
- attrs: {
15997
- src: this.renderSrc
15998
- }
16071
+ src: this.renderSrc
15999
16072
  },
16000
- this.$slots.default
16073
+ (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)
16001
16074
  );
16002
16075
  },
16003
16076
  data() {
@@ -16099,7 +16172,7 @@ const Lazyload = {
16099
16172
  });
16100
16173
  }
16101
16174
  };
16102
- const version = "3.0.3";
16175
+ const version = "3.0.5";
16103
16176
  function install(app) {
16104
16177
  const components = [
16105
16178
  ActionSheet,