@v-c/image 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/LICENSE +21 -0
  2. package/dist/Image.cjs +228 -0
  3. package/dist/Image.d.ts +46 -0
  4. package/dist/Image.js +226 -0
  5. package/dist/Preview/CloseBtn.cjs +41 -0
  6. package/dist/Preview/CloseBtn.d.ts +8 -0
  7. package/dist/Preview/CloseBtn.js +39 -0
  8. package/dist/Preview/Footer.cjs +231 -0
  9. package/dist/Preview/Footer.d.ts +24 -0
  10. package/dist/Preview/Footer.js +229 -0
  11. package/dist/Preview/PrevNext.cjs +56 -0
  12. package/dist/Preview/PrevNext.d.ts +10 -0
  13. package/dist/Preview/PrevNext.js +54 -0
  14. package/dist/Preview/index.cjs +399 -0
  15. package/dist/Preview/index.d.ts +101 -0
  16. package/dist/Preview/index.js +397 -0
  17. package/dist/PreviewGroup.cjs +135 -0
  18. package/dist/PreviewGroup.d.ts +34 -0
  19. package/dist/PreviewGroup.js +133 -0
  20. package/dist/common.cjs +12 -0
  21. package/dist/common.d.ts +2 -0
  22. package/dist/common.js +12 -0
  23. package/dist/context.cjs +10 -0
  24. package/dist/context.d.ts +7 -0
  25. package/dist/context.js +9 -0
  26. package/dist/getFixScaleEleTransPosition.cjs +25 -0
  27. package/dist/getFixScaleEleTransPosition.d.ts +16 -0
  28. package/dist/getFixScaleEleTransPosition.js +24 -0
  29. package/dist/hooks/useImageTransform.cjs +96 -0
  30. package/dist/hooks/useImageTransform.d.ts +21 -0
  31. package/dist/hooks/useImageTransform.js +95 -0
  32. package/dist/hooks/useMouseEvent.cjs +93 -0
  33. package/dist/hooks/useMouseEvent.d.ts +9 -0
  34. package/dist/hooks/useMouseEvent.js +92 -0
  35. package/dist/hooks/usePreviewItems.cjs +45 -0
  36. package/dist/hooks/usePreviewItems.d.ts +10 -0
  37. package/dist/hooks/usePreviewItems.js +44 -0
  38. package/dist/hooks/useRegisterImage.cjs +25 -0
  39. package/dist/hooks/useRegisterImage.d.ts +3 -0
  40. package/dist/hooks/useRegisterImage.js +24 -0
  41. package/dist/hooks/useStatus.cjs +46 -0
  42. package/dist/hooks/useStatus.d.ts +13 -0
  43. package/dist/hooks/useStatus.js +45 -0
  44. package/dist/hooks/useTouchEvent.cjs +120 -0
  45. package/dist/hooks/useTouchEvent.d.ts +8 -0
  46. package/dist/hooks/useTouchEvent.js +119 -0
  47. package/dist/index.cjs +8 -0
  48. package/dist/index.d.ts +11 -0
  49. package/dist/index.js +6 -0
  50. package/dist/interface.cjs +0 -0
  51. package/dist/interface.d.ts +13 -0
  52. package/dist/interface.js +0 -0
  53. package/dist/portal/dist/Context.cjs +12 -0
  54. package/dist/portal/dist/Context.js +11 -0
  55. package/dist/portal/dist/Portal.cjs +91 -0
  56. package/dist/portal/dist/Portal.js +91 -0
  57. package/dist/portal/dist/index.cjs +3 -0
  58. package/dist/portal/dist/index.js +3 -0
  59. package/dist/portal/dist/useDom.cjs +47 -0
  60. package/dist/portal/dist/useDom.js +47 -0
  61. package/dist/portal/dist/useScrollLocker.cjs +26 -0
  62. package/dist/portal/dist/useScrollLocker.js +26 -0
  63. package/dist/portal/dist/util.cjs +4 -0
  64. package/dist/portal/dist/util.js +4 -0
  65. package/dist/previewConfig.cjs +4 -0
  66. package/dist/previewConfig.d.ts +4 -0
  67. package/dist/previewConfig.js +3 -0
  68. package/dist/util/dist/Dom/canUseDom.cjs +4 -0
  69. package/dist/util/dist/Dom/canUseDom.js +4 -0
  70. package/dist/util/dist/Dom/contains.cjs +11 -0
  71. package/dist/util/dist/Dom/contains.js +11 -0
  72. package/dist/util/dist/Dom/dynamicCSS.cjs +78 -0
  73. package/dist/util/dist/Dom/dynamicCSS.js +77 -0
  74. package/dist/util/dist/KeyCode.cjs +81 -0
  75. package/dist/util/dist/KeyCode.js +81 -0
  76. package/dist/util/dist/RenderComponent.cjs +29 -0
  77. package/dist/util/dist/RenderComponent.js +29 -0
  78. package/dist/util/dist/classnames.cjs +36 -0
  79. package/dist/util/dist/classnames.js +35 -0
  80. package/dist/util/dist/getScrollBarSize.cjs +45 -0
  81. package/dist/util/dist/getScrollBarSize.js +45 -0
  82. package/dist/util/dist/hooks/useMergedState.cjs +24 -0
  83. package/dist/util/dist/hooks/useMergedState.js +24 -0
  84. package/dist/util/dist/index.cjs +3 -0
  85. package/dist/util/dist/index.js +3 -0
  86. package/dist/util/dist/isEqual.cjs +27 -0
  87. package/dist/util/dist/isEqual.js +27 -0
  88. package/dist/util/dist/omit.cjs +8 -0
  89. package/dist/util/dist/omit.js +8 -0
  90. package/dist/util/dist/pickAttrs.cjs +39 -0
  91. package/dist/util/dist/pickAttrs.js +39 -0
  92. package/dist/util/dist/props-util/index.cjs +47 -0
  93. package/dist/util/dist/props-util/index.js +44 -0
  94. package/dist/util/dist/raf.cjs +36 -0
  95. package/dist/util/dist/raf.js +36 -0
  96. package/dist/util/dist/type.cjs +2 -0
  97. package/dist/util/dist/type.js +2 -0
  98. package/dist/util/dist/utils/transition.cjs +21 -0
  99. package/dist/util/dist/utils/transition.js +21 -0
  100. package/dist/util/dist/warning.cjs +37 -0
  101. package/dist/util/dist/warning.js +37 -0
  102. package/dist/util.cjs +26 -0
  103. package/dist/util.d.ts +5 -0
  104. package/dist/util.js +25 -0
  105. package/package.json +48 -0
