@v-c/image 1.0.8 → 1.0.10

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 (37) hide show
  1. package/dist/{image/src/Image.js → Image.js} +13 -11
  2. package/dist/Preview/CloseBtn.d.ts +3 -0
  3. package/dist/{image/src/Preview → Preview}/CloseBtn.js +19 -7
  4. package/dist/{image/src/Preview → Preview}/Footer.js +26 -48
  5. package/dist/{image/src/Preview → Preview}/PrevNext.js +9 -12
  6. package/dist/Preview/index.d.ts +3 -1
  7. package/dist/{image/src/Preview → Preview}/index.js +44 -26
  8. package/dist/{image/src/PreviewGroup.js → PreviewGroup.js} +7 -5
  9. package/dist/{image/src/common.js → common.js} +3 -1
  10. package/dist/{image/src/context.js → context.js} +2 -0
  11. package/dist/{image/src/getFixScaleEleTransPosition.js → getFixScaleEleTransPosition.js} +14 -0
  12. package/dist/{image/src/hooks → hooks}/useImageTransform.js +16 -4
  13. package/dist/{image/src/hooks → hooks}/useMouseEvent.js +5 -2
  14. package/dist/{image/src/hooks → hooks}/usePreviewItems.js +5 -0
  15. package/dist/{image/src/hooks → hooks}/useRegisterImage.js +2 -0
  16. package/dist/{image/src/hooks → hooks}/useStatus.js +2 -0
  17. package/dist/{image/src/hooks → hooks}/useTouchEvent.js +6 -2
  18. package/dist/index.js +7 -0
  19. package/dist/previewConfig.js +7 -0
  20. package/dist/{image/src/util.js → util.js} +2 -0
  21. package/package.json +1 -1
  22. package/dist/image/src/index.js +0 -6
  23. package/dist/image/src/previewConfig.js +0 -3
  24. package/dist/util/dist/Dom/canUseDom.js +0 -4
  25. package/dist/util/dist/Dom/focus.js +0 -80
  26. package/dist/util/dist/Dom/isVisible.js +0 -16
  27. package/dist/util/dist/KeyCode.js +0 -81
  28. package/dist/util/dist/hooks/useMergedState.js +0 -24
  29. package/dist/util/dist/isEqual.js +0 -27
  30. package/dist/util/dist/omit.js +0 -8
  31. package/dist/util/dist/pickAttrs.js +0 -39
  32. package/dist/util/dist/props-util/index.js +0 -32
  33. package/dist/util/dist/raf.js +0 -36
  34. package/dist/util/dist/type.js +0 -2
  35. package/dist/util/dist/utils/transition.js +0 -21
  36. package/dist/util/dist/warning.js +0 -37
  37. /package/dist/{image/src/interface.js → interface.js} +0 -0
@@ -1,14 +1,15 @@
1
1
  import { COMMON_PROPS } from "./common.js";
2
2
  import { usePreviewGroupContext } from "./context.js";
3
- import { useMergedState } from "../../util/dist/hooks/useMergedState.js";
4
- import { pickAttrs } from "../../util/dist/pickAttrs.js";
5
- import { getAttrStyleAndClass, getStylePxValue } from "../../util/dist/props-util/index.js";
6
3
  import useRegisterImage from "./hooks/useRegisterImage.js";
7
4
  import useStatus from "./hooks/useStatus.js";
8
- import Preview_default from "./Preview/index.js";
5
+ import Preview from "./Preview/index.js";
9
6
  import { Fragment, computed, createVNode, defineComponent, mergeDefaults, mergeProps, shallowRef } from "vue";
10
7
  import { clsx } from "@v-c/util";
