@v-c/util 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 (62) hide show
  1. package/dist/hooks/useControlledState.d.ts +2 -0
  2. package/dist/hooks/useControlledState.js +18 -0
  3. package/dist/index.d.ts +2 -1
  4. package/dist/index.js +3 -2
  5. package/dist/utils/set.d.ts +14 -1
  6. package/dist/utils/set.js +9 -4
  7. package/package.json +49 -1
  8. package/dist/Children/isFragment.cjs +0 -6
  9. package/dist/Children/toArray.cjs +0 -14
  10. package/dist/Dom/addEventListener.cjs +0 -9
  11. package/dist/Dom/canUseDom.cjs +0 -8
  12. package/dist/Dom/class.cjs +0 -16
  13. package/dist/Dom/contains.cjs +0 -15
  14. package/dist/Dom/css.cjs +0 -82
  15. package/dist/Dom/dynamicCSS.cjs +0 -86
  16. package/dist/Dom/findDOMNode.cjs +0 -23
  17. package/dist/Dom/focus.cjs +0 -101
  18. package/dist/Dom/isVisible.cjs +0 -20
  19. package/dist/Dom/scrollLocker.cjs +0 -70
  20. package/dist/Dom/shadow.cjs +0 -12
  21. package/dist/Dom/styleChecker.cjs +0 -22
  22. package/dist/Dom/support.cjs +0 -21
  23. package/dist/EventInterface.cjs +0 -1
  24. package/dist/KeyCode.cjs +0 -250
  25. package/dist/Portal.cjs +0 -45
  26. package/dist/PortalWrapper.cjs +0 -138
  27. package/dist/RenderComponent.cjs +0 -34
  28. package/dist/classnames.cjs +0 -40
  29. package/dist/composeProps.cjs +0 -20
  30. package/dist/createRef.cjs +0 -25
  31. package/dist/debug/diff.cjs +0 -47
  32. package/dist/deprecated.cjs +0 -8
  33. package/dist/getScrollBarSize.cjs +0 -58
  34. package/dist/guid.cjs +0 -9
  35. package/dist/hooks/useEvent.cjs +0 -8
  36. package/dist/hooks/useId.cjs +0 -16
  37. package/dist/hooks/useLayoutEffect.cjs +0 -36
  38. package/dist/hooks/useMemo.cjs +0 -18
  39. package/dist/hooks/useMergedState.cjs +0 -28
  40. package/dist/hooks/useMobile.cjs +0 -19
  41. package/dist/hooks/useState.cjs +0 -13
  42. package/dist/index.cjs +0 -22
  43. package/dist/isEqual.cjs +0 -31
  44. package/dist/isMobile.cjs +0 -10
  45. package/dist/isValid.cjs +0 -9
  46. package/dist/omit.cjs +0 -12
  47. package/dist/pickAttrs.cjs +0 -43
  48. package/dist/props-util/index.cjs +0 -87
  49. package/dist/raf.cjs +0 -48
  50. package/dist/setStyle.cjs +0 -19
  51. package/dist/switchScrollingEffect.cjs +0 -35
  52. package/dist/test/domHook.cjs +0 -39
  53. package/dist/type.cjs +0 -71
  54. package/dist/utils/checkSlotProp.cjs +0 -10
  55. package/dist/utils/get.cjs +0 -13
  56. package/dist/utils/omit.cjs +0 -9
  57. package/dist/utils/set.cjs +0 -53
  58. package/dist/utils/transition.cjs +0 -94
  59. package/dist/utils/watchState.cjs +0 -19
  60. package/dist/vnode.cjs +0 -71
  61. package/dist/vueuse/unref-element.cjs +0 -7
  62. package/dist/warning.cjs +0 -48