@@ -0,0 +1,45 @@
1
+ var cached;
2
+ function getScrollBarSize(fresh) {
3
+ if (typeof document === "undefined") return 0;
4
+ if (fresh || cached === void 0) {
5
+ const inner = document.createElement("div");
6
+ inner.style.width = "100%";
7
+ inner.style.height = "200px";
8
+ const outer = document.createElement("div");
9
+ const outerStyle = outer.style;
10
+ outerStyle.position = "absolute";
11
+ outerStyle.top = "0";
12
+ outerStyle.left = "0";
13
+ outerStyle.pointerEvents = "none";
14
+ outerStyle.visibility = "hidden";
15
+ outerStyle.width = "200px";
16
+ outerStyle.height = "150px";
17
+ outerStyle.overflow = "hidden";
18
+ outer.appendChild(inner);
19
+ document.body.appendChild(outer);
20
+ const widthContained = inner.offsetWidth;
21
+ outer.style.overflow = "scroll";
22
+ let widthScroll = inner.offsetWidth;
23
+ if (widthContained === widthScroll) widthScroll = outer.clientWidth;
24
+ document.body.removeChild(outer);
25
+ cached = widthContained - widthScroll;
26
+ }
27
+ return cached;
28
+ }
29
+ function ensureSize(str) {
30
+ const match = str.match(/^(.*)px$/);
31
+ const value = Number(match?.[1]);
32
+ return Number.isNaN(value) ? getScrollBarSize() : value;
33
+ }
34
+ function getTargetScrollBarSize(target) {
35
+ if (typeof document === "undefined" || !target || !(target instanceof Element)) return {
36
+ width: 0,
37
+ height: 0
38
+ };
39
+ const { width, height } = getComputedStyle(target, "::-webkit-scrollbar");
40
+ return {
41
+ width: ensureSize(width),
42
+ height: ensureSize(height)
43
+ };
44
+ }
45
+ exports.getTargetScrollBarSize = getTargetScrollBarSize;
@@ -0,0 +1,45 @@
1
+ var cached;
2
+ function getScrollBarSize(fresh) {
3
+ if (typeof document === "undefined") return 0;
4
+ if (fresh || cached === void 0) {
5
+ const inner = document.createElement("div");
6
+ inner.style.width = "100%";
7
+ inner.style.height = "200px";
8
+ const outer = document.createElement("div");
9
+ const outerStyle = outer.style;
10
+ outerStyle.position = "absolute";
11
+ outerStyle.top = "0";
12
+ outerStyle.left = "0";
13
+ outerStyle.pointerEvents = "none";
14
+ outerStyle.visibility = "hidden";
15
+ outerStyle.width = "200px";
16
+ outerStyle.height = "150px";
17
+ outerStyle.overflow = "hidden";
18
+ outer.appendChild(inner);
19
+ document.body.appendChild(outer);
20
+ const widthContained = inner.offsetWidth;
21
+ outer.style.overflow = "scroll";
22
+ let widthScroll = inner.offsetWidth;
23
+ if (widthContained === widthScroll) widthScroll = outer.clientWidth;
24
+ document.body.removeChild(outer);
25
+ cached = widthContained - widthScroll;
26
+ }
27
+ return cached;
28
+ }
29
+ function ensureSize(str) {
30
+ const match = str.match(/^(.*)px$/);
31
+ const value = Number(match?.[1]);
32
+ return Number.isNaN(value) ? getScrollBarSize() : value;
33
+ }
34
+ function getTargetScrollBarSize(target) {
35
+ if (typeof document === "undefined" || !target || !(target instanceof Element)) return {
36
+ width: 0,
37
+ height: 0
38
+ };
39
+ const { width, height } = getComputedStyle(target, "::-webkit-scrollbar");
40
+ return {
41
+ width: ensureSize(width),
42
+ height: ensureSize(height)
43
+ };
44
+ }
45
+ export { getTargetScrollBarSize };
@@ -0,0 +1,24 @@
1
+ let vue = require("vue");
2
+ function useMergedState(defaultStateValue, option) {
3
+ const { defaultValue, value = (0, vue.ref)() } = option || {};
4
+ let initValue = typeof defaultStateValue === "function" ? defaultStateValue() : defaultStateValue;
5
+ if (value.value !== void 0) initValue = (0, vue.unref)(value);
6
+ if (defaultValue !== void 0) initValue = typeof defaultValue === "function" ? defaultValue() : defaultValue;
7
+ const innerValue = (0, vue.ref)(initValue);
8
+ const mergedValue = (0, vue.ref)(initValue);
9
+ (0, vue.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 ((0, vue.toRaw)(mergedValue.value) !== newValue && option?.onChange) option.onChange(newValue, preVal);
18
+ }
19
+ (0, vue.watch)(value, () => {
20
+ innerValue.value = value.value;
21
+ });
22
+ return [mergedValue, triggerChange];
23
+ }
24
+ exports.useMergedState = useMergedState;
@@ -0,0 +1,24 @@
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 };
@@ -0,0 +1,3 @@
1
+ require("./RenderComponent.cjs");
2
+ const require_classnames = require("./classnames.cjs");
3
+ const require_warning = require("./warning.cjs");
@@ -0,0 +1,3 @@
1
+ import "./RenderComponent.js";
2
+ import { classNames, clsx } from "./classnames.js";
3
+ import { warning_default } from "./warning.js";
@@ -0,0 +1,27 @@
1
+ const require_warning = require("./warning.cjs");
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
+ require_warning.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
+ exports.isEqual_default = isEqual_default;
@@ -0,0 +1,27 @@
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 };
@@ -0,0 +1,8 @@
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
+ exports.omit = omit;
@@ -0,0 +1,8 @@
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 };
@@ -0,0 +1,39 @@
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
+ exports.pickAttrs = pickAttrs;
@@ -0,0 +1,39 @@
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 };
@@ -0,0 +1,47 @@
1
+ const require_omit = require("../omit.cjs");
2
+ let vue = require("vue");
3
+ function isEmptyElement(c) {
4
+ return c && (c.type === vue.Comment || c.type === vue.Fragment && c.children.length === 0 || c.type === vue.Text && c.children.trim() === "");
5
+ }
6
+ function filterEmpty(children = []) {
7
+ const res = [];
8
+ children.forEach((child) => {
9
+ if (Array.isArray(child)) res.push(...child);
10
+ else if (child?.type === vue.Fragment) res.push(...filterEmpty(child.children));
11
+ else res.push(child);
12
+ });
13
+ return res.filter((c) => !isEmptyElement(c));
14
+ }
15
+ var skipFlattenKey = Symbol("skipFlatten");
16
+ var defaultOptions = {
17
+ class: true,
18
+ style: true
19
+ };
20
+ function pureAttrs(attrs, options = defaultOptions) {
21
+ const enableClass = options.class ?? defaultOptions.class;
22
+ const enableStyle = options.style ?? defaultOptions.style;
23
+ const newAttrs = { ...attrs };
24
+ if (enableClass) delete newAttrs.class;
25
+ if (enableStyle) delete newAttrs.style;
26
+ if (options.omits && options.omits.length > 0) return require_omit.omit(newAttrs, options.omits);
27
+ return newAttrs;
28
+ }
29
+ function getAttrStyleAndClass(attrs, options) {
30
+ return {
31
+ className: attrs.class,
32
+ style: attrs.style,
33
+ restAttrs: pureAttrs(attrs, options)
34
+ };
35
+ }
36
+ function getStylePxValue(value) {
37
+ if (typeof value === "number") return `${value}px`;
38
+ else if (typeof value === "string") {
39
+ const trimed = value.trim();
40
+ if (Number.isNaN(Number(trimed))) return trimed;
41
+ else return `${Number(trimed)}px`;
42
+ }
43
+ return value;
44
+ }
45
+ exports.filterEmpty = filterEmpty;
46
+ exports.getAttrStyleAndClass = getAttrStyleAndClass;
47
+ exports.getStylePxValue = getStylePxValue;
@@ -0,0 +1,44 @@
1
+ import { omit } from "../omit.js";
2
+ import { Comment, Fragment, Text, isVNode, toRef } from "vue";
3
+ function isEmptyElement(c) {
4
+ return c && (c.type === Comment || c.type === Fragment && c.children.length === 0 || c.type === Text && c.children.trim() === "");
5
+ }
6
+ function filterEmpty(children = []) {
7
+ const res = [];
8
+ children.forEach((child) => {
9
+ if (Array.isArray(child)) res.push(...child);
10
+ else if (child?.type === Fragment) res.push(...filterEmpty(child.children));
11
+ else res.push(child);
12
+ });
13
+ return res.filter((c) => !isEmptyElement(c));
14
+ }
15
+ var defaultOptions = {
16
+ class: true,
17
+ style: true
18
+ };
19
+ function pureAttrs(attrs, options = defaultOptions) {
20
+ const enableClass = options.class ?? defaultOptions.class;
21
+ const enableStyle = options.style ?? defaultOptions.style;
22
+ const newAttrs = { ...attrs };
23
+ if (enableClass) delete newAttrs.class;
24
+ if (enableStyle) delete newAttrs.style;
25
+ if (options.omits && options.omits.length > 0) return omit(newAttrs, options.omits);
26
+ return newAttrs;
27
+ }
28
+ function getAttrStyleAndClass(attrs, options) {
29
+ return {
30
+ className: attrs.class,
31
+ style: attrs.style,
32
+ restAttrs: pureAttrs(attrs, options)
33
+ };
34
+ }
35
+ function getStylePxValue(value) {
36
+ if (typeof value === "number") return `${value}px`;
37
+ else if (typeof value === "string") {
38
+ const trimed = value.trim();
39
+ if (Number.isNaN(Number(trimed))) return trimed;
40
+ else return `${Number(trimed)}px`;
41
+ }
42
+ return value;
43
+ }
44
+ export { filterEmpty, getAttrStyleAndClass, getStylePxValue };
@@ -0,0 +1,36 @@
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
+ exports.raf_default = raf_default;
@@ -0,0 +1,36 @@
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 };
@@ -0,0 +1,2 @@
1
+ var tuple = (...args) => args;
2
+ exports.tuple = tuple;
@@ -0,0 +1,2 @@
1
+ var tuple = (...args) => args;
2
+ export { tuple };
@@ -0,0 +1,21 @@
1
+ const require_type = require("../type.cjs");
2
+ let vue = require("vue");
3
+ require_type.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
+ exports.getTransitionProps = getTransitionProps;
@@ -0,0 +1,21 @@
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 };
@@ -0,0 +1,37 @@
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
+ exports.warning_default = warning_default;
@@ -0,0 +1,37 @@
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 };
package/dist/util.cjs ADDED
@@ -0,0 +1,26 @@
1
+ function isImageValid(src) {
2
+ return new Promise((resolve) => {
3
+ if (!src) {
4
+ resolve(false);
5
+ return;
6
+ }
7
+ const isTestEnv = typeof process !== "undefined" && process.env.NODE_ENV === "test";
8
+ const isJSDomUA = typeof navigator !== "undefined" && /jsdom/i.test(navigator.userAgent);
9
+ if (isTestEnv || isJSDomUA) {
10
+ resolve(/^(https?:)?\/\//.test(src) || /^(data|blob):/.test(src) || src.startsWith("/") || src.startsWith("./") || src.startsWith("../"));
11
+ return;
12
+ }
13
+ const img = document.createElement("img");
14
+ img.onerror = () => resolve(false);
15
+ img.onload = () => resolve(true);
16
+ img.src = src;
17
+ });
18
+ }
19
+ function getClientSize() {
20
+ return {
21
+ width: document.documentElement.clientWidth,
22
+ height: window.innerHeight || document.documentElement.clientHeight
23
+ };
24
+ }
25
+ exports.getClientSize = getClientSize;
26
+ exports.isImageValid = isImageValid;
package/dist/util.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export declare function isImageValid(src: string): Promise<unknown>;
2
+ export declare function getClientSize(): {
3
+ width: number;
4
+ height: number;
5
+ };
package/dist/util.js ADDED
@@ -0,0 +1,25 @@
1
+ function isImageValid(src) {
2
+ return new Promise((resolve) => {
3
+ if (!src) {
4
+ resolve(false);
5
+ return;
6
+ }
7
+ const isTestEnv = typeof process !== "undefined" && process.env.NODE_ENV === "test";
8
+ const isJSDomUA = typeof navigator !== "undefined" && /jsdom/i.test(navigator.userAgent);
9
+ if (isTestEnv || isJSDomUA) {
10
+ resolve(/^(https?:)?\/\//.test(src) || /^(data|blob):/.test(src) || src.startsWith("/") || src.startsWith("./") || src.startsWith("../"));
11
+ return;
12
+ }
13
+ const img = document.createElement("img");
14
+ img.onerror = () => resolve(false);
15
+ img.onload = () => resolve(true);
16
+ img.src = src;
17
+ });
18
+ }
19
+ function getClientSize() {
20
+ return {
21
+ width: document.documentElement.clientWidth,
22
+ height: window.innerHeight || document.documentElement.clientHeight
23
+ };
24
+ }
25
+ export { getClientSize, isImageValid };