@v-c/image 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/{Image.cjs → image/src/Image.cjs} +10 -7
  2. package/dist/{Image.js → image/src/Image.js} +6 -6
  3. package/dist/{Preview → image/src/Preview}/CloseBtn.cjs +4 -1
  4. package/dist/{Preview → image/src/Preview}/Footer.cjs +6 -3
  5. package/dist/{Preview → image/src/Preview}/Footer.js +2 -2
  6. package/dist/{Preview → image/src/Preview}/PrevNext.cjs +6 -3
  7. package/dist/{Preview → image/src/Preview}/PrevNext.js +2 -2
  8. package/dist/{Preview → image/src/Preview}/index.cjs +11 -8
  9. package/dist/{Preview → image/src/Preview}/index.js +7 -7
  10. package/dist/{PreviewGroup.cjs → image/src/PreviewGroup.cjs} +8 -5
  11. package/dist/{PreviewGroup.js → image/src/PreviewGroup.js} +4 -4
  12. package/dist/{common.cjs → image/src/common.cjs} +1 -0
  13. package/dist/{context.cjs → image/src/context.cjs} +1 -0
  14. package/dist/{getFixScaleEleTransPosition.cjs → image/src/getFixScaleEleTransPosition.cjs} +4 -1
  15. package/dist/{hooks → image/src/hooks}/useImageTransform.cjs +6 -3
  16. package/dist/{hooks → image/src/hooks}/useImageTransform.js +2 -2
  17. package/dist/{hooks → image/src/hooks}/useMouseEvent.cjs +6 -3
  18. package/dist/{hooks → image/src/hooks}/useMouseEvent.js +2 -2
  19. package/dist/{hooks → image/src/hooks}/usePreviewItems.cjs +4 -1
  20. package/dist/{hooks → image/src/hooks}/useRegisterImage.cjs +4 -1
  21. package/dist/{hooks → image/src/hooks}/useStatus.cjs +4 -1
  22. package/dist/{hooks → image/src/hooks}/useTouchEvent.cjs +4 -1
  23. package/dist/{index.cjs → image/src/index.cjs} +4 -1
  24. package/dist/image/src/interface.cjs +1 -0
  25. package/dist/{previewConfig.cjs → image/src/previewConfig.cjs} +1 -0
  26. package/dist/{util.cjs → image/src/util.cjs} +1 -0
  27. package/dist/portal/dist/Portal.cjs +9 -0
  28. package/dist/portal/dist/Portal.js +9 -0
  29. package/dist/portal/dist/useEscKeyDown.cjs +57 -0
  30. package/dist/portal/dist/useEscKeyDown.js +52 -0
  31. package/dist/portal/dist/useScrollLocker.cjs +4 -2
  32. package/dist/portal/dist/useScrollLocker.js +5 -3
  33. package/dist/util/dist/Dom/dynamicCSS.cjs +2 -0
  34. package/dist/util/dist/Dom/dynamicCSS.js +2 -0
  35. package/dist/util/dist/getScrollBarSize.cjs +9 -1
  36. package/dist/util/dist/getScrollBarSize.js +9 -1
  37. package/dist/util/dist/hooks/useControlledState.cjs +1 -0
  38. package/dist/util/dist/hooks/useControlledState.js +1 -0
  39. package/dist/util/dist/hooks/useId.cjs +5 -0
  40. package/dist/util/dist/hooks/useId.js +5 -0
  41. package/dist/util/dist/index.cjs +6 -1
  42. package/dist/util/dist/index.js +6 -1
  43. package/dist/util/dist/props-util/index.cjs +1 -1
  44. package/dist/util/dist/props-util/index.js +1 -0
  45. package/package.json +3 -3
  46. package/dist/interface.cjs +0 -0
  47. /package/dist/{Preview → image/src/Preview}/CloseBtn.js +0 -0
  48. /package/dist/{common.js → image/src/common.js} +0 -0
  49. /package/dist/{context.js → image/src/context.js} +0 -0
  50. /package/dist/{getFixScaleEleTransPosition.js → image/src/getFixScaleEleTransPosition.js} +0 -0
  51. /package/dist/{hooks → image/src/hooks}/usePreviewItems.js +0 -0
  52. /package/dist/{hooks → image/src/hooks}/useRegisterImage.js +0 -0
  53. /package/dist/{hooks → image/src/hooks}/useStatus.js +0 -0
  54. /package/dist/{hooks → image/src/hooks}/useTouchEvent.js +0 -0
  55. /package/dist/{index.js → image/src/index.js} +0 -0
  56. /package/dist/{interface.js → image/src/interface.js} +0 -0
  57. /package/dist/{previewConfig.js → image/src/previewConfig.js} +0 -0
  58. /package/dist/{util.js → image/src/util.js} +0 -0
@@ -1,11 +1,14 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- const require_index = require("./util/dist/props-util/index.cjs");
3
- const require_classnames = require("./util/dist/classnames.cjs");
4
- require("./util/dist/index.cjs");
5
- const require_useMergedState = require("./util/dist/hooks/useMergedState.cjs");
6
- const require_pickAttrs = require("./util/dist/pickAttrs.cjs");
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
7
5
  const require_common = require("./common.cjs");