11
- var Image_default = /* @__PURE__ */ defineComponent((props, { attrs, slots }) => {
8
+ import useMergedState from "@v-c/util/dist/hooks/useMergedState";
9
+ import pickAttrs from "@v-c/util/dist/pickAttrs";
10
+ import { getAttrStyleAndClass, getStylePxValue } from "@v-c/util/dist/props-util";
11
+ //#region src/Image.tsx
12
+ var Image = /* @__PURE__ */ defineComponent((props, { attrs, slots }) => {
12
13
  const groupContext = usePreviewGroupContext();
13
14
  const prefixCls = computed(() => props.prefixCls ?? "vc-image");
14
15
  const previewPrefixCls = computed(() => props.previewPrefixCls ?? `${prefixCls.value}-preview`);
@@ -71,7 +72,7 @@ var Image_default = /* @__PURE__ */ defineComponent((props, { attrs, slots }) =>
71
72
  };
72
73
  const onPreviewKeyDown = (event) => {
73
74
  props.onKeydown?.(event);
74
- if (!canPreview) return;
75
+ if (!canPreview.value) return;
75
76
  if (event.key === "Enter" || event.key === " ") {
76
77
  event.preventDefault();
77
78
  const rect = event.target.getBoundingClientRect();
@@ -114,9 +115,9 @@ var Image_default = /* @__PURE__ */ defineComponent((props, { attrs, slots }) =>
114
115
  return createVNode(Fragment, null, [createVNode("div", mergeProps(pickAttrs(restAttrs, false), {
115
116
  "class": rootCls,
116
117
  "onClick": canPreview.value ? onPreview : onInternalClick,
117
- "role": canPreview ? "button" : restAttrs.role,
118
- "tabindex": canPreview && restAttrs.tabIndex == null ? 0 : restAttrs.tabIndex,
119
- "aria-label": canPreview ? restAttrs["aria-label"] ?? restAttrs.alt : restAttrs["aria-label"],
118
+ "role": canPreview.value ? "button" : restAttrs.role,
119
+ "tabindex": canPreview.value && restAttrs.tabIndex == null ? 0 : restAttrs.tabIndex,
120
+ "aria-label": canPreview.value ? restAttrs["aria-label"] ?? restAttrs.alt : restAttrs["aria-label"],
120
121
  "onKeydown": onPreviewKeyDown,
121
122
  "style": rootStyle
122
123
  }), [
@@ -138,7 +139,7 @@ var Image_default = /* @__PURE__ */ defineComponent((props, { attrs, slots }) =>
138
139
  "class": clsx(`${prefixCls.value}-cover`, props.classNames?.cover, `${prefixCls.value}-cover-${coverPlacement}`),
139
140
  "style": props.styles?.cover
140
141
  }, [coverNode])
141
- ]), !groupContext && canPreview.value && createVNode(Preview_default, mergeProps({
142
+ ]), !groupContext && canPreview.value && createVNode(Preview, mergeProps({
142
143
  "aria-hidden": !isShowPreview.value,
143
144
  "open": isShowPreview.value,
144
145
  "prefixCls": previewPrefixCls.value,
@@ -253,4 +254,5 @@ var Image_default = /* @__PURE__ */ defineComponent((props, { attrs, slots }) =>
253
254
  name: "Image",
254
255
  inheritAttrs: false
255
256
  });
256
- export { Image_default as default };
257
+ //#endregion
258
+ export { Image as default };
@@ -1,8 +1,11 @@
1
1
  import { VueNode } from '@v-c/util/dist/type';
2
+ import { CSSProperties } from 'vue';
2
3
  export interface CloseBtnProps {
3
4
  prefixCls: string;
4
5
  icon?: VueNode;
5
6
  onClick: (e: MouseEvent) => void;
7
+ className?: string;
8
+ style?: CSSProperties;
6
9
  }
7
10
  declare const CloseBtn: import('vue').DefineSetupFnComponent<CloseBtnProps, {}, {}, CloseBtnProps & {}, import('vue').PublicProps>;
8
11
  export default CloseBtn;
@@ -1,9 +1,12 @@
1
1
  import { createVNode, defineComponent } from "vue";
2
- var CloseBtn_default = /* @__PURE__ */ defineComponent((props) => {
2
+ import { clsx } from "@v-c/util";
3
+ //#region src/Preview/CloseBtn.tsx
4
+ var CloseBtn = /* @__PURE__ */ defineComponent((props) => {
3
5
  return () => {
4
- const { prefixCls, icon, onClick } = props;
6
+ const { prefixCls, icon, onClick, className, style } = props;
5
7
  return createVNode("button", {
6
- "class": `${prefixCls}-close`,
8
+ "class": clsx(`${prefixCls}-close`, className),
9
+ "style": style,
7
10
  "type": "button",
8
11
  "onClick": onClick
9
12
  }, [icon]);
@@ -12,8 +15,7 @@ var CloseBtn_default = /* @__PURE__ */ defineComponent((props) => {
12
15
  props: {
13
16
  prefixCls: {
14
17
  type: String,
15
- required: true,
16
- default: void 0
18
+ required: true
17
19
  },
18
20
  icon: {
19
21
  type: [
@@ -30,10 +32,20 @@ var CloseBtn_default = /* @__PURE__ */ defineComponent((props) => {
30
32
  },
31
33
  onClick: {
32
34
  type: Function,
33
- required: true,
35
+ required: true
36
+ },
37
+ className: {
38
+ type: String,
39
+ required: false,
40
+ default: void 0
41
+ },
42
+ style: {
43
+ type: Object,
44
+ required: false,
34
45
  default: void 0
35
46
  }
36
47
  },
37
48
  name: "ImagePreviewCloseBtn"
38
49
  });
39
- export { CloseBtn_default as default };
50
+ //#endregion
51
+ export { CloseBtn as default };
@@ -1,6 +1,7 @@
1
1
  import { createVNode, defineComponent } from "vue";
2
2
  import { clsx } from "@v-c/util";
3
- var Footer_default = /* @__PURE__ */ defineComponent((props) => {
3
+ //#region src/Preview/Footer.tsx
4
+ var Footer = /* @__PURE__ */ defineComponent((props) => {
4
5
  const renderOperation = ({ type, disabled, onClick, icon }) => {
5
6
  const actionCls = `${props.prefixCls}-actions-action`;
6
7
  return createVNode("button", {
@@ -108,13 +109,11 @@ var Footer_default = /* @__PURE__ */ defineComponent((props) => {
108
109
  props: {
109
110
  prefixCls: {
110
111
  type: String,
111
- required: true,
112
- default: void 0
112
+ required: true
113
113
  },
114
114
  showProgress: {
115
115
  type: Boolean,
116
- required: true,
117
- default: void 0
116
+ required: true
118
117
  },
119
118
  countRender: {
120
119
  type: Function,
@@ -128,104 +127,83 @@ var Footer_default = /* @__PURE__ */ defineComponent((props) => {
128
127
  },
129
128
  current: {
130
129
  type: Number,
131
- required: true,
132
- default: void 0
130
+ required: true
133
131
  },
134
132
  count: {
135
133
  type: Number,
136
- required: true,
137
- default: void 0
134
+ required: true
138
135
  },
139
136
  showSwitch: {
140
137
  type: Boolean,
141
- required: true,
142
- default: void 0
143
- },
144
- icons: {
145
- required: true,
146
- default: void 0
138
+ required: true
147
139
  },
140
+ icons: { required: true },
148
141
  scale: {
149
142
  type: Number,
150
- required: true,
151
- default: void 0
143
+ required: true
152
144
  },
153
145
  minScale: {
154
146
  type: Number,
155
- required: true,
156
- default: void 0
147
+ required: true
157
148
  },
158
149
  maxScale: {
159
150
  type: Number,
160
- required: true,
161
- default: void 0
151
+ required: true
162
152
  },
163
153
  image: {
164
154
  type: Object,
165
- required: true,
166
- default: void 0
155
+ required: true
167
156
  },
168
157
  transform: {
169
158
  type: Object,
170
- required: true,
171
- default: void 0
159
+ required: true
172
160
  },
173
161
  classNames: {
174
162
  type: Object,
175
- required: true,
176
- default: void 0
163
+ required: true
177
164
  },
178
165
  styles: {
179
166
  type: Object,
180
- required: true,
181
- default: void 0
167
+ required: true
182
168
  },
183
169
  onActive: {
184
170
  type: Function,
185
- required: true,
186
- default: void 0
171
+ required: true
187
172
  },
188
173
  onFlipY: {
189
174
  type: Function,
190
- required: true,
191
- default: void 0
175
+ required: true
192
176
  },
193
177
  onFlipX: {
194
178
  type: Function,
195
- required: true,
196
- default: void 0
179
+ required: true
197
180
  },
198
181
  onRotateLeft: {
199
182
  type: Function,
200
- required: true,
201
- default: void 0
183
+ required: true
202
184
  },
203
185
  onRotateRight: {
204
186
  type: Function,
205
- required: true,
206
- default: void 0
187
+ required: true
207
188
  },
208
189
  onZoomOut: {
209
190
  type: Function,
210
- required: true,
211
- default: void 0
191
+ required: true
212
192
  },
213
193
  onZoomIn: {
214
194
  type: Function,
215
- required: true,
216
- default: void 0
195
+ required: true
217
196
  },
218
197
  onClose: {
219
198
  type: Function,
220
- required: true,
221
- default: void 0
199
+ required: true
222
200
  },
223
201
  onReset: {
224
202
  type: Function,
225
- required: true,
226
- default: void 0
203
+ required: true
227
204
  }
228
205
  },
229
206
  name: "ImagePreviewFooter"
230
207
  });
231
- export { Footer_default as default };
208
+ //#endregion
209
+ export { Footer as default };
@@ -1,6 +1,7 @@
1
1
  import { Fragment, createVNode, defineComponent } from "vue";
2
2
  import { clsx } from "@v-c/util";
3
- var PrevNext_default = /* @__PURE__ */ defineComponent((props) => {
3
+ //#region src/Preview/PrevNext.tsx
4
+ var PrevNext = /* @__PURE__ */ defineComponent((props) => {
4
5
  return () => {
5
6
  const { prefixCls, onActive, current, count, icons } = props;
6
7
  const switchCls = `${prefixCls}-switch`;
@@ -26,30 +27,26 @@ var PrevNext_default = /* @__PURE__ */ defineComponent((props) => {
26
27
  props: {
27
28
  prefixCls: {
28
29
  type: String,
29
- required: true,
30
- default: void 0
30
+ required: true
31
31
  },
32
32
  onActive: {
33
33
  type: Function,
34
- required: true,
35
- default: void 0
34
+ required: true
36
35
  },
37
36
  current: {
38
37
  type: Number,
39
- required: true,
40
- default: void 0
38
+ required: true
41
39
  },
42
40
  count: {
43
41
  type: Number,
44
- required: true,
45
- default: void 0
42
+ required: true
46
43
  },
47
44
  icons: {
48
45
  type: Object,
49
- required: true,
50
- default: void 0
46
+ required: true
51
47
  }
52
48
  },
53
49
  name: "ImagePreviewPrevNext"
54
50
  });
55
- export { PrevNext_default as default };
51
+ //#endregion
52
+ export { PrevNext as default };
@@ -4,7 +4,7 @@ import { CSSProperties } from 'vue';
4
4
  import { TransformAction, TransformType } from '../hooks/useImageTransform';
5
5
  import { ImgInfo } from '../Image';
6
6
  import { FooterSemanticName } from './Footer';
7
- export type PreviewSemanticName = 'root' | 'mask' | 'body' | FooterSemanticName;
7
+ export type PreviewSemanticName = 'root' | 'mask' | 'body' | 'close' | FooterSemanticName;
8
8
  export interface OperationIcons {
9
9
  rotateLeft?: VueNode;
10
10
  rotateRight?: VueNode;
@@ -60,7 +60,9 @@ export interface InternalPreviewConfig {
60
60
  open?: boolean;
61
61
  getContainer?: PortalProps['getContainer'];
62
62
  zIndex?: number;
63
+ maskClosable?: boolean;
63
64
  afterOpenChange?: (open: boolean) => void;
65
+ focusTrap?: boolean;
64
66
  movable?: boolean;
65
67
  icons?: OperationIcons;
66
68
  closeIcon?: VueNode | boolean | null;
@@ -1,22 +1,24 @@
1
1
  import { usePreviewGroupContext } from "../context.js";
2
2
  import useStatus from "../hooks/useStatus.js";
3
- import { canUseDom } from "../../../util/dist/Dom/canUseDom.js";
4
- import { useLockFocus } from "../../../util/dist/Dom/focus.js";
5
- import { KeyCodeStr } from "../../../util/dist/KeyCode.js";
6
- import { getTransitionProps } from "../../../util/dist/utils/transition.js";
7
3
  import useImageTransform from "../hooks/useImageTransform.js";
8
- import { BASE_SCALE_RATIO } from "../previewConfig.js";
4
+ import "../previewConfig.js";
9
5
  import useMouseEvent from "../hooks/useMouseEvent.js";
10
6
  import useTouchEvent from "../hooks/useTouchEvent.js";
11
- import CloseBtn_default from "./CloseBtn.js";
12
- import Footer_default from "./Footer.js";
13
- import PrevNext_default from "./PrevNext.js";
7
+ import CloseBtn from "./CloseBtn.js";
8
+ import Footer from "./Footer.js";
9
+ import PrevNext from "./PrevNext.js";
14
10
  import { Transition, computed, createVNode, defineComponent, mergeDefaults, mergeProps, nextTick, shallowRef, watch, watchEffect } from "vue";
15
11
  import { clsx } from "@v-c/util";
16
12
  import Portal from "@v-c/portal";
17
- var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots }) => {
13
+ import canUseDom from "@v-c/util/dist/Dom/canUseDom";
14
+ import { useLockFocus } from "@v-c/util/dist/Dom/focus";
15
+ import { KeyCodeStr } from "@v-c/util/dist/KeyCode";
16
+ import { getTransitionProps } from "@v-c/util/dist/utils/transition";
17
+ //#region src/Preview/index.tsx
18
+ var Preview = /* @__PURE__ */ defineComponent((props, { attrs, slots }) => {
18
19
  const imgEl = shallowRef();
19
20
  const wrapperRef = shallowRef(null);
21
+ const triggerRef = shallowRef(null);
20
22
  const groupContext = usePreviewGroupContext();
21
23
  const showLeftOrRightSwitches = computed(() => !!groupContext && (props.count ?? 1) > 1);
22
24
  const showOperationsProgress = computed(() => !!groupContext && (props.count ?? 1) >= 1);
@@ -33,6 +35,9 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
33
35
  watch(() => props.open, (open) => {
34
36
  if (!open) resetTransform("close");
35
37
  });
38
+ watch(() => props.open, (open) => {
39
+ if (open && canUseDom()) triggerRef.value = document.activeElement;
40
+ });
36
41
  const onDoubleClick = (event) => {
37
42
  if (!props.open) return;
38
43
  if (transform.value.scale !== 1) updateTransform({
@@ -76,10 +81,6 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
76
81
  const onKeyDown = (event) => {
77
82
  if (!props.open) return;
78
83
  const { key } = event;
79
- if (key === KeyCodeStr.Escape) {
80
- props.onClose?.();
81
- return;
82
- }
83
84
  if (showLeftOrRightSwitches.value) {
84
85
  if (key === KeyCodeStr.ArrowLeft) onActive(-1);
85
86
  else if (key === KeyCodeStr.ArrowRight) onActive(1);
@@ -104,6 +105,8 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
104
105
  if (!nextVisible) {
105
106
  animatedVisible.value = false;
106
107
  portalRender.value = false;
108
+ triggerRef.value?.focus?.();
109
+ triggerRef.value = null;
107
110
  }
108
111
  props.afterOpenChange?.(nextVisible);
109
112
  };
@@ -114,9 +117,10 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
114
117
  src: computed(() => props.src),
115
118
  fallback: computed(() => props.fallback)
116
119
  });
117
- useLockFocus(portalRender, () => wrapperRef.value);
120
+ const focusTrap = computed(() => props.focusTrap ?? true);
121
+ useLockFocus(computed(() => !!(focusTrap.value && props.open && portalRender.value)), () => wrapperRef.value);
118
122
  return () => {
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 = {}, movable = true } = props;
123
+ 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 = {}, movable = true, maskClosable = true } = props;
120
124
  const bodyStyle = { ...styles.body ?? {} };
121
125
  if (mousePosition) bodyStyle.transformOrigin = `${mousePosition.x}px ${mousePosition.y}px`;
122
126
  const image = {
@@ -160,7 +164,10 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
160
164
  return createVNode(Portal, {
161
165
  "open": open || animatedVisible.value || portalRender.value,
162
166
  "getContainer": getContainer,
163
- "autoLock": open || animatedVisible.value
167
+ "autoLock": open || animatedVisible.value,
168
+ "onEsc": ({ top }) => {
169
+ if (top) props.onClose?.();
170
+ }
164
171
  }, { default: () => [createVNode(Transition, mergeProps(transitionProps, {
165
172
  "onAfterEnter": () => onVisibleChanged(true),
166
173
  "onAfterLeave": () => onVisibleChanged(false)
@@ -178,7 +185,7 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
178
185
  createVNode("div", {
179
186
  "class": clsx(`${prefixCls}-mask`, classNames.mask),
180
187
  "style": styles.mask,
181
- "onClick": () => props.onClose?.()
188
+ "onClick": maskClosable ? () => props.onClose?.() : void 0
182
189
  }, null),
183
190
  createVNode("div", {
184
191
  "class": clsx(`${prefixCls}-body`, classNames.body),
@@ -188,19 +195,21 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
188
195
  image,
189
196
  ...groupContext ? { current } : {}
190
197
  }) : imgNode]),
191
- closeIcon !== false && closeIcon !== null && createVNode(CloseBtn_default, {
198
+ closeIcon !== false && closeIcon !== null && createVNode(CloseBtn, {
192
199
  "prefixCls": prefixCls,
193
200
  "icon": closeIcon === true ? icons.close : closeIcon || icons.close,
194
- "onClick": () => props.onClose?.()
201
+ "onClick": () => props.onClose?.(),
202
+ "className": classNames.close,
203
+ "style": styles.close
195
204
  }, null),
196
- showLeftOrRightSwitches.value && createVNode(PrevNext_default, {
205
+ showLeftOrRightSwitches.value && createVNode(PrevNext, {
197
206
  "prefixCls": prefixCls,
198
207
  "current": current,
199
208
  "count": count,
200
209
  "icons": icons,
201
210
  "onActive": onActive
202
211
  }, null),
203
- createVNode(Footer_default, {
212
+ createVNode(Footer, {
204
213
  "prefixCls": prefixCls,
205
214
  "showProgress": showOperationsProgress.value,
206
215
  "current": current,
@@ -233,8 +242,7 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
233
242
  props: /* @__PURE__ */ mergeDefaults({
234
243
  prefixCls: {
235
244
  type: String,
236
- required: true,
237
- default: void 0
245
+ required: true
238
246
  },
239
247
  classNames: {
240
248
  type: Object,
@@ -293,8 +301,7 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
293
301
  },
294
302
  mousePosition: {
295
303
  type: [null, Object],
296
- required: true,
297
- default: void 0
304
+ required: true
298
305
  },
299
306
  rootClassName: {
300
307
  type: String,
@@ -345,11 +352,21 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
345
352
  required: false,
346
353
  default: void 0
347
354
  },
355
+ maskClosable: {
356
+ type: Boolean,
357
+ required: false,
358
+ default: void 0
359
+ },
348
360
  afterOpenChange: {
349
361
  type: Function,
350
362
  required: false,
351
363
  default: void 0
352
364
  },
365
+ focusTrap: {
366
+ type: Boolean,
367
+ required: false,
368
+ default: void 0
369
+ },
353
370
  movable: {
354
371
  type: Boolean,
355
372
  required: false,
@@ -406,4 +423,5 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
406
423
  name: "ImagePreview",
407
424
  inheritAttrs: false
408
425
  });
409
- export { Preview_default as default };
426
+ //#endregion
427
+ export { Preview as default };
@@ -1,9 +1,10 @@
1
1
  import { usePreviewGroupProvider } from "./context.js";
2
- import { useMergedState } from "../../util/dist/hooks/useMergedState.js";
3
- import Preview_default from "./Preview/index.js";
2
+ import Preview from "./Preview/index.js";
4
3
  import usePreviewItems from "./hooks/usePreviewItems.js";
5
4
  import { Fragment, computed, createVNode, defineComponent, mergeDefaults, mergeProps, shallowRef, toRef, watch } from "vue";
6
- var PreviewGroup_default = /* @__PURE__ */ defineComponent((props, { slots, emit }) => {
5
+ import useMergedState from "@v-c/util/dist/hooks/useMergedState";
6
+ //#region src/PreviewGroup.tsx
7
+ var PreviewGroup = /* @__PURE__ */ defineComponent((props, { slots, emit }) => {
7
8
  const mergedPreviewConfig = computed(() => {
8
9
  if (props.preview && typeof props.preview === "object") return props.preview;
9
10
  return {};
@@ -54,7 +55,7 @@ var PreviewGroup_default = /* @__PURE__ */ defineComponent((props, { slots, emit
54
55
  const { src, ...imgCommonProps } = itemsList[current.value]?.data || {};
55
56
  const countRender = slots.countRender ? (currentNum, total) => slots.countRender?.(currentNum, total) : mergedPreviewConfig.value.countRender;
56
57
  const { open: _open, current: _current, onOpenChange: _onOpenChange, onChange: _onChange, ...restPreviewConfig } = mergedPreviewConfig.value;
57
- return createVNode(Fragment, null, [slots.default?.(), createVNode(Preview_default, mergeProps({
58
+ return createVNode(Fragment, null, [slots.default?.(), createVNode(Preview, mergeProps({
58
59
  "aria-hidden": !isShowPreview.value,
59
60
  "open": isShowPreview.value,
60
61
  "prefixCls": props.previewPrefixCls,
@@ -130,4 +131,5 @@ var PreviewGroup_default = /* @__PURE__ */ defineComponent((props, { slots, emit
130
131
  inheritAttrs: false,
131
132
  emits: ["change"]
132
133
  });
133
- export { PreviewGroup_default as default };
134
+ //#endregion
135
+ export { PreviewGroup as default };
@@ -1,4 +1,5 @@
1
- const COMMON_PROPS = [
1
+ //#region src/common.ts
2
+ var COMMON_PROPS = [
2
3
  "crossOrigin",
3
4
  "decoding",
4
5
  "draggable",
@@ -10,4 +11,5 @@ const COMMON_PROPS = [
10
11
  "alt",
11
12
  "fetchPriority"
12
13
  ];
14
+ //#endregion
13
15
  export { COMMON_PROPS };
@@ -1,4 +1,5 @@
1
1
  import { inject, provide } from "vue";
2
+ //#region src/context.ts
2
3
  var PreviewGroupContextKey = Symbol("PreviewGroupContext");
3
4
  function usePreviewGroupContext() {
4
5
  return inject(PreviewGroupContextKey, null);
@@ -6,4 +7,5 @@ function usePreviewGroupContext() {
6
7
  function usePreviewGroupProvider(value) {
7
8
  provide(PreviewGroupContextKey, value);
8
9
  }
10
+ //#endregion
9
11
  export { usePreviewGroupContext, usePreviewGroupProvider };
@@ -1,4 +1,5 @@
1
1
  import { getClientSize } from "./util.js";
2
+ //#region src/getFixScaleEleTransPosition.ts
2
3
  function fixPoint(key, start, width, clientWidth) {
3
4
  const startAddWidth = start + width;
4
5
  const offsetStart = (width - clientWidth) / 2;
@@ -8,6 +9,18 @@ function fixPoint(key, start, width, clientWidth) {
8
9
  } else if (start < 0 || startAddWidth > clientWidth) return { [key]: start < 0 ? offsetStart : -offsetStart };
9
10
  return {};
10
11
  }
12
+ /**
13
+ * Fix positon x,y point when
14
+ *
15
+ * Ele width && height < client
16
+ * - Back origin
17
+ *
18
+ * - Ele width | height > clientWidth | clientHeight
19
+ * - left | top > 0 -> Back 0
20
+ * - left | top + width | height < clientWidth | clientHeight -> Back left | top + width | height === clientWidth | clientHeight
21
+ *
22
+ * Regardless of other
23
+ */
11
24
  function getFixScaleEleTransPosition(width, height, left, top) {
12
25
  const { width: clientWidth, height: clientHeight } = getClientSize();
13
26
  let fixPos = null;
@@ -21,4 +34,5 @@ function getFixScaleEleTransPosition(width, height, left, top) {
21
34
  };
22
35
  return fixPos;
23
36
  }
37
+ //#endregion
24
38
  export { getFixScaleEleTransPosition as default };
@@ -1,7 +1,8 @@
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";
4
2
  import { ref, shallowRef } from "vue";
3
+ import isEqual from "@v-c/util/dist/isEqual";
4
+ import raf from "@v-c/util/dist/raf";
5
+ //#region src/hooks/useImageTransform.ts
5
6
  var initialTransform = {
6
7
  x: 0,
7
8
  y: 0,
@@ -17,15 +18,16 @@ function useImageTransform(imgRef, minScale, maxScale, onTransform) {
17
18
  const resetTransform = (action) => {
18
19
  const oldTransform = transform.value;
19
20
  transform.value = initialTransform;
20
- if (!isEqual_default(initialTransform, oldTransform)) onTransform?.({
21
+ if (!isEqual(initialTransform, oldTransform)) onTransform?.({
21
22
  transform: initialTransform,
22
23
  action
23
24
  });
24
25
  };
26
+ /** Direct update transform */
25
27
  const updateTransform = (newTransform, action) => {
26
28
  if (frame.value === null) {
27
29
  queue.value = [];
28
- frame.value = raf_default(() => {
30
+ frame.value = raf(() => {
29
31
  let memoState = transform.value;
30
32
  queue.value.forEach((queueState) => {
31
33
  memoState = {
@@ -46,6 +48,7 @@ function useImageTransform(imgRef, minScale, maxScale, onTransform) {
46
48
  ...newTransform
47
49
  });
48
50
  };
51
+ /** Scale according to the position of centerX and centerY */
49
52
  const dispatchZoomChange = (ratio, action, centerX, centerY, isTouch) => {
50
53
  if (!imgRef.value) return;
51
54
  const { width, height, offsetWidth, offsetHeight, offsetLeft, offsetTop } = imgRef.value;
@@ -61,15 +64,23 @@ function useImageTransform(imgRef, minScale, maxScale, onTransform) {
61
64
  newScale = isTouch ? newScale : _minScale;
62
65
  newRatio = newScale / _transform.scale;
63
66
  }
67
+ /** Default center point scaling */
64
68
  const mergedCenterX = centerX ?? innerWidth / 2;
65
69
  const mergedCenterY = centerY ?? innerHeight / 2;
66
70
  const diffRatio = newRatio - 1;
71
+ /** Deviation calculated from image size */
67
72
  const diffImgX = diffRatio * width * .5;
68
73
  const diffImgY = diffRatio * height * .5;
74
+ /** The difference between the click position and the edge of the document */
69
75
  const diffOffsetLeft = diffRatio * (mergedCenterX - _transform.x - offsetLeft);
70
76
  const diffOffsetTop = diffRatio * (mergedCenterY - _transform.y - offsetTop);
77
+ /** Final positioning */
71
78
  let newX = _transform.x - (diffOffsetLeft - diffImgX);
72
79
  let newY = _transform.y - (diffOffsetTop - diffImgY);
80
+ /**
81
+ * When zooming the image
82
+ * When the image size is smaller than the width and height of the window, the position is initialized
83
+ */
73
84
  if (ratio < 1 && newScale === 1) {
74
85
  const mergedWidth = offsetWidth * newScale;
75
86
  const mergedHeight = offsetHeight * newScale;
@@ -92,4 +103,5 @@ function useImageTransform(imgRef, minScale, maxScale, onTransform) {
92
103
  dispatchZoomChange
93
104
  };
94
105
  }
106
+ //#endregion
95
107
  export { useImageTransform as default };
@@ -1,8 +1,9 @@
1
1
  import getFixScaleEleTransPosition from "../getFixScaleEleTransPosition.js";
2
- import { canUseDom } from "../../../util/dist/Dom/canUseDom.js";
3
- import { BASE_SCALE_RATIO, WHEEL_MAX_SCALE_RATIO } from "../previewConfig.js";
2
+ import "../previewConfig.js";
4
3
  import { shallowRef, watch } from "vue";
5
4
  import { warning } from "@v-c/util";
5
+ import canUseDom from "@v-c/util/dist/Dom/canUseDom";
6
+ //#region src/hooks/useMouseEvent.ts
6
7
  function useMouseEvent(imgRef, movable, open, scaleStep, transform, updateTransform, dispatchZoomChange) {
7
8
  const isMoving = shallowRef(false);
8
9
  const startPositionInfo = shallowRef({
@@ -34,6 +35,7 @@ function useMouseEvent(imgRef, movable, open, scaleStep, transform, updateTransf
34
35
  if (open.value && isMoving.value) {
35
36
  const { x, y, scale, rotate } = transform.value;
36
37
  isMoving.value = false;
38
+ /** No need to restore the position when the picture is not moved, So as not to interfere with the click */
37
39
  const { transformX, transformY } = startPositionInfo.value;
38
40
  if (!(x !== transformX && y !== transformY)) return;
39
41
  if (!imgRef.value) return;
@@ -88,4 +90,5 @@ function useMouseEvent(imgRef, movable, open, scaleStep, transform, updateTransf
88
90
  onWheel
89
91
  };
90
92
  }
93
+ //#endregion
91
94
  export { useMouseEvent as default };
@@ -1,5 +1,9 @@
1
1
  import { COMMON_PROPS } from "../common.js";
2
2
  import { computed, shallowRef, watchEffect } from "vue";
3
+ //#region src/hooks/usePreviewItems.ts
4
+ /**
5
+ * Merge props provided `items` or context collected images
6
+ */
3
7
  function usePreviewItems(items) {
4
8
  const images = shallowRef({});
5
9
  const registerImage = (id, data) => {
@@ -41,4 +45,5 @@ function usePreviewItems(items) {
41
45
  computed(() => !!items?.value)
42
46
  ];
43
47
  }
48
+ //#endregion
44
49
  export { usePreviewItems as default };
@@ -1,5 +1,6 @@
1
1
  import { usePreviewGroupContext } from "../context.js";
2
2
  import { onBeforeUnmount, onMounted, shallowRef, watch } from "vue";
3
+ //#region src/hooks/useRegisterImage.ts
3
4
  var uid = 0;
4
5
  function useRegisterImage(canPreview, data) {
5
6
  uid += 1;
@@ -21,4 +22,5 @@ function useRegisterImage(canPreview, data) {
21
22
  });
22
23
  return id.value;
23
24
  }
25
+ //#endregion
24
26
  export { useRegisterImage as default };
@@ -1,5 +1,6 @@
1
1
  import { isImageValid } from "../util.js";
2
2
  import { computed, shallowRef, watch, watchEffect } from "vue";
3
+ //#region src/hooks/useStatus.ts
3
4
  function useStatus(options) {
4
5
  const { src, isCustomPlaceholder, fallback } = options;
5
6
  const status = shallowRef(isCustomPlaceholder?.value ? "loading" : "normal");
@@ -42,4 +43,5 @@ function useStatus(options) {
42
43
  status
43
44
  ];
44
45
  }
46
+ //#endregion
45
47
  export { useStatus as default };
@@ -1,6 +1,7 @@
1
1
  import getFixScaleEleTransPosition from "../getFixScaleEleTransPosition.js";
2
- import { canUseDom } from "../../../util/dist/Dom/canUseDom.js";
3
2
  import { shallowRef, watchEffect } from "vue";
3
+ import canUseDom from "@v-c/util/dist/Dom/canUseDom";
4
+ //#region src/hooks/useTouchEvent.ts
4
5
  function getDistance(a, b) {
5
6
  const x = a.x - b.x;
6
7
  const y = a.y - b.y;
@@ -89,7 +90,9 @@ function useTouchEvent(imgRef, movable, open, minScale, transform, updateTransfo
89
90
  if (isTouching.value) isTouching.value = false;
90
91
  updateTouchPointInfo({ eventType: "none" });
91
92
  const { rotate, scale } = transform.value;
92
- if (minScale.value > scale) return updateTransform({
93
+ if (minScale.value > scale)
94
+ /** When the scaling ratio is less than the minimum scaling ratio, reset the scaling ratio */
95
+ return updateTransform({
93
96
  x: 0,
94
97
  y: 0,
95
98
  scale: minScale.value
@@ -118,4 +121,5 @@ function useTouchEvent(imgRef, movable, open, minScale, transform, updateTransfo
118
121
  onTouchEnd
119
122
  };
120
123
  }
124
+ //#endregion
121
125
  export { useTouchEvent as default };
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ import Image from "./Image.js";
2
+ import PreviewGroup from "./PreviewGroup.js";
3
+ //#region src/index.ts
4
+ var ExportImage = Image;
5
+ ExportImage.PreviewGroup = PreviewGroup;
6
+ //#endregion
7
+ export { PreviewGroup, ExportImage as default };
@@ -0,0 +1,7 @@
1
+ //#region src/previewConfig.ts
2
+ /** Scale the ratio base */
3
+ var BASE_SCALE_RATIO = 1;
4
+ /** The maximum zoom ratio when the mouse zooms in, adjustable */
5
+ var WHEEL_MAX_SCALE_RATIO = 1;
6
+ //#endregion
7
+ export { BASE_SCALE_RATIO, WHEEL_MAX_SCALE_RATIO };
@@ -1,3 +1,4 @@
1
+ //#region src/util.ts
1
2
  function isImageValid(src) {
2
3
  return new Promise((resolve) => {
3
4
  if (!src) {
@@ -26,4 +27,5 @@ function getClientSize() {
26
27
  height: window.innerHeight || document.documentElement.clientHeight
27
28
  };
28
29
  }
30
+ //#endregion
29
31
  export { getClientSize, isImageValid };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/image",
3
3
  "type": "module",
4
- "version": "1.0.8",
4
+ "version": "1.0.10",
5
5
  "description": "image component",
6
6
  "author": "",
7
7
  "license": "MIT",
@@ -1,6 +0,0 @@
1
- import Image_default from "./Image.js";
2
- import PreviewGroup_default from "./PreviewGroup.js";
3
- var ExportImage = Image_default;
4
- ExportImage.PreviewGroup = PreviewGroup_default;
5
- var src_default = ExportImage;
6
- export { PreviewGroup_default as PreviewGroup, src_default as default };
@@ -1,3 +0,0 @@
1
- const BASE_SCALE_RATIO = 1;
2
- const WHEEL_MAX_SCALE_RATIO = 1;
3
- export { BASE_SCALE_RATIO, WHEEL_MAX_SCALE_RATIO };
@@ -1,4 +0,0 @@
1
- function canUseDom() {
2
- return !!(typeof window !== "undefined" && window.document && window.document.createElement);
3
- }
4
- export { canUseDom };
@@ -1,80 +0,0 @@
1
- import { isVisible_default } from "./isVisible.js";
2
- import { watch } from "vue";
3
- function focusable(node, includePositive = false) {
4
- if (isVisible_default(node)) {
5
- const nodeName = node.nodeName.toLowerCase();
6
- const isFocusableElement = [
7
- "input",
8
- "select",
9
- "textarea",
10
- "button"
11
- ].includes(nodeName) || node.isContentEditable || nodeName === "a" && !!node.getAttribute("href");
12
- const tabIndexAttr = node.getAttribute("tabindex");
13
- const tabIndexNum = Number(tabIndexAttr);
14
- let tabIndex = null;
15
- if (tabIndexAttr && !Number.isNaN(tabIndexNum)) tabIndex = tabIndexNum;
16
- else if (isFocusableElement && tabIndex === null) tabIndex = 0;
17
- if (isFocusableElement && node.disabled) tabIndex = null;
18
- return tabIndex !== null && (tabIndex >= 0 || includePositive && tabIndex < 0);
19
- }
20
- return false;
21
- }
22
- function getFocusNodeList(node, includePositive = false) {
23
- const res = [...node.querySelectorAll("*")].filter((child) => {
24
- return focusable(child, includePositive);
25
- });
26
- if (focusable(node, includePositive)) res.unshift(node);
27
- return res;
28
- }
29
- var lastFocusElement = null;
30
- var focusElements = [];
31
- function getLastElement() {
32
- return focusElements[focusElements.length - 1];
33
- }
34
- function hasFocus(element) {
35
- const { activeElement } = document;
36
- return element === activeElement || element.contains(activeElement);
37
- }
38
- function syncFocus() {
39
- const lastElement = getLastElement();
40
- const { activeElement } = document;
41
- if (lastElement && !hasFocus(lastElement)) {
42
- const focusableList = getFocusNodeList(lastElement);
43
- (focusableList.includes(lastFocusElement) ? lastFocusElement : focusableList[0])?.focus();
44
- } else lastFocusElement = activeElement;
45
- }
46
- function onWindowKeyDown(e) {
47
- if (e.key === "Tab") {
48
- const { activeElement } = document;
49
- const focusableList = getFocusNodeList(getLastElement());
50
- const last = focusableList[focusableList.length - 1];
51
- if (e.shiftKey && activeElement === focusableList[0]) lastFocusElement = last;
52
- else if (!e.shiftKey && activeElement === last) lastFocusElement = focusableList[0];
53
- }
54
- }
55
- function lockFocus(element) {
56
- if (element) {
57
- focusElements = focusElements.filter((ele) => ele !== element);
58
- focusElements.push(element);
59
- window.addEventListener("focusin", syncFocus);
60
- window.addEventListener("keydown", onWindowKeyDown, true);
61
- syncFocus();
62
- }
63
- return () => {
64
- lastFocusElement = null;
65
- focusElements = focusElements.filter((ele) => ele !== element);
66
- if (focusElements.length === 0) {
67
- window.removeEventListener("focusin", syncFocus);
68
- window.removeEventListener("keydown", onWindowKeyDown, true);
69
- }
70
- };
71
- }
72
- function useLockFocus(lock, getElement) {
73
- watch(lock, (_, _o, onCleanup) => {
74
- if (lock.value) {
75
- const element = getElement();
76
- if (element) onCleanup(lockFocus(element));
77
- }
78
- });
79
- }
80
- export { useLockFocus };
@@ -1,16 +0,0 @@
1
- var isVisible_default = (element) => {
2
- if (!element) return false;
3
- if (element instanceof Element) {
4
- if (element.offsetParent) return true;
5
- if (element.getBBox) {
6
- const { width, height } = element.getBBox();
7
- if (width || height) return true;
8
- }
9
- if (element.getBoundingClientRect) {
10
- const { width, height } = element.getBoundingClientRect();
11
- if (width || height) return true;
12
- }
13
- }
14
- return false;
15
- };
16
- export { isVisible_default };
@@ -1,81 +0,0 @@
1
- var KeyCodeStr = {
2
- Enter: "Enter",
3
- Backspace: "Backspace",
4
- Tab: "Tab",
5
- Space: " ",
6
- Escape: "Escape",
7
- Shift: "Shift",
8
- Control: "Control",
9
- Alt: "Alt",
10
- Meta: "Meta",
11
- ArrowLeft: "ArrowLeft",
12
- ArrowUp: "ArrowUp",
13
- ArrowRight: "ArrowRight",
14
- ArrowDown: "ArrowDown",
15
- Home: "Home",
16
- End: "End",
17
- PageUp: "PageUp",
18
- PageDown: "PageDown",
19
- Insert: "Insert",
20
- Delete: "Delete",
21
- F1: "F1",
22
- F2: "F2",
23
- F3: "F3",
24
- F4: "F4",
25
- F5: "F5",
26
- F6: "F6",
27
- F7: "F7",
28
- F8: "F8",
29
- F9: "F9",
30
- F10: "F10",
31
- F11: "F11",
32
- F12: "F12",
33
- Digit0: "0",
34
- Digit1: "1",
35
- Digit2: "2",
36
- Digit3: "3",
37
- Digit4: "4",
38
- Digit5: "5",
39
- Digit6: "6",
40
- Digit7: "7",
41
- Digit8: "8",
42
- Digit9: "9",
43
- KeyA: "a",
44
- KeyB: "b",
45
- KeyC: "c",
46
- KeyD: "d",
47
- KeyE: "e",
48
- KeyF: "f",
49
- KeyG: "g",
50
- KeyH: "h",
51
- KeyI: "i",
52
- KeyJ: "j",
53
- KeyK: "k",
54
- KeyL: "l",
55
- KeyM: "m",
56
- KeyN: "n",
57
- KeyO: "o",
58
- KeyP: "p",
59
- KeyQ: "q",
60
- KeyR: "r",
61
- KeyS: "s",
62
- KeyT: "t",
63
- KeyU: "u",
64
- KeyV: "v",
65
- KeyW: "w",
66
- KeyX: "x",
67
- KeyY: "y",
68
- KeyZ: "z",
69
- Semicolon: ";",
70
- Equal: "=",
71
- Comma: ",",
72
- Minus: "-",
73
- Period: ".",
74
- Slash: "/",
75
- Backquote: "`",
76
- BracketLeft: "[",
77
- Backslash: "\\",
78
- BracketRight: "]",
79
- Quote: "'"
80
- };
81
- export { KeyCodeStr };
@@ -1,24 +0,0 @@
1
- import { ref, toRaw, unref, watch, watchEffect } from "vue";
2
- function useMergedState(defaultStateValue, option) {
3
- const { defaultValue, value = ref() } = option || {};
4
- let initValue = typeof defaultStateValue === "function" ? defaultStateValue() : defaultStateValue;
5
- if (value.value !== void 0) initValue = unref(value);
6
- if (defaultValue !== void 0) initValue = typeof defaultValue === "function" ? defaultValue() : defaultValue;
7
- const innerValue = ref(initValue);
8
- const mergedValue = ref(initValue);
9
- watchEffect(() => {
10
- let val = value.value !== void 0 ? value.value : innerValue.value;
11
- if (option?.postState) val = option.postState(val);
12
- mergedValue.value = val;
13
- });
14
- function triggerChange(newValue) {
15
- const preVal = mergedValue.value;
16
- innerValue.value = newValue;
17
- if (toRaw(mergedValue.value) !== newValue && option?.onChange) option.onChange(newValue, preVal);
18
- }
19
- watch(value, () => {
20
- innerValue.value = value.value;
21
- });
22
- return [mergedValue, triggerChange];
23
- }
24
- export { useMergedState };
@@ -1,27 +0,0 @@
1
- import { warning_default } from "./warning.js";
2
- function isEqual(obj1, obj2, shallow = false) {
3
- const refSet = /* @__PURE__ */ new Set();
4
- function deepEqual(a, b, level = 1) {
5
- const circular = refSet.has(a);
6
- warning_default(!circular, "Warning: There may be circular references");
7
- if (circular) return false;
8
- if (a === b) return true;
9
- if (shallow && level > 1) return false;
10
- refSet.add(a);
11
- const newLevel = level + 1;
12
- if (Array.isArray(a)) {
13
- if (!Array.isArray(b) || a.length !== b.length) return false;
14
- for (let i = 0; i < a.length; i++) if (!deepEqual(a[i], b[i], newLevel)) return false;
15
- return true;
16
- }
17
- if (a && b && typeof a === "object" && typeof b === "object") {
18
- const keys = Object.keys(a);
19
- if (keys.length !== Object.keys(b).length) return false;
20
- return keys.every((key) => deepEqual(a[key], b[key], newLevel));
21
- }
22
- return false;
23
- }
24
- return deepEqual(obj1, obj2);
25
- }
26
- var isEqual_default = isEqual;
27
- export { isEqual_default };
@@ -1,8 +0,0 @@
1
- function omit(obj, fields) {
2
- const clone = { ...obj };
3
- if (Array.isArray(fields)) fields.forEach((key) => {
4
- delete clone[key];
5
- });
6
- return clone;
7
- }
8
- export { omit };
@@ -1,39 +0,0 @@
1
- var propList = `accept acceptCharset accessKey action allowFullScreen allowTransparency
2
- alt async autoComplete autoFocus autoPlay capture cellPadding cellSpacing challenge
3
- charSet checked classID className colSpan cols content contentEditable contextMenu
4
- controls coords crossOrigin data dateTime default defer dir disabled download draggable
5
- encType form formAction formEncType formMethod formNoValidate formTarget frameBorder
6
- headers height hidden high href hrefLang htmlFor httpEquiv icon id inputMode integrity
7
- is keyParams keyType kind label lang list loop low manifest marginHeight marginWidth max maxLength media
8
- mediaGroup method min minLength multiple muted name noValidate nonce open
9
- optimum pattern placeholder poster preload radioGroup readOnly rel required
10
- reversed role rowSpan rows sandbox scope scoped scrolling seamless selected
11
- shape size sizes span spellCheck src srcDoc srcLang srcSet start step style
12
- summary tabIndex target title type useMap value width wmode wrap onCopy onCut onPaste onCompositionEnd onCompositionStart onCompositionUpdate onKeyDown
13
- onKeyPress onKeyUp onFocus onBlur onChange onInput onSubmit onClick onContextMenu onDoubleClick
14
- onDrag onDragEnd onDragEnter onDragExit onDragLeave onDragOver onDragStart onDrop onMouseDown
15
- onMouseEnter onMouseLeave onMouseMove onMouseOut onMouseOver onMouseUp onSelect onTouchCancel
16
- onTouchEnd onTouchMove onTouchStart onScroll onWheel onAbort onCanPlay onCanPlayThrough
17
- onDurationChange onEmptied onEncrypted onEnded onError onLoadedData onLoadedMetadata
18
- onLoadStart onPause onPlay onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend onTimeUpdate onVolumeChange onWaiting onLoad onError`.split(/\s+/);
19
- var ariaPrefix = "aria-";
20
- var dataPrefix = "data-";
21
- function match(key, prefix) {
22
- return key.indexOf(prefix) === 0;
23
- }
24
- function pickAttrs(props, ariaOnly = false) {
25
- let mergedConfig;
26
- if (ariaOnly === false) mergedConfig = {
27
- aria: true,
28
- data: true,
29
- attr: true
30
- };
31
- else if (ariaOnly === true) mergedConfig = { aria: true };
32
- else mergedConfig = { ...ariaOnly };
33
- const attrs = {};
34
- Object.keys(props).forEach((key) => {
35
- if (mergedConfig.aria && (key === "role" || match(key, ariaPrefix)) || mergedConfig.data && match(key, dataPrefix) || mergedConfig.attr && propList.includes(key)) attrs[key] = props[key];
36
- });
37
- return attrs;
38
- }
39
- export { pickAttrs };
@@ -1,32 +0,0 @@
1
- import { omit } from "../omit.js";
2
- import { Fragment, toRef } from "vue";
3
- var defaultOptions = {
4
- class: true,
5
- style: true
6
- };
7
- function pureAttrs(attrs, options = defaultOptions) {
8
- const enableClass = options.class ?? defaultOptions.class;
9
- const enableStyle = options.style ?? defaultOptions.style;
10
- const newAttrs = { ...attrs };
11
- if (enableClass) delete newAttrs.class;
12
- if (enableStyle) delete newAttrs.style;
13
- if (options.omits && options.omits.length > 0) return omit(newAttrs, options.omits);
14
- return newAttrs;
15
- }
16
- function getAttrStyleAndClass(attrs, options) {
17
- return {
18
- className: attrs.class,
19
- style: attrs.style,
20
- restAttrs: pureAttrs(attrs, options)
21
- };
22
- }
23
- function getStylePxValue(value) {
24
- if (typeof value === "number") return `${value}px`;
25
- else if (typeof value === "string") {
26
- const trimed = value.trim();
27
- if (Number.isNaN(Number(trimed))) return trimed;
28
- else return `${Number(trimed)}px`;
29
- }
30
- return value;
31
- }
32
- export { getAttrStyleAndClass, getStylePxValue };
@@ -1,36 +0,0 @@
1
- var raf = (callback) => +setTimeout(callback, 16);
2
- var caf = (num) => clearTimeout(num);
3
- if (typeof window !== "undefined" && "requestAnimationFrame" in window) {
4
- raf = (callback) => window.requestAnimationFrame(callback);
5
- caf = (handle) => window.cancelAnimationFrame(handle);
6
- }
7
- var rafUUID = 0;
8
- var rafIds = /* @__PURE__ */ new Map();
9
- function cleanup(id) {
10
- rafIds.delete(id);
11
- }
12
- function wrapperRaf(callback, times = 1) {
13
- rafUUID += 1;
14
- const id = rafUUID;
15
- function callRef(leftTimes) {
16
- if (leftTimes === 0) {
17
- cleanup(id);
18
- callback();
19
- } else {
20
- const realId = raf(() => {
21
- callRef(leftTimes - 1);
22
- });
23
- rafIds.set(id, realId);
24
- }
25
- }
26
- callRef(times);
27
- return id;
28
- }
29
- wrapperRaf.cancel = (id) => {
30
- const realId = rafIds.get(id);
31
- cleanup(id);
32
- return caf(realId);
33
- };
34
- if (process.env.NODE_ENV !== "production") wrapperRaf.ids = () => rafIds;
35
- var raf_default = wrapperRaf;
36
- export { raf_default };
@@ -1,2 +0,0 @@
1
- var tuple = (...args) => args;
2
- export { tuple };
@@ -1,21 +0,0 @@
1
- import { tuple } from "../type.js";
2
- import { nextTick } from "vue";
3
- tuple("bottomLeft", "bottomRight", "topLeft", "topRight");
4
- function getTransitionProps(transitionName, opt = {}) {
5
- if (!transitionName) return {};
6
- return transitionName ? {
7
- name: transitionName,
8
- appear: true,
9
- enterFromClass: `${transitionName} ${transitionName}-enter ${transitionName}-appear ${transitionName}-appear-prepare ${transitionName}-enter-prepare ${transitionName}-enter-start`,
10
- enterActiveClass: `${transitionName} ${transitionName}-enter ${transitionName}-appear ${transitionName}-appear-prepare ${transitionName}-enter-prepare `,
11
- enterToClass: `${transitionName} ${transitionName}-enter ${transitionName}-appear ${transitionName}-appear-active ${transitionName}-enter-active`,
12
- leaveFromClass: `${transitionName} ${transitionName}-leave`,
13
- leaveActiveClass: `${transitionName} ${transitionName}-leave ${transitionName}-leave-active`,
14
- leaveToClass: `${transitionName} ${transitionName}-leave ${transitionName}-leave-active`,
15
- ...opt
16
- } : {
17
- css: false,
18
- ...opt
19
- };
20
- }
21
- export { getTransitionProps };
@@ -1,37 +0,0 @@
1
- var warned = {};
2
- var preWarningFns = [];
3
- function preMessage(fn) {
4
- preWarningFns.push(fn);
5
- }
6
- function warning(valid, message) {
7
- if (process.env.NODE_ENV !== "production" && !valid && console !== void 0) {
8
- const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? "", "warning"), message);
9
- if (finalMessage) console.error(`Warning: ${finalMessage}`);
10
- }
11
- }
12
- function note(valid, message) {
13
- if (process.env.NODE_ENV !== "production" && !valid && console !== void 0) {
14
- const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? "", "note"), message);
15
- if (finalMessage) console.warn(`Note: ${finalMessage}`);
16
- }
17
- }
18
- function resetWarned() {
19
- warned = {};
20
- }
21
- function call(method, valid, message) {
22
- if (!valid && !warned[message]) {
23
- method(false, message);
24
- warned[message] = true;
25
- }
26
- }
27
- function warningOnce(valid, message) {
28
- call(warning, valid, message);
29
- }
30
- function noteOnce(valid, message) {
31
- call(note, valid, message);
32
- }
33
- warningOnce.preMessage = preMessage;
34
- warningOnce.resetWarned = resetWarned;
35
- warningOnce.noteOnce = noteOnce;
36
- var warning_default = warningOnce;
37
- export { warning_default };
File without changes