@@ -1,8 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- function useEvent(callback) {
6
- return callback;
7
- }
8
- exports.default = useEvent;
@@ -1,16 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- let vue = require("vue");
6
- function getUseId() {
7
- return vue.useId;
8
- }
9
- var useOriginalId = getUseId();
10
- function useId_default(id) {
11
- const vueId = useOriginalId();
12
- if (id) return id;
13
- if (process.env.NODE_ENV === "test") return "test-id";
14
- return vueId;
15
- }
16
- exports.default = useId_default;
@@ -1,36 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- let vue = require("vue");
3
- function useLayoutEffect(callback, deps = []) {
4
- let close = null;
5
- if (deps && deps.length) (0, vue.watch)(deps, async () => {
6
- if (close) close?.();
7
- await (0, vue.nextTick)();
8
- if (typeof callback === "function") close = callback();
9
- }, {
10
- immediate: true,
11
- flush: "post"
12
- });
13
- else {
14
- (0, vue.onMounted)(() => {
15
- if (close) close?.();
16
- if (typeof callback === "function") close = callback();
17
- });
18
- (0, vue.onUpdated)(() => {
19
- if (close) close?.();
20
- if (typeof callback === "function") close = callback();
21
- });
22
- }
23
- (0, vue.onUnmounted)(() => {
24
- if (close) close?.();
25
- });
26
- }
27
- function useLayoutUpdateEffect(callback, deps) {
28
- let close = null;
29
- (0, vue.watch)(deps, async () => {
30
- if (close) close?.();
31
- await (0, vue.nextTick)();
32
- if (typeof callback === "function") close = callback();
33
- }, { flush: "post" });
34
- }
35
- exports.useLayoutEffect = useLayoutEffect;
36
- exports.useLayoutUpdateEffect = useLayoutUpdateEffect;
@@ -1,18 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- let vue = require("vue");
6
- function useMemo(getValue, condition, shouldUpdate) {
7
- const cacheRef = (0, vue.ref)(getValue());
8
- (0, vue.watch)(condition.map((item) => {
9
- if (typeof item === "function" || (0, vue.isRef)(item) || (0, vue.isReactive)(item)) return item;
10
- return () => item;
11
- }), (next, pre) => {
12
- if (shouldUpdate) {
13
- if (shouldUpdate(next, pre)) cacheRef.value = getValue();
14
- } else cacheRef.value = getValue();
15
- });
16
- return cacheRef;
17
- }
18
- exports.default = useMemo;
@@ -1,28 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- let vue = require("vue");
6
- function useMergedState(defaultStateValue, option) {
7
- const { defaultValue, value = (0, vue.ref)() } = option || {};
8
- let initValue = typeof defaultStateValue === "function" ? defaultStateValue() : defaultStateValue;
9
- if (value.value !== void 0) initValue = (0, vue.unref)(value);
10
- if (defaultValue !== void 0) initValue = typeof defaultValue === "function" ? defaultValue() : defaultValue;
11
- const innerValue = (0, vue.ref)(initValue);
12
- const mergedValue = (0, vue.ref)(initValue);
13
- (0, vue.watchEffect)(() => {
14
- let val = value.value !== void 0 ? value.value : innerValue.value;
15
- if (option?.postState) val = option.postState(val);
16
- mergedValue.value = val;
17
- });
18
- function triggerChange(newValue) {
19
- const preVal = mergedValue.value;
20
- innerValue.value = newValue;
21
- if ((0, vue.toRaw)(mergedValue.value) !== newValue && option?.onChange) option.onChange(newValue, preVal);
22
- }
23
- (0, vue.watch)(value, () => {
24
- innerValue.value = value.value;
25
- });
26
- return [mergedValue, triggerChange];
27
- }
28
- exports.default = useMergedState;
@@ -1,19 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- const require_isMobile = require("../isMobile.cjs");
6
- let vue = require("vue");
7
- function useMobile() {
8
- const mobile = (0, vue.shallowRef)(false);
9
- (0, vue.onMounted)(() => {
10
- mobile.value = require_isMobile.default();
11
- });
12
- (0, vue.onUpdated)(() => {
13
- mobile.value = require_isMobile.default();
14
- });
15
- return mobile;
16
- }
17
- var useMobile_default = useMobile;
18
- exports.default = useMobile_default;
19
- exports.useMobile = useMobile;
@@ -1,13 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- let vue = require("vue");
6
- function useState(defaultStateValue) {
7
- const innerValue = (0, vue.ref)(typeof defaultStateValue === "function" ? defaultStateValue() : defaultStateValue);
8
- function triggerChange(newValue) {
9
- innerValue.value = newValue;
10
- }
11
- return [innerValue, triggerChange];
12
- }
13
- exports.default = useState;
package/dist/index.cjs DELETED
@@ -1,22 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_KeyCode = require("./KeyCode.cjs");
3
- const require_raf = require("./raf.cjs");
4
- const require_omit = require("./omit.cjs");
5
- const require_RenderComponent = require("./RenderComponent.cjs");
6
- const require_classnames = require("./classnames.cjs");
7
- const require_useId = require("./hooks/useId.cjs");
8
- const require_useMergedState = require("./hooks/useMergedState.cjs");
9
- const require_get = require("./utils/get.cjs");
10
- const require_set = require("./utils/set.cjs");
11
- const require_warning = require("./warning.cjs");
12
- exports.KeyCode = require_KeyCode.default;
13
- exports.RenderComponent = require_RenderComponent.default;
14
- exports.classNames = require_classnames.default;
15
- exports.clsx = require_classnames.clsx;
16
- exports.get = require_get.default;
17
- exports.omit = require_omit.default;
18
- exports.raf = require_raf.default;
19
- exports.set = require_set.default;
20
- exports.useId = require_useId.default;
21
- exports.useMergedState = require_useMergedState.default;
22
- exports.warning = require_warning.default;
package/dist/isEqual.cjs DELETED
@@ -1,31 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- const require_warning = require("./warning.cjs");
6
- function isEqual(obj1, obj2, shallow = false) {
7
- const refSet = /* @__PURE__ */ new Set();
8
- function deepEqual(a, b, level = 1) {
9
- const circular = refSet.has(a);
10
- require_warning.default(!circular, "Warning: There may be circular references");
11
- if (circular) return false;
12
- if (a === b) return true;
13
- if (shallow && level > 1) return false;
14
- refSet.add(a);
15
- const newLevel = level + 1;
16
- if (Array.isArray(a)) {
17
- if (!Array.isArray(b) || a.length !== b.length) return false;
18
- for (let i = 0; i < a.length; i++) if (!deepEqual(a[i], b[i], newLevel)) return false;
19
- return true;
20
- }
21
- if (a && b && typeof a === "object" && typeof b === "object") {
22
- const keys = Object.keys(a);
23
- if (keys.length !== Object.keys(b).length) return false;
24
- return keys.every((key) => deepEqual(a[key], b[key], newLevel));
25
- }
26
- return false;
27
- }
28
- return deepEqual(obj1, obj2);
29
- }
30
- var isEqual_default = isEqual;
31
- exports.default = isEqual_default;
package/dist/isMobile.cjs DELETED
@@ -1,10 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- var isMobile_default = () => {
6
- if (typeof navigator === "undefined" || typeof window === "undefined") return false;
7
- const agent = navigator.userAgent || navigator.vendor || window.opera;
8
- return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(agent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-([mpt])|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c([\- _agpst])|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac([ \-/])|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/([klu])|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t([\- ov])|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[23]|n30(0|2)|n50([025])|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan([adt])|pdxg|pg(13|-([1-8c]))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c([\-01])|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(agent?.substr(0, 4));
9
- };
10
- exports.default = isMobile_default;
package/dist/isValid.cjs DELETED
@@ -1,9 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- function isValid(value) {
6
- return value !== void 0 && value !== null && value !== "";
7
- }
8
- var isValid_default = isValid;
9
- exports.default = isValid_default;
package/dist/omit.cjs DELETED
@@ -1,12 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- function omit(obj, fields) {
6
- const clone = { ...obj };
7
- if (Array.isArray(fields)) fields.forEach((key) => {
8
- delete clone[key];
9
- });
10
- return clone;
11
- }
12
- exports.default = omit;
@@ -1,43 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- var propList = `accept acceptCharset accessKey action allowFullScreen allowTransparency
6
- alt async autoComplete autoFocus autoPlay capture cellPadding cellSpacing challenge
7
- charSet checked classID className colSpan cols content contentEditable contextMenu
8
- controls coords crossOrigin data dateTime default defer dir disabled download draggable
9
- encType form formAction formEncType formMethod formNoValidate formTarget frameBorder
10
- headers height hidden high href hrefLang htmlFor httpEquiv icon id inputMode integrity
11
- is keyParams keyType kind label lang list loop low manifest marginHeight marginWidth max maxLength media
12
- mediaGroup method min minLength multiple muted name noValidate nonce open
13
- optimum pattern placeholder poster preload radioGroup readOnly rel required
14
- reversed role rowSpan rows sandbox scope scoped scrolling seamless selected
15
- shape size sizes span spellCheck src srcDoc srcLang srcSet start step style
16
- summary tabIndex target title type useMap value width wmode wrap onCopy onCut onPaste onCompositionEnd onCompositionStart onCompositionUpdate onKeyDown
17
- onKeyPress onKeyUp onFocus onBlur onChange onInput onSubmit onClick onContextMenu onDoubleClick
18
- onDrag onDragEnd onDragEnter onDragExit onDragLeave onDragOver onDragStart onDrop onMouseDown
19
- onMouseEnter onMouseLeave onMouseMove onMouseOut onMouseOver onMouseUp onSelect onTouchCancel
20
- onTouchEnd onTouchMove onTouchStart onScroll onWheel onAbort onCanPlay onCanPlayThrough
21
- onDurationChange onEmptied onEncrypted onEnded onError onLoadedData onLoadedMetadata
22
- onLoadStart onPause onPlay onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend onTimeUpdate onVolumeChange onWaiting onLoad onError`.split(/\s+/);
23
- var ariaPrefix = "aria-";
24
- var dataPrefix = "data-";
25
- function match(key, prefix) {
26
- return key.indexOf(prefix) === 0;
27
- }
28
- function pickAttrs(props, ariaOnly = false) {
29
- let mergedConfig;
30
- if (ariaOnly === false) mergedConfig = {
31
- aria: true,
32
- data: true,
33
- attr: true
34
- };
35
- else if (ariaOnly === true) mergedConfig = { aria: true };
36
- else mergedConfig = { ...ariaOnly };
37
- const attrs = {};
38
- Object.keys(props).forEach((key) => {
39
- if (mergedConfig.aria && (key === "role" || match(key, ariaPrefix)) || mergedConfig.data && match(key, dataPrefix) || mergedConfig.attr && propList.includes(key)) attrs[key] = props[key];
40
- });
41
- return attrs;
42
- }
43
- exports.default = pickAttrs;
@@ -1,87 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_isValid = require("../isValid.cjs");
3
- const require_omit = require("../omit.cjs");
4
- let vue = require("vue");
5
- function isEmptyElement(c) {
6
- return c && (c.type === vue.Comment || c.type === vue.Fragment && c.children.length === 0 || c.type === vue.Text && c.children.trim() === "");
7
- }
8
- function filterEmpty(children = []) {
9
- if (!Array.isArray(children)) children = [children];
10
- const res = [];
11
- children.forEach((child) => {
12
- if (Array.isArray(child)) res.push(...child);
13
- else if (child?.type === vue.Fragment) res.push(...filterEmpty(child.children));
14
- else res.push(child);
15
- });
16
- return res.filter((c) => !isEmptyElement(c));
17
- }
18
- const skipFlattenKey = Symbol("skipFlatten");
19
- function flattenChildren(children, isFilterEmpty = true) {
20
- const temp = Array.isArray(children) ? children : [children];
21
- const res = [];
22
- temp.forEach((child) => {
23
- if (Array.isArray(child)) res.push(...flattenChildren(child, isFilterEmpty));
24
- else if (require_isValid.default(child)) res.push(child);
25
- else if (child && typeof child === "object" && child.type === vue.Fragment) if (child.key === skipFlattenKey) res.push(child);
26
- else res.push(...flattenChildren(child.children, isFilterEmpty));
27
- else if (child && (0, vue.isVNode)(child)) {
28
- if (isFilterEmpty && !isEmptyElement(child)) res.push(child);
29
- else if (!isFilterEmpty) res.push(child);
30
- }
31
- });
32
- if (isFilterEmpty) return filterEmpty(res);
33
- return res;
34
- }
35
- function toPropsRefs(obj, ...args) {
36
- const _res = {};
37
- args.forEach((key) => {
38
- _res[key] = (0, vue.toRef)(obj, key);
39
- });
40
- return _res;
41
- }
42
- function removeUndefined(obj) {
43
- const res = {};
44
- Object.keys(obj).forEach((key) => {
45
- const value = obj[key];
46
- if (value !== void 0) res[key] = value;
47
- });
48
- return res;
49
- }
50
- var defaultOptions = {
51
- class: true,
52
- style: true
53
- };
54
- function pureAttrs(attrs, options = defaultOptions) {
55
- const enableClass = options.class ?? defaultOptions.class;
56
- const enableStyle = options.style ?? defaultOptions.style;
57
- const newAttrs = { ...attrs };
58
- if (enableClass) delete newAttrs.class;
59
- if (enableStyle) delete newAttrs.style;
60
- if (options.omits && options.omits.length > 0) return require_omit.default(newAttrs, options.omits);
61
- return newAttrs;
62
- }
63
- function getAttrStyleAndClass(attrs, options) {
64
- return {
65
- className: attrs.class,
66
- style: attrs.style,
67
- restAttrs: pureAttrs(attrs, options)
68
- };
69
- }
70
- function getStylePxValue(value) {
71
- if (typeof value === "number") return `${value}px`;
72
- else if (typeof value === "string") {
73
- const trimed = value.trim();
74
- if (Number.isNaN(Number(trimed))) return trimed;
75
- else return `${Number(trimed)}px`;
76
- }
77
- return value;
78
- }
79
- exports.filterEmpty = filterEmpty;
80
- exports.flattenChildren = flattenChildren;
81
- exports.getAttrStyleAndClass = getAttrStyleAndClass;
82
- exports.getStylePxValue = getStylePxValue;
83
- exports.isEmptyElement = isEmptyElement;
84
- exports.pureAttrs = pureAttrs;
85
- exports.removeUndefined = removeUndefined;
86
- exports.skipFlattenKey = skipFlattenKey;
87
- exports.toPropsRefs = toPropsRefs;
package/dist/raf.cjs DELETED
@@ -1,48 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- var raf = (callback) => +setTimeout(callback, 16);
6
- var caf = (num) => clearTimeout(num);
7
- if (typeof window !== "undefined" && "requestAnimationFrame" in window) {
8
- raf = (callback) => window.requestAnimationFrame(callback);
9
- caf = (handle) => window.cancelAnimationFrame(handle);
10
- }
11
- var rafUUID = 0;
12
- var rafIds = /* @__PURE__ */ new Map();
13
- function cleanup(id) {
14
- rafIds.delete(id);
15
- }
16
- function wrapperRaf(callback, times = 1) {
17
- rafUUID += 1;
18
- const id = rafUUID;
19
- function callRef(leftTimes) {
20
- if (leftTimes === 0) {
21
- cleanup(id);
22
- callback();
23
- } else {
24
- const realId = raf(() => {
25
- callRef(leftTimes - 1);
26
- });
27
- rafIds.set(id, realId);
28
- }
29
- }
30
- callRef(times);
31
- return id;
32
- }
33
- wrapperRaf.cancel = (id) => {
34
- const realId = rafIds.get(id);
35
- cleanup(id);
36
- return caf(realId);
37
- };
38
- if (process.env.NODE_ENV !== "production") wrapperRaf.ids = () => rafIds;
39
- var raf_default = wrapperRaf;
40
- function rafDebounce(fn) {
41
- let id = null;
42
- return () => {
43
- if (id !== null) wrapperRaf.cancel(id);
44
- id = wrapperRaf(fn);
45
- };
46
- }
47
- exports.default = raf_default;
48
- exports.rafDebounce = rafDebounce;
package/dist/setStyle.cjs DELETED
@@ -1,19 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- function setStyle(style, options = {}) {
6
- if (!style) return {};
7
- const { element = document.body } = options;
8
- const oldStyle = {};
9
- const styleKeys = Object.keys(style);
10
- styleKeys.forEach((key) => {
11
- oldStyle[key] = element.style[key];
12
- });
13
- styleKeys.forEach((key) => {
14
- element.style[key] = style[key];
15
- });
16
- return oldStyle;
17
- }
18
- var setStyle_default = setStyle;
19
- exports.default = setStyle_default;
@@ -1,35 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- const require_getScrollBarSize = require("./getScrollBarSize.cjs");
6
- const require_setStyle = require("./setStyle.cjs");
7
- function isBodyOverflowing() {
8
- return document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight) && window.innerWidth > document.body.offsetWidth;
9
- }
10
- var cacheStyle = {};
11
- var switchScrollingEffect_default = (close) => {
12
- if (!isBodyOverflowing() && !close) return;
13
- const scrollingEffectClassName = "ant-scrolling-effect";
14
- const scrollingEffectClassNameReg = new RegExp(`${scrollingEffectClassName}`, "g");
15
- const bodyClassName = document.body.className;
16
- if (close) {
17
- if (!scrollingEffectClassNameReg.test(bodyClassName)) return;
18
- require_setStyle.default(cacheStyle);
19
- cacheStyle = {};
20
- document.body.className = bodyClassName.replace(scrollingEffectClassNameReg, "").trim();
21
- return;
22
- }
23
- const scrollBarSize = require_getScrollBarSize.default();
24
- if (scrollBarSize) {
25
- cacheStyle = require_setStyle.default({
26
- position: "relative",
27
- width: `calc(100% - ${scrollBarSize}px)`
28
- });
29
- if (!scrollingEffectClassNameReg.test(bodyClassName)) {
30
- const addClassName = `${bodyClassName} ${scrollingEffectClassName}`;
31
- document.body.className = addClassName.trim();
32
- }
33
- }
34
- };
35
- exports.default = switchScrollingEffect_default;
@@ -1,39 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- var NO_EXIST = { __NOT_EXIST: true };
3
- function spyElementPrototypes(elementClass, properties) {
4
- const propNames = Object.keys(properties);
5
- const originDescriptors = {};
6
- propNames.forEach((propName) => {
7
- const originDescriptor = Object.getOwnPropertyDescriptor(elementClass.prototype, propName);
8
- originDescriptors[propName] = originDescriptor || NO_EXIST;
9
- const spyProp = properties[propName];
10
- if (typeof spyProp === "function") elementClass.prototype[propName] = function spyFunc(...args) {
11
- return spyProp.call(this, originDescriptor, ...args);
12
- };
13
- else Object.defineProperty(elementClass.prototype, propName, {
14
- ...spyProp,
15
- set(value) {
16
- if (spyProp.set) return spyProp.set.call(this, originDescriptor, value);
17
- return originDescriptor.set(value);
18
- },
19
- get() {
20
- if (spyProp.get) return spyProp.get.call(this, originDescriptor);
21
- return originDescriptor.get();
22
- },
23
- configurable: true
24
- });
25
- });
26
- return { mockRestore() {
27
- propNames.forEach((propName) => {
28
- const originDescriptor = originDescriptors[propName];
29
- if (originDescriptor === NO_EXIST) delete elementClass.prototype[propName];
30
- else if (typeof originDescriptor === "function") elementClass.prototype[propName] = originDescriptor;
31
- else Object.defineProperty(elementClass.prototype, propName, originDescriptor);
32
- });
33
- } };
34
- }
35
- function spyElementPrototype(Element, propName, property) {
36
- return spyElementPrototypes(Element, { [propName]: property });
37
- }
38
- exports.spyElementPrototype = spyElementPrototype;
39
- exports.spyElementPrototypes = spyElementPrototypes;
package/dist/type.cjs DELETED
@@ -1,71 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const tuple = (...args) => args;
3
- const tupleNum = (...args) => args;
4
- function withInstall(comp) {
5
- const c = comp;
6
- c.install = function(app) {
7
- app.component(c.displayName || c.name, comp);
8
- };
9
- return comp;
10
- }
11
- function eventType() {
12
- return { type: [Function, Array] };
13
- }
14
- function objectType(defaultVal) {
15
- return {
16
- type: Object,
17
- default: defaultVal
18
- };
19
- }
20
- function booleanType(defaultVal) {
21
- return {
22
- type: Boolean,
23
- default: defaultVal
24
- };
25
- }
26
- function functionType(defaultVal) {
27
- return {
28
- type: Function,
29
- default: defaultVal
30
- };
31
- }
32
- function anyType(defaultVal, required) {
33
- const type = {
34
- validator: () => true,
35
- default: defaultVal
36
- };
37
- return required ? type : type;
38
- }
39
- function vNodeType() {
40
- return { validator: () => true };
41
- }
42
- function arrayType(defaultVal) {
43
- return {
44
- type: Array,
45
- default: defaultVal
46
- };
47
- }
48
- function stringType(defaultVal) {
49
- return {
50
- type: String,
51
- default: defaultVal
52
- };
53
- }
54
- function someType(types, defaultVal) {
55
- return types ? {
56
- type: types,
57
- default: defaultVal
58
- } : anyType(defaultVal);
59
- }
60
- exports.anyType = anyType;
61
- exports.arrayType = arrayType;
62
- exports.booleanType = booleanType;
63
- exports.eventType = eventType;
64
- exports.functionType = functionType;
65
- exports.objectType = objectType;
66
- exports.someType = someType;
67
- exports.stringType = stringType;
68
- exports.tuple = tuple;
69
- exports.tupleNum = tupleNum;
70
- exports.vNodeType = vNodeType;
71
- exports.withInstall = withInstall;
@@ -1,10 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- function checkSlotProp(props, slots, name, ...args) {
3
- if (slots[name]) return slots[name]?.(...args);
4
- if (name in props) {
5
- if (typeof props[name] === "function") return props[name]?.(...args);
6
- return props[name];
7
- }
8
- return null;
9
- }
10
- exports.checkSlotProp = checkSlotProp;
@@ -1,13 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- function get(entity, path) {
6
- let current = entity;
7
- for (let i = 0; i < path.length; i += 1) {
8
- if (current === null || current === void 0) return void 0;
9
- current = current[path[i]];
10
- }
11
- return current;
12
- }
13
- exports.default = get;
@@ -1,9 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- function omit(obj, keys) {
3
- const result = { ...obj };
4
- keys.forEach((key) => {
5
- delete result[key];
6
- });
7
- return result;
8
- }
9
- exports.omit = omit;