8
6
  const require_context = require("./context.cjs");
7
+ const require_classnames = require("../../util/dist/classnames.cjs");
8
+ const require_useMergedState = require("../../util/dist/hooks/useMergedState.cjs");
9
+ const require_index = require("../../util/dist/props-util/index.cjs");
10
+ require("../../util/dist/index.cjs");
11
+ const require_pickAttrs = require("../../util/dist/pickAttrs.cjs");
9
12
  const require_useRegisterImage = require("./hooks/useRegisterImage.cjs");
10
13
  const require_useStatus = require("./hooks/useStatus.cjs");
11
14
  const require_index$2 = require("./Preview/index.cjs");
@@ -94,7 +97,7 @@ var Image = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slots }) =
94
97
  actionsNode: originNode,
95
98
  ...info
96
99
  }) : mergedPreviewConfig.value.actionsRender;
97
- const { src: _previewSrc, open: _previewOpen, onOpenChange: _onPreviewOpenChange, cover: _cover, rootClassName: _previewRootCls,...restPreviewProps } = mergedPreviewConfig.value;
100
+ const { src: _previewSrc, open: _previewOpen, onOpenChange: _onPreviewOpenChange, cover: _cover, rootClassName: _previewRootCls, ...restPreviewProps } = mergedPreviewConfig.value;
98
101
  return (0, vue.createVNode)(vue.Fragment, null, [(0, vue.createVNode)("div", (0, vue.mergeProps)(require_pickAttrs.pickAttrs(restAttrs, false), {
99
102
  "class": rootCls,
100
103
  "onClick": canPreview.value ? onPreview : onInternalClick,
@@ -1,10 +1,10 @@
1
- import { getAttrStyleAndClass, getStylePxValue } from "./util/dist/props-util/index.js";
2
- import { clsx } from "./util/dist/classnames.js";
3
- import "./util/dist/index.js";
4
- import { useMergedState } from "./util/dist/hooks/useMergedState.js";
5
- import { pickAttrs } from "./util/dist/pickAttrs.js";
6
1
  import { COMMON_PROPS } from "./common.js";
7
2
  import { usePreviewGroupContext } from "./context.js";
3
+ import { clsx } from "../../util/dist/classnames.js";
4
+ import { useMergedState } from "../../util/dist/hooks/useMergedState.js";
5
+ import { getAttrStyleAndClass, getStylePxValue } from "../../util/dist/props-util/index.js";
6
+ import "../../util/dist/index.js";
7
+ import { pickAttrs } from "../../util/dist/pickAttrs.js";
8
8
  import useRegisterImage from "./hooks/useRegisterImage.js";
9
9
  import useStatus from "./hooks/useStatus.js";
10
10
  import Preview_default from "./Preview/index.js";
@@ -93,7 +93,7 @@ var Image_default = /* @__PURE__ */ defineComponent((props, { attrs, slots }) =>
93
93
  actionsNode: originNode,
94
94
  ...info
95
95
  }) : mergedPreviewConfig.value.actionsRender;
96
- const { src: _previewSrc, open: _previewOpen, onOpenChange: _onPreviewOpenChange, cover: _cover, rootClassName: _previewRootCls,...restPreviewProps } = mergedPreviewConfig.value;
96
+ const { src: _previewSrc, open: _previewOpen, onOpenChange: _onPreviewOpenChange, cover: _cover, rootClassName: _previewRootCls, ...restPreviewProps } = mergedPreviewConfig.value;
97
97
  return createVNode(Fragment, null, [createVNode("div", mergeProps(pickAttrs(restAttrs, false), {
98
98
  "class": rootCls,
99
99
  "onClick": canPreview.value ? onPreview : onInternalClick,
@@ -1,4 +1,7 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
2
5
  let vue = require("vue");
3
6
  var CloseBtn = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
4
7
  return () => {
@@ -1,6 +1,9 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- const require_classnames = require("../util/dist/classnames.cjs");
3
- require("../util/dist/index.cjs");
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ const require_classnames = require("../../../util/dist/classnames.cjs");
6
+ require("../../../util/dist/index.cjs");
4
7
  let vue = require("vue");
5
8
  var Footer = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
6
9
  const renderOperation = ({ type, disabled, onClick, icon }) => {
@@ -1,5 +1,5 @@
1
- import { clsx } from "../util/dist/classnames.js";
2
- import "../util/dist/index.js";
1
+ import { clsx } from "../../../util/dist/classnames.js";
2
+ import "../../../util/dist/index.js";
3
3
  import { createVNode, defineComponent } from "vue";
4
4
  var Footer_default = /* @__PURE__ */ defineComponent((props) => {
5
5
  const renderOperation = ({ type, disabled, onClick, icon }) => {
@@ -1,6 +1,9 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- const require_classnames = require("../util/dist/classnames.cjs");
3
- require("../util/dist/index.cjs");
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ const require_classnames = require("../../../util/dist/classnames.cjs");
6
+ require("../../../util/dist/index.cjs");
4
7
  let vue = require("vue");
5
8
  var PrevNext = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
6
9
  return () => {
@@ -1,5 +1,5 @@
1
- import { clsx } from "../util/dist/classnames.js";
2
- import "../util/dist/index.js";
1
+ import { clsx } from "../../../util/dist/classnames.js";
2
+ import "../../../util/dist/index.js";
3
3
  import { Fragment, createVNode, defineComponent } from "vue";
4
4
  var PrevNext_default = /* @__PURE__ */ defineComponent((props) => {
5
5
  return () => {
@@ -1,11 +1,14 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- const require_classnames = require("../util/dist/classnames.cjs");
3
- require("../util/dist/index.cjs");
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
4
5
  const require_context = require("../context.cjs");
6
+ const require_classnames = require("../../../util/dist/classnames.cjs");
7
+ const require_KeyCode = require("../../../util/dist/KeyCode.cjs");
8
+ require("../../../util/dist/index.cjs");
5
9
  const require_useStatus = require("../hooks/useStatus.cjs");
6
- const require_index$1 = require("../portal/dist/index.cjs");
7
- const require_KeyCode = require("../util/dist/KeyCode.cjs");
8
- const require_transition = require("../util/dist/utils/transition.cjs");
10
+ const require_index$1 = require("../../../portal/dist/index.cjs");
11
+ const require_transition = require("../../../util/dist/utils/transition.cjs");
9
12
  const require_useImageTransform = require("../hooks/useImageTransform.cjs");
10
13
  const require_previewConfig = require("../previewConfig.cjs");
11
14
  const require_useMouseEvent = require("../hooks/useMouseEvent.cjs");
@@ -14,7 +17,7 @@ const require_CloseBtn = require("./CloseBtn.cjs");
14
17
  const require_Footer = require("./Footer.cjs");
15
18
  const require_PrevNext = require("./PrevNext.cjs");
16
19
  let vue = require("vue");
17
- var Preview = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs }) => {
20
+ var Preview = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slots }) => {
18
21
  const imgEl = (0, vue.shallowRef)();
19
22
  const groupContext = require_context.usePreviewGroupContext();
20
23
  const showLeftOrRightSwitches = (0, vue.computed)(() => !!groupContext && (props.count ?? 1) > 1);
@@ -113,7 +116,7 @@ var Preview = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs }) => {
113
116
  fallback: (0, vue.computed)(() => props.fallback)
114
117
  });
115
118
  return () => {
116
- const { prefixCls, rootClassName, src, alt, imageInfo, open, closeIcon, getContainer, current = 0, count = 1, countRender, motionName = "fade", imageRender, imgCommonProps, actionsRender, classNames = {}, styles = {}, mousePosition, zIndex, icons = {} } = props;
119
+ const { prefixCls, rootClassName, src, alt, imageInfo, open, closeIcon, getContainer, current = 0, count = 1, countRender, motionName = "fade", imageRender, imgCommonProps, actionsRender = slots?.actionsRender, classNames = {}, styles = {}, mousePosition, zIndex, icons = {} } = props;
117
120
  const bodyStyle = { ...styles.body ?? {} };
118
121
  if (mousePosition) bodyStyle.transformOrigin = `${mousePosition.x}px ${mousePosition.y}px`;
119
122
  const image = {
@@ -1,10 +1,10 @@
1
- import { clsx } from "../util/dist/classnames.js";
2
- import "../util/dist/index.js";
3
1
  import { usePreviewGroupContext } from "../context.js";
2
+ import { clsx } from "../../../util/dist/classnames.js";
3
+ import { KeyCodeStr } from "../../../util/dist/KeyCode.js";
4
+ import "../../../util/dist/index.js";
4
5
  import useStatus from "../hooks/useStatus.js";
5
- import { src_default } from "../portal/dist/index.js";
6
- import { KeyCodeStr } from "../util/dist/KeyCode.js";
7
- import { getTransitionProps } from "../util/dist/utils/transition.js";
6
+ import { src_default } from "../../../portal/dist/index.js";
7
+ import { getTransitionProps } from "../../../util/dist/utils/transition.js";
8
8
  import useImageTransform from "../hooks/useImageTransform.js";
9
9
  import { BASE_SCALE_RATIO } from "../previewConfig.js";
10
10
  import useMouseEvent from "../hooks/useMouseEvent.js";
@@ -13,7 +13,7 @@ import CloseBtn_default from "./CloseBtn.js";
13
13
  import Footer_default from "./Footer.js";
14
14
  import PrevNext_default from "./PrevNext.js";
15
15
  import { Transition, computed, createVNode, defineComponent, mergeDefaults, mergeProps, nextTick, shallowRef, watch, watchEffect } from "vue";
16
- var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs }) => {
16
+ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots }) => {
17
17
  const imgEl = shallowRef();
18
18
  const groupContext = usePreviewGroupContext();
19
19
  const showLeftOrRightSwitches = computed(() => !!groupContext && (props.count ?? 1) > 1);
@@ -112,7 +112,7 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs }) => {
112
112
  fallback: computed(() => props.fallback)
113
113
  });
114
114
  return () => {
115
- const { prefixCls, rootClassName, src, alt, imageInfo, open, closeIcon, getContainer, current = 0, count = 1, countRender, motionName = "fade", imageRender, imgCommonProps, actionsRender, classNames = {}, styles = {}, mousePosition, zIndex, icons = {} } = props;
115
+ const { prefixCls, rootClassName, src, alt, imageInfo, open, closeIcon, getContainer, current = 0, count = 1, countRender, motionName = "fade", imageRender, imgCommonProps, actionsRender = slots?.actionsRender, classNames = {}, styles = {}, mousePosition, zIndex, icons = {} } = props;
116
116
  const bodyStyle = { ...styles.body ?? {} };
117
117
  if (mousePosition) bodyStyle.transformOrigin = `${mousePosition.x}px ${mousePosition.y}px`;
118
118
  const image = {
@@ -1,6 +1,9 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- const require_useMergedState = require("./util/dist/hooks/useMergedState.cjs");
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
3
5
  const require_context = require("./context.cjs");
6
+ const require_useMergedState = require("../../util/dist/hooks/useMergedState.cjs");
4
7
  const require_index = require("./Preview/index.cjs");
5
8
  const require_usePreviewItems = require("./hooks/usePreviewItems.cjs");
6
9
  let vue = require("vue");
@@ -52,9 +55,9 @@ var PreviewGroup = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots, emi
52
55
  });
53
56
  return () => {
54
57
  const itemsList = mergedItems.value;
55
- const { src,...imgCommonProps } = itemsList[current.value]?.data || {};
58
+ const { src, ...imgCommonProps } = itemsList[current.value]?.data || {};
56
59
  const countRender = slots.countRender ? (currentNum, total) => slots.countRender?.(currentNum, total) : mergedPreviewConfig.value.countRender;
57
- const { open: _open, current: _current, onOpenChange: _onOpenChange, onChange: _onChange,...restPreviewConfig } = mergedPreviewConfig.value;
60
+ const { open: _open, current: _current, onOpenChange: _onOpenChange, onChange: _onChange, ...restPreviewConfig } = mergedPreviewConfig.value;
58
61
  return (0, vue.createVNode)(vue.Fragment, null, [slots.default?.(), (0, vue.createVNode)(require_index.default, (0, vue.mergeProps)({
59
62
  "aria-hidden": !isShowPreview.value,
60
63
  "open": isShowPreview.value,
@@ -72,7 +75,7 @@ var PreviewGroup = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots, emi
72
75
  "countRender": countRender,
73
76
  "classNames": props.classNames?.popup,
74
77
  "styles": props.styles?.popup
75
- }), null)]);
78
+ }), slots)]);
76
79
  };
77
80
  }, {
78
81
  props: /* @__PURE__ */ (0, vue.mergeDefaults)({
@@ -1,5 +1,5 @@
1
- import { useMergedState } from "./util/dist/hooks/useMergedState.js";
2
1
  import { usePreviewGroupProvider } from "./context.js";
2
+ import { useMergedState } from "../../util/dist/hooks/useMergedState.js";
3
3
  import Preview_default from "./Preview/index.js";
4
4
  import usePreviewItems from "./hooks/usePreviewItems.js";
5
5
  import { Fragment, computed, createVNode, defineComponent, mergeDefaults, mergeProps, shallowRef, toRef, watch } from "vue";
@@ -51,9 +51,9 @@ var PreviewGroup_default = /* @__PURE__ */ defineComponent((props, { slots, emit
51
51
  });
52
52
  return () => {
53
53
  const itemsList = mergedItems.value;
54
- const { src,...imgCommonProps } = itemsList[current.value]?.data || {};
54
+ const { src, ...imgCommonProps } = itemsList[current.value]?.data || {};
55
55
  const countRender = slots.countRender ? (currentNum, total) => slots.countRender?.(currentNum, total) : mergedPreviewConfig.value.countRender;
56
- const { open: _open, current: _current, onOpenChange: _onOpenChange, onChange: _onChange,...restPreviewConfig } = mergedPreviewConfig.value;
56
+ const { open: _open, current: _current, onOpenChange: _onOpenChange, onChange: _onChange, ...restPreviewConfig } = mergedPreviewConfig.value;
57
57
  return createVNode(Fragment, null, [slots.default?.(), createVNode(Preview_default, mergeProps({
58
58
  "aria-hidden": !isShowPreview.value,
59
59
  "open": isShowPreview.value,
@@ -71,7 +71,7 @@ var PreviewGroup_default = /* @__PURE__ */ defineComponent((props, { slots, emit
71
71
  "countRender": countRender,
72
72
  "classNames": props.classNames?.popup,
73
73
  "styles": props.styles?.popup
74
- }), null)]);
74
+ }), slots)]);
75
75
  };
76
76
  }, {
77
77
  props: /* @__PURE__ */ mergeDefaults({
@@ -1,3 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
1
2
  const COMMON_PROPS = [
2
3
  "crossOrigin",
3
4
  "decoding",
@@ -1,3 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
1
2
  let vue = require("vue");
2
3
  var PreviewGroupContextKey = Symbol("PreviewGroupContext");
3
4
  function usePreviewGroupContext() {
@@ -1,4 +1,7 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
2
5
  const require_util = require("./util.cjs");
3
6
  function fixPoint(key, start, width, clientWidth) {
4
7
  const startAddWidth = start + width;
@@ -1,7 +1,10 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
2
5
  const require_util = require("../util.cjs");
3
- const require_isEqual = require("../util/dist/isEqual.cjs");
4
- const require_raf = require("../util/dist/raf.cjs");
6
+ const require_raf = require("../../../util/dist/raf.cjs");
7
+ const require_isEqual = require("../../../util/dist/isEqual.cjs");
5
8
  let vue = require("vue");
6
9
  var initialTransform = {
7
10
  x: 0,
@@ -1,6 +1,6 @@
1
1
  import { getClientSize } from "../util.js";
2
- import { isEqual_default } from "../util/dist/isEqual.js";
3
- import { raf_default } from "../util/dist/raf.js";
2
+ import { raf_default } from "../../../util/dist/raf.js";
3
+ import { isEqual_default } from "../../../util/dist/isEqual.js";
4
4
  import { ref, shallowRef } from "vue";
5
5
  var initialTransform = {
6
6
  x: 0,
@@ -1,7 +1,10 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- const require_warning = require("../util/dist/warning.cjs");
3
- require("../util/dist/index.cjs");
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
4
5
  const require_getFixScaleEleTransPosition = require("../getFixScaleEleTransPosition.cjs");
6
+ const require_warning = require("../../../util/dist/warning.cjs");
7
+ require("../../../util/dist/index.cjs");
5
8
  const require_previewConfig = require("../previewConfig.cjs");
6
9
  let vue = require("vue");
7
10
  function useMouseEvent(imgRef, movable, open, scaleStep, transform, updateTransform, dispatchZoomChange) {
@@ -1,6 +1,6 @@
1
- import { warning_default } from "../util/dist/warning.js";
2
- import "../util/dist/index.js";
3
1
  import getFixScaleEleTransPosition from "../getFixScaleEleTransPosition.js";
2
+ import { warning_default } from "../../../util/dist/warning.js";
3
+ import "../../../util/dist/index.js";
4
4
  import { BASE_SCALE_RATIO, WHEEL_MAX_SCALE_RATIO } from "../previewConfig.js";
5
5
  import { shallowRef, watch } from "vue";
6
6
  function useMouseEvent(imgRef, movable, open, scaleStep, transform, updateTransform, dispatchZoomChange) {
@@ -1,4 +1,7 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
2
5
  const require_common = require("../common.cjs");
3
6
  let vue = require("vue");
4
7
  function usePreviewItems(items) {
@@ -1,4 +1,7 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
2
5
  const require_context = require("../context.cjs");
3
6
  let vue = require("vue");
4
7
  var uid = 0;
@@ -1,4 +1,7 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
2
5
  const require_util = require("../util.cjs");
3
6
  let vue = require("vue");
4
7
  function useStatus(options) {
@@ -1,4 +1,7 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
2
5
  const require_getFixScaleEleTransPosition = require("../getFixScaleEleTransPosition.cjs");
3
6
  let vue = require("vue");
4
7
  function getDistance(a, b) {
@@ -1,4 +1,7 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
2
5
  const require_Image = require("./Image.cjs");
3
6
  const require_PreviewGroup = require("./PreviewGroup.cjs");
4
7
  var ExportImage = require_Image.default;
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,3 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
1
2
  const BASE_SCALE_RATIO = 1;
2
3
  const WHEEL_MAX_SCALE_RATIO = 1;
3
4
  exports.BASE_SCALE_RATIO = BASE_SCALE_RATIO;
@@ -1,3 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
1
2
  function isImageValid(src) {
2
3
  return new Promise((resolve) => {
3
4
  if (!src) {
@@ -4,6 +4,7 @@ require("../../util/dist/index.cjs");
4
4
  const require_Context = require("./Context.cjs");
5
5
  const require_canUseDom = require("../../util/dist/Dom/canUseDom.cjs");
6
6
  const require_useDom = require("./useDom.cjs");
7
+ const require_useEscKeyDown = require("./useEscKeyDown.cjs");
7
8
  const require_useScrollLocker = require("./useScrollLocker.cjs");
8
9
  let vue = require("vue");
9
10
  function _isSlot(s) {
@@ -34,6 +35,9 @@ var Portal_default = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots, e
34
35
  require_Context.useContextProvider(queueCreate);
35
36
  const mergedContainer = (0, vue.computed)(() => innerContainer.value ?? defaultContainer);
36
37
  require_useScrollLocker.useScrollLocker((0, vue.computed)(() => !!(props.autoLock && props.open && require_canUseDom.canUseDom() && (mergedContainer.value === defaultContainer || mergedContainer.value === document.body))));
38
+ require_useEscKeyDown.useEscKeyDown((0, vue.computed)(() => !!props.open), (...args) => {
39
+ props.onEsc?.(...args);
40
+ });
37
41
  const elementEl = (0, vue.shallowRef)();
38
42
  const setRef = (el) => {
39
43
  elementEl.value = el;
@@ -76,6 +80,11 @@ var Portal_default = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots, e
76
80
  required: false,
77
81
  default: void 0
78
82
  },
83
+ onEsc: {
84
+ type: Function,
85
+ required: false,
86
+ default: void 0
87
+ },
79
88
  debug: {
80
89
  type: String,
81
90
  required: false,
@@ -4,6 +4,7 @@ import "../../util/dist/index.js";
4
4
  import { useContextProvider } from "./Context.js";
5
5
  import { canUseDom } from "../../util/dist/Dom/canUseDom.js";
6
6
  import { useDom } from "./useDom.js";
7
+ import { useEscKeyDown } from "./useEscKeyDown.js";
7
8
  import { useScrollLocker } from "./useScrollLocker.js";
8
9
  import { Teleport, computed, createVNode, defineComponent, isVNode, mergeDefaults, onMounted, shallowRef, watch } from "vue";
9
10
  function _isSlot(s) {
@@ -34,6 +35,9 @@ var Portal_default = /* @__PURE__ */ defineComponent((props, { slots, expose })
34
35
  useContextProvider(queueCreate);
35
36
  const mergedContainer = computed(() => innerContainer.value ?? defaultContainer);
36
37
  useScrollLocker(computed(() => !!(props.autoLock && props.open && canUseDom() && (mergedContainer.value === defaultContainer || mergedContainer.value === document.body))));
38
+ useEscKeyDown(computed(() => !!props.open), (...args) => {
39
+ props.onEsc?.(...args);
40
+ });
37
41
  const elementEl = shallowRef();
38
42
  const setRef = (el) => {
39
43
  elementEl.value = el;
@@ -76,6 +80,11 @@ var Portal_default = /* @__PURE__ */ defineComponent((props, { slots, expose })
76
80
  required: false,
77
81
  default: void 0
78
82
  },
83
+ onEsc: {
84
+ type: Function,
85
+ required: false,
86
+ default: void 0
87
+ },
79
88
  debug: {
80
89
  type: String,
81
90
  required: false,
@@ -0,0 +1,57 @@
1
+ let vue = require("vue");
2
+ var stack = [];
3
+ var IME_LOCK_DURATION = 200;
4
+ var lastCompositionEndTime = 0;
5
+ var _test = process.env.NODE_ENV === "test" ? () => ({
6
+ stack,
7
+ reset: () => {
8
+ lastCompositionEndTime = 0;
9
+ }
10
+ }) : null;
11
+ function onGlobalKeyDown(event) {
12
+ if (event.key === "Escape" && !event.isComposing) {
13
+ if (Date.now() - lastCompositionEndTime < IME_LOCK_DURATION) return;
14
+ const len = stack.length;
15
+ for (let i = len - 1; i >= 0; i -= 1) stack?.[i]?.onEsc?.({
16
+ top: i === len - 1,
17
+ event
18
+ });
19
+ }
20
+ }
21
+ function onGlobalCompositionEnd() {
22
+ lastCompositionEndTime = Date.now();
23
+ }
24
+ function attachGlobalEventListeners() {
25
+ window.addEventListener("keydown", onGlobalKeyDown);
26
+ window.addEventListener("compositionend", onGlobalCompositionEnd);
27
+ }
28
+ function detachGlobalEventListeners() {
29
+ if (stack.length === 0) {
30
+ window.removeEventListener("keydown", onGlobalKeyDown);
31
+ window.removeEventListener("compositionend", onGlobalCompositionEnd);
32
+ }
33
+ }
34
+ function useEscKeyDown(open, onEsc = () => {}) {
35
+ const id = (0, vue.useId)();
36
+ const onEventEsc = onEsc;
37
+ const ensure = () => {
38
+ if (!stack.find((item) => item.id === id)) stack.push({
39
+ id,
40
+ onEsc: onEventEsc
41
+ });
42
+ };
43
+ const clear = () => {
44
+ stack = stack.filter((item) => item.id !== id);
45
+ };
46
+ (0, vue.watch)(open, (_, _o, onCleanup) => {
47
+ if (open.value) {
48
+ ensure();
49
+ attachGlobalEventListeners();
50
+ onCleanup(() => {
51
+ clear();
52
+ detachGlobalEventListeners();
53
+ });
54
+ } else if (!open.value) clear();
55
+ }, { immediate: true });
56
+ }
57
+ exports.useEscKeyDown = useEscKeyDown;
@@ -0,0 +1,52 @@
1
+ import { useId, watch } from "vue";
2
+ var stack = [];
3
+ var IME_LOCK_DURATION = 200;
4
+ var lastCompositionEndTime = 0;
5
+ process.env.NODE_ENV;
6
+ function onGlobalKeyDown(event) {
7
+ if (event.key === "Escape" && !event.isComposing) {
8
+ if (Date.now() - lastCompositionEndTime < IME_LOCK_DURATION) return;
9
+ const len = stack.length;
10
+ for (let i = len - 1; i >= 0; i -= 1) stack?.[i]?.onEsc?.({
11
+ top: i === len - 1,
12
+ event
13
+ });
14
+ }
15
+ }
16
+ function onGlobalCompositionEnd() {
17
+ lastCompositionEndTime = Date.now();
18
+ }
19
+ function attachGlobalEventListeners() {
20
+ window.addEventListener("keydown", onGlobalKeyDown);
21
+ window.addEventListener("compositionend", onGlobalCompositionEnd);
22
+ }
23
+ function detachGlobalEventListeners() {
24
+ if (stack.length === 0) {
25
+ window.removeEventListener("keydown", onGlobalKeyDown);
26
+ window.removeEventListener("compositionend", onGlobalCompositionEnd);
27
+ }
28
+ }
29
+ function useEscKeyDown(open, onEsc = () => {}) {
30
+ const id = useId();
31
+ const onEventEsc = onEsc;
32
+ const ensure = () => {
33
+ if (!stack.find((item) => item.id === id)) stack.push({
34
+ id,
35
+ onEsc: onEventEsc
36
+ });
37
+ };
38
+ const clear = () => {
39
+ stack = stack.filter((item) => item.id !== id);
40
+ };
41
+ watch(open, (_, _o, onCleanup) => {
42
+ if (open.value) {
43
+ ensure();
44
+ attachGlobalEventListeners();
45
+ onCleanup(() => {
46
+ clear();
47
+ detachGlobalEventListeners();
48
+ });
49
+ } else if (!open.value) clear();
50
+ }, { immediate: true });
51
+ }
52
+ export { useEscKeyDown };
@@ -8,8 +8,7 @@ function useScrollLocker(lock) {
8
8
  const mergedLock = (0, vue.computed)(() => (0, vue.unref)(lock));
9
9
  uuid += 1;
10
10
  const id = (0, vue.shallowRef)(`${UNIQUE_ID}_${uuid}`);
11
- (0, vue.watch)([id, mergedLock], async () => {
12
- await (0, vue.nextTick)();
11
+ (0, vue.watch)([id, mergedLock], async (_, _o, onCleanup) => {
13
12
  if (mergedLock.value) {
14
13
  const scrollbarSize = require_getScrollBarSize.getTargetScrollBarSize(document.body).width;
15
14
  require_dynamicCSS.updateCSS(`
@@ -17,6 +16,9 @@ html body {
17
16
  overflow-y: hidden;
18
17
  ${require_util.isBodyOverflowing() ? `width: calc(100% - ${scrollbarSize}px);` : ""}
19
18
  }`, id.value);
19
+ onCleanup(() => {
20
+ require_dynamicCSS.removeCSS(id.value);
21
+ });
20
22
  } else require_dynamicCSS.removeCSS(id.value);
21
23
  }, {
22
24
  flush: "post",
@@ -1,15 +1,14 @@
1
1
  import { isBodyOverflowing } from "./util.js";
2
2
  import { removeCSS, updateCSS } from "../../util/dist/Dom/dynamicCSS.js";
3
3
  import { getTargetScrollBarSize } from "../../util/dist/getScrollBarSize.js";
4
- import { computed, nextTick, shallowRef, unref, watch } from "vue";
4
+ import { computed, shallowRef, unref, watch } from "vue";
5
5
  var UNIQUE_ID = `vc-util-locker-${Date.now()}`;
6
6
  var uuid = 0;
7
7
  function useScrollLocker(lock) {
8
8
  const mergedLock = computed(() => unref(lock));
9
9
  uuid += 1;
10
10
  const id = shallowRef(`${UNIQUE_ID}_${uuid}`);
11
- watch([id, mergedLock], async () => {
12
- await nextTick();
11
+ watch([id, mergedLock], async (_, _o, onCleanup) => {
13
12
  if (mergedLock.value) {
14
13
  const scrollbarSize = getTargetScrollBarSize(document.body).width;
15
14
  updateCSS(`
@@ -17,6 +16,9 @@ html body {
17
16
  overflow-y: hidden;
18
17
  ${isBodyOverflowing() ? `width: calc(100% - ${scrollbarSize}px);` : ""}
19
18
  }`, id.value);
19
+ onCleanup(() => {
20
+ removeCSS(id.value);
21
+ });
20
22
  } else removeCSS(id.value);
21
23
  }, {
22
24
  flush: "post",
@@ -50,6 +50,7 @@ function findExistNode(key, option = {}) {
50
50
  return findStyles(getContainer(option)).find((node) => node.getAttribute(getMark(option)) === key);
51
51
  }
52
52
  function removeCSS(key, option = {}) {
53
+ if (!require_canUseDom.canUseDom()) return null;
53
54
  const existNode = findExistNode(key, option);
54
55
  if (existNode) getContainer(option).removeChild(existNode);
55
56
  }
@@ -63,6 +64,7 @@ function syncRealContainer(container, option) {
63
64
  }
64
65
  }
65
66
  function updateCSS(css, key, option = {}) {
67
+ if (!require_canUseDom.canUseDom()) return null;
66
68
  syncRealContainer(getContainer(option), option);
67
69
  const existNode = findExistNode(key, option);
68
70
  if (existNode) {
@@ -50,6 +50,7 @@ function findExistNode(key, option = {}) {
50
50
  return findStyles(getContainer(option)).find((node) => node.getAttribute(getMark(option)) === key);
51
51
  }
52
52
  function removeCSS(key, option = {}) {
53
+ if (!canUseDom()) return null;
53
54
  const existNode = findExistNode(key, option);
54
55
  if (existNode) getContainer(option).removeChild(existNode);
55
56
  }
@@ -63,6 +64,7 @@ function syncRealContainer(container, option) {
63
64
  }
64
65
  }
65
66
  function updateCSS(css, key, option = {}) {
67
+ if (!canUseDom()) return null;
66
68
  syncRealContainer(getContainer(option), option);
67
69
  const existNode = findExistNode(key, option);
68
70
  if (existNode) {
@@ -36,7 +36,15 @@ function getTargetScrollBarSize(target) {
36
36
  width: 0,
37
37
  height: 0
38
38
  };
39
- const { width, height } = getComputedStyle(target, "::-webkit-scrollbar");
39
+ if (typeof navigator !== "undefined" && /jsdom/i.test(navigator.userAgent)) return {
40
+ width: 0,
41
+ height: 0
42
+ };
43
+ let width = "0px";
44
+ let height = "0px";
45
+ try {
46
+ ({width, height} = getComputedStyle(target, "::-webkit-scrollbar"));
47
+ } catch {}
40
48
  return {
41
49
  width: ensureSize(width),
42
50
  height: ensureSize(height)
@@ -36,7 +36,15 @@ function getTargetScrollBarSize(target) {
36
36
  width: 0,
37
37
  height: 0
38
38
  };
39
- const { width, height } = getComputedStyle(target, "::-webkit-scrollbar");
39
+ if (typeof navigator !== "undefined" && /jsdom/i.test(navigator.userAgent)) return {
40
+ width: 0,
41
+ height: 0
42
+ };
43
+ let width = "0px";
44
+ let height = "0px";
45
+ try {
46
+ ({width, height} = getComputedStyle(target, "::-webkit-scrollbar"));
47
+ } catch {}
40
48
  return {
41
49
  width: ensureSize(width),
42
50
  height: ensureSize(height)
@@ -0,0 +1 @@
1
+ let vue = require("vue");
@@ -0,0 +1 @@
1
+ import { nextTick, shallowRef, watch } from "vue";
@@ -0,0 +1,5 @@
1
+ let vue = require("vue");
2
+ function getUseId() {
3
+ return vue.useId;
4
+ }
5
+ var useOriginalId = getUseId();
@@ -0,0 +1,5 @@
1
+ import { useId } from "vue";
2
+ function getUseId() {
3
+ return useId;
4
+ }
5
+ getUseId();
@@ -1,3 +1,8 @@
1
- require("./RenderComponent.cjs");
2
1
  const require_classnames = require("./classnames.cjs");
2
+ require("./hooks/useControlledState.cjs");
3
+ require("./hooks/useId.cjs");
4
+ const require_useMergedState = require("./hooks/useMergedState.cjs");
5
+ const require_omit = require("./omit.cjs");
6
+ const require_raf = require("./raf.cjs");
7
+ require("./RenderComponent.cjs");
3
8
  const require_warning = require("./warning.cjs");
@@ -1,3 +1,8 @@
1
- import "./RenderComponent.js";
2
1
  import { classNames, clsx } from "./classnames.js";
2
+ import "./hooks/useControlledState.js";
3
+ import "./hooks/useId.js";
4
+ import { useMergedState } from "./hooks/useMergedState.js";
5
+ import { omit } from "./omit.js";
6
+ import { raf_default } from "./raf.js";
7
+ import "./RenderComponent.js";
3
8
  import { warning_default } from "./warning.js";
@@ -4,6 +4,7 @@ function isEmptyElement(c) {
4
4
  return c && (c.type === vue.Comment || c.type === vue.Fragment && c.children.length === 0 || c.type === vue.Text && c.children.trim() === "");
5
5
  }
6
6
  function filterEmpty(children = []) {
7
+ if (!Array.isArray(children)) children = [children];
7
8
  const res = [];
8
9
  children.forEach((child) => {
9
10
  if (Array.isArray(child)) res.push(...child);
@@ -12,7 +13,6 @@ function filterEmpty(children = []) {
12
13
  });
13
14
  return res.filter((c) => !isEmptyElement(c));
14
15
  }
15
- var skipFlattenKey = Symbol("skipFlatten");
16
16
  var defaultOptions = {
17
17
  class: true,
18
18
  style: true
@@ -4,6 +4,7 @@ function isEmptyElement(c) {
4
4
  return c && (c.type === Comment || c.type === Fragment && c.children.length === 0 || c.type === Text && c.children.trim() === "");
5
5
  }
6
6
  function filterEmpty(children = []) {
7
+ if (!Array.isArray(children)) children = [children];
7
8
  const res = [];
8
9
  children.forEach((child) => {
9
10
  if (Array.isArray(child)) res.push(...child);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/image",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.0.2",
5
5
  "description": "image component",
6
6
  "author": "",
7
7
  "license": "MIT",
@@ -32,8 +32,8 @@
32
32
  "vue": "^3.0.0"
33
33
  },
34
34
  "dependencies": {
35
- "@v-c/util": "^1.0.3",
36
- "@v-c/portal": "^1.0.1"
35
+ "@v-c/portal": "^1.0.4",
36
+ "@v-c/util": "^1.0.8"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@ant-design/icons-vue": "^7.0.1"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes