@v-c/util 0.0.12 → 0.0.13
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.
- package/dist/Children/isFragment.cjs +7 -1
- package/dist/Children/isFragment.js +4 -4
- package/dist/Children/toArray.cjs +20 -1
- package/dist/Children/toArray.js +17 -8
- package/dist/Dom/addEventListener.cjs +13 -1
- package/dist/Dom/addEventListener.js +7 -5
- package/dist/Dom/canUseDom.cjs +6 -1
- package/dist/Dom/canUseDom.js +3 -3
- package/dist/Dom/class.cjs +29 -1
- package/dist/Dom/class.js +23 -13
- package/dist/Dom/contains.cjs +16 -1
- package/dist/Dom/contains.js +12 -12
- package/dist/Dom/css.cjs +96 -1
- package/dist/Dom/css.js +69 -48
- package/dist/Dom/dynamicCSS.cjs +110 -1
- package/dist/Dom/dynamicCSS.js +92 -59
- package/dist/Dom/findDOMNode.cjs +16 -1
- package/dist/Dom/findDOMNode.js +12 -8
- package/dist/Dom/focus.cjs +60 -1
- package/dist/Dom/focus.js +48 -28
- package/dist/Dom/isVisible.cjs +22 -1
- package/dist/Dom/isVisible.js +16 -16
- package/dist/Dom/scrollLocker.cjs +89 -1
- package/dist/Dom/scrollLocker.js +70 -45
- package/dist/Dom/shadow.cjs +13 -1
- package/dist/Dom/shadow.js +8 -8
- package/dist/Dom/styleChecker.cjs +25 -1
- package/dist/Dom/styleChecker.js +19 -14
- package/dist/Dom/support.cjs +28 -1
- package/dist/Dom/support.js +16 -12
- package/dist/KeyCode.cjs +523 -1
- package/dist/KeyCode.js +62 -55
- package/dist/Portal.cjs +48 -1
- package/dist/Portal.js +34 -19
- package/dist/PortalWrapper.cjs +169 -1
- package/dist/PortalWrapper.js +133 -79
- package/dist/classnames.cjs +45 -1
- package/dist/classnames.js +38 -25
- package/dist/composeProps.cjs +19 -1
- package/dist/composeProps.js +15 -9
- package/dist/createRef.cjs +24 -1
- package/dist/createRef.js +16 -13
- package/dist/debug/diff.cjs +50 -1
- package/dist/debug/diff.js +39 -30
- package/dist/deprecated.cjs +10 -1
- package/dist/deprecated.js +7 -5
- package/dist/getScrollBarSize.cjs +51 -1
- package/dist/getScrollBarSize.js +39 -25
- package/dist/guid.cjs +7 -1
- package/dist/guid.js +4 -4
- package/dist/hooks/useEvent.cjs +6 -1
- package/dist/hooks/useEvent.js +3 -3
- package/dist/hooks/useId.cjs +18 -1
- package/dist/hooks/useId.js +14 -8
- package/dist/hooks/useLayoutEffect.cjs +58 -1
- package/dist/hooks/useLayoutEffect.js +50 -20
- package/dist/hooks/useMemo.cjs +16 -1
- package/dist/hooks/useMemo.js +13 -7
- package/dist/hooks/useMergedState.cjs +30 -1
- package/dist/hooks/useMergedState.js +25 -16
- package/dist/hooks/useMobile.cjs +16 -1
- package/dist/hooks/useMobile.js +13 -11
- package/dist/hooks/useState.cjs +12 -1
- package/dist/hooks/useState.js +8 -7
- package/dist/index.cjs +11 -1
- package/dist/index.js +9 -9
- package/dist/isEqual.cjs +36 -1
- package/dist/isEqual.js +30 -26
- package/dist/isMobile.cjs +13 -1
- package/dist/isMobile.js +7 -7
- package/dist/isValid.cjs +6 -1
- package/dist/isValid.js +3 -3
- package/dist/omit.cjs +12 -1
- package/dist/omit.js +9 -6
- package/dist/pickAttrs.cjs +41 -3
- package/dist/pickAttrs.js +37 -22
- package/dist/props-util/index.cjs +69 -1
- package/dist/props-util/index.js +62 -32
- package/dist/raf.cjs +48 -1
- package/dist/raf.js +37 -26
- package/dist/setStyle.cjs +17 -1
- package/dist/setStyle.js +13 -9
- package/dist/switchScrollingEffect.cjs +38 -1
- package/dist/switchScrollingEffect.js +27 -20
- package/dist/test/domHook.cjs +52 -1
- package/dist/test/domHook.js +43 -28
- package/dist/type.cjs +51 -1
- package/dist/type.js +39 -37
- package/dist/utils/checkSlotProp.cjs +13 -1
- package/dist/utils/checkSlotProp.js +10 -3
- package/dist/utils/get.cjs +12 -1
- package/dist/utils/get.js +8 -8
- package/dist/utils/omit.cjs +10 -1
- package/dist/utils/omit.js +7 -6
- package/dist/utils/set.cjs +64 -1
- package/dist/utils/set.js +54 -32
- package/dist/utils/transition.cjs +96 -1
- package/dist/utils/transition.d.ts +2 -2
- package/dist/utils/transition.js +70 -65
- package/dist/utils/watchState.cjs +20 -1
- package/dist/utils/watchState.js +15 -10
- package/dist/vnode.cjs +56 -1
- package/dist/vnode.js +46 -30
- package/dist/vueuse/unref-element.cjs +8 -1
- package/dist/vueuse/unref-element.js +5 -5
- package/dist/warning.cjs +53 -1
- package/dist/warning.js +40 -35
- package/package.json +1 -1
package/dist/type.cjs
CHANGED
|
@@ -1 +1,51 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const tuple = (...args) => args;
|
|
4
|
+
const tupleNum = (...args) => args;
|
|
5
|
+
function withInstall(comp) {
|
|
6
|
+
const c = comp;
|
|
7
|
+
c.install = function(app) {
|
|
8
|
+
app.component(c.displayName || c.name, comp);
|
|
9
|
+
};
|
|
10
|
+
return comp;
|
|
11
|
+
}
|
|
12
|
+
function eventType() {
|
|
13
|
+
return { type: [Function, Array] };
|
|
14
|
+
}
|
|
15
|
+
function objectType(defaultVal) {
|
|
16
|
+
return { type: Object, default: defaultVal };
|
|
17
|
+
}
|
|
18
|
+
function booleanType(defaultVal) {
|
|
19
|
+
return { type: Boolean, default: defaultVal };
|
|
20
|
+
}
|
|
21
|
+
function functionType(defaultVal) {
|
|
22
|
+
return { type: Function, default: defaultVal };
|
|
23
|
+
}
|
|
24
|
+
function anyType(defaultVal, required) {
|
|
25
|
+
const type = { validator: () => true, default: defaultVal };
|
|
26
|
+
return required ? type : type;
|
|
27
|
+
}
|
|
28
|
+
function vNodeType() {
|
|
29
|
+
return { validator: () => true };
|
|
30
|
+
}
|
|
31
|
+
function arrayType(defaultVal) {
|
|
32
|
+
return { type: Array, default: defaultVal };
|
|
33
|
+
}
|
|
34
|
+
function stringType(defaultVal) {
|
|
35
|
+
return { type: String, default: defaultVal };
|
|
36
|
+
}
|
|
37
|
+
function someType(types, defaultVal) {
|
|
38
|
+
return types ? { type: types, default: defaultVal } : anyType(defaultVal);
|
|
39
|
+
}
|
|
40
|
+
exports.anyType = anyType;
|
|
41
|
+
exports.arrayType = arrayType;
|
|
42
|
+
exports.booleanType = booleanType;
|
|
43
|
+
exports.eventType = eventType;
|
|
44
|
+
exports.functionType = functionType;
|
|
45
|
+
exports.objectType = objectType;
|
|
46
|
+
exports.someType = someType;
|
|
47
|
+
exports.stringType = stringType;
|
|
48
|
+
exports.tuple = tuple;
|
|
49
|
+
exports.tupleNum = tupleNum;
|
|
50
|
+
exports.vNodeType = vNodeType;
|
|
51
|
+
exports.withInstall = withInstall;
|
package/dist/type.js
CHANGED
|
@@ -1,49 +1,51 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
1
|
+
const tuple = (...args) => args;
|
|
2
|
+
const tupleNum = (...args) => args;
|
|
3
|
+
function withInstall(comp) {
|
|
4
|
+
const c = comp;
|
|
5
|
+
c.install = function(app) {
|
|
6
|
+
app.component(c.displayName || c.name, comp);
|
|
7
|
+
};
|
|
8
|
+
return comp;
|
|
9
|
+
}
|
|
10
|
+
function eventType() {
|
|
9
11
|
return { type: [Function, Array] };
|
|
10
12
|
}
|
|
11
|
-
function
|
|
12
|
-
return { type: Object, default:
|
|
13
|
+
function objectType(defaultVal) {
|
|
14
|
+
return { type: Object, default: defaultVal };
|
|
13
15
|
}
|
|
14
|
-
function
|
|
15
|
-
return { type: Boolean, default:
|
|
16
|
+
function booleanType(defaultVal) {
|
|
17
|
+
return { type: Boolean, default: defaultVal };
|
|
16
18
|
}
|
|
17
|
-
function
|
|
18
|
-
return { type: Function, default:
|
|
19
|
+
function functionType(defaultVal) {
|
|
20
|
+
return { type: Function, default: defaultVal };
|
|
19
21
|
}
|
|
20
|
-
function
|
|
21
|
-
const
|
|
22
|
-
return
|
|
22
|
+
function anyType(defaultVal, required) {
|
|
23
|
+
const type = { validator: () => true, default: defaultVal };
|
|
24
|
+
return required ? type : type;
|
|
23
25
|
}
|
|
24
|
-
function
|
|
25
|
-
return { validator: () =>
|
|
26
|
+
function vNodeType() {
|
|
27
|
+
return { validator: () => true };
|
|
26
28
|
}
|
|
27
|
-
function
|
|
28
|
-
return { type: Array, default:
|
|
29
|
+
function arrayType(defaultVal) {
|
|
30
|
+
return { type: Array, default: defaultVal };
|
|
29
31
|
}
|
|
30
|
-
function
|
|
31
|
-
return { type: String, default:
|
|
32
|
+
function stringType(defaultVal) {
|
|
33
|
+
return { type: String, default: defaultVal };
|
|
32
34
|
}
|
|
33
|
-
function
|
|
34
|
-
return
|
|
35
|
+
function someType(types, defaultVal) {
|
|
36
|
+
return types ? { type: types, default: defaultVal } : anyType(defaultVal);
|
|
35
37
|
}
|
|
36
38
|
export {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
anyType,
|
|
40
|
+
arrayType,
|
|
41
|
+
booleanType,
|
|
42
|
+
eventType,
|
|
43
|
+
functionType,
|
|
44
|
+
objectType,
|
|
45
|
+
someType,
|
|
46
|
+
stringType,
|
|
47
|
+
tuple,
|
|
48
|
+
tupleNum,
|
|
49
|
+
vNodeType,
|
|
50
|
+
withInstall
|
|
49
51
|
};
|
|
@@ -1 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
function checkSlotProp(props, slots, name, ...args) {
|
|
4
|
+
if (slots[name])
|
|
5
|
+
return slots[name]?.(...args);
|
|
6
|
+
if (name in props) {
|
|
7
|
+
if (typeof props[name] === "function")
|
|
8
|
+
return props[name]?.(...args);
|
|
9
|
+
return props[name];
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
exports.checkSlotProp = checkSlotProp;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
1
|
+
function checkSlotProp(props, slots, name, ...args) {
|
|
2
|
+
if (slots[name])
|
|
3
|
+
return slots[name]?.(...args);
|
|
4
|
+
if (name in props) {
|
|
5
|
+
if (typeof props[name] === "function")
|
|
6
|
+
return props[name]?.(...args);
|
|
7
|
+
return props[name];
|
|
8
|
+
}
|
|
9
|
+
return null;
|
|
3
10
|
}
|
|
4
11
|
export {
|
|
5
|
-
|
|
12
|
+
checkSlotProp
|
|
6
13
|
};
|
package/dist/utils/get.cjs
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
function get(entity, path) {
|
|
4
|
+
let current = entity;
|
|
5
|
+
for (let i = 0; i < path.length; i += 1) {
|
|
6
|
+
if (current === null || current === void 0)
|
|
7
|
+
return void 0;
|
|
8
|
+
current = current[path[i]];
|
|
9
|
+
}
|
|
10
|
+
return current;
|
|
11
|
+
}
|
|
12
|
+
exports.default = get;
|
package/dist/utils/get.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
function
|
|
2
|
-
let
|
|
3
|
-
for (let
|
|
4
|
-
if (
|
|
5
|
-
return;
|
|
6
|
-
|
|
1
|
+
function get(entity, path) {
|
|
2
|
+
let current = entity;
|
|
3
|
+
for (let i = 0; i < path.length; i += 1) {
|
|
4
|
+
if (current === null || current === void 0)
|
|
5
|
+
return void 0;
|
|
6
|
+
current = current[path[i]];
|
|
7
7
|
}
|
|
8
|
-
return
|
|
8
|
+
return current;
|
|
9
9
|
}
|
|
10
10
|
export {
|
|
11
|
-
|
|
11
|
+
get as default
|
|
12
12
|
};
|
package/dist/utils/omit.cjs
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
function omit(obj, keys) {
|
|
4
|
+
const result = { ...obj };
|
|
5
|
+
keys.forEach((key) => {
|
|
6
|
+
delete result[key];
|
|
7
|
+
});
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
exports.omit = omit;
|
package/dist/utils/omit.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
delete
|
|
5
|
-
})
|
|
1
|
+
function omit(obj, keys) {
|
|
2
|
+
const result = { ...obj };
|
|
3
|
+
keys.forEach((key) => {
|
|
4
|
+
delete result[key];
|
|
5
|
+
});
|
|
6
|
+
return result;
|
|
6
7
|
}
|
|
7
8
|
export {
|
|
8
|
-
|
|
9
|
+
omit
|
|
9
10
|
};
|
package/dist/utils/set.cjs
CHANGED
|
@@ -1 +1,64 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const get = require("./get.cjs");
|
|
4
|
+
function internalSet(entity, paths, value, removeIfUndefined) {
|
|
5
|
+
if (!paths.length)
|
|
6
|
+
return value;
|
|
7
|
+
const [path, ...restPath] = paths;
|
|
8
|
+
let clone;
|
|
9
|
+
if (!entity && typeof path === "number")
|
|
10
|
+
clone = [];
|
|
11
|
+
else if (Array.isArray(entity))
|
|
12
|
+
clone = [...entity];
|
|
13
|
+
else
|
|
14
|
+
clone = { ...entity };
|
|
15
|
+
if (removeIfUndefined && value === void 0 && restPath.length === 1)
|
|
16
|
+
delete clone[path][restPath[0]];
|
|
17
|
+
else
|
|
18
|
+
clone[path] = internalSet(clone[path], restPath, value, removeIfUndefined);
|
|
19
|
+
return clone;
|
|
20
|
+
}
|
|
21
|
+
function set(entity, paths, value, removeIfUndefined = false) {
|
|
22
|
+
if (paths.length && removeIfUndefined && value === void 0 && !get.default(entity, paths.slice(0, -1))) {
|
|
23
|
+
return entity;
|
|
24
|
+
}
|
|
25
|
+
return internalSet(entity, paths, value, removeIfUndefined);
|
|
26
|
+
}
|
|
27
|
+
function isObject(obj) {
|
|
28
|
+
return typeof obj === "object" && obj !== null && Object.getPrototypeOf(obj) === Object.prototype;
|
|
29
|
+
}
|
|
30
|
+
function createEmpty(source) {
|
|
31
|
+
return Array.isArray(source) ? [] : {};
|
|
32
|
+
}
|
|
33
|
+
const keys = typeof Reflect === "undefined" ? Object.keys : Reflect.ownKeys;
|
|
34
|
+
function merge(...sources) {
|
|
35
|
+
let clone = createEmpty(sources[0]);
|
|
36
|
+
sources.forEach((src) => {
|
|
37
|
+
function internalMerge(path, parentLoopSet) {
|
|
38
|
+
const loopSet = new Set(parentLoopSet);
|
|
39
|
+
const value = get.default(src, path);
|
|
40
|
+
const isArr = Array.isArray(value);
|
|
41
|
+
if (isArr || isObject(value)) {
|
|
42
|
+
if (!loopSet.has(value)) {
|
|
43
|
+
loopSet.add(value);
|
|
44
|
+
const originValue = get.default(clone, path);
|
|
45
|
+
if (isArr) {
|
|
46
|
+
clone = set(clone, path, []);
|
|
47
|
+
} else if (!originValue || typeof originValue !== "object") {
|
|
48
|
+
clone = set(clone, path, createEmpty(value));
|
|
49
|
+
}
|
|
50
|
+
keys(value).forEach((key) => {
|
|
51
|
+
internalMerge([...path, key], loopSet);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
clone = set(clone, path, value);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
internalMerge([]);
|
|
59
|
+
});
|
|
60
|
+
return clone;
|
|
61
|
+
}
|
|
62
|
+
exports.default = set;
|
|
63
|
+
exports.isObject = isObject;
|
|
64
|
+
exports.merge = merge;
|
package/dist/utils/set.js
CHANGED
|
@@ -1,42 +1,64 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
3
|
-
if (!
|
|
4
|
-
return
|
|
5
|
-
const [
|
|
6
|
-
let
|
|
7
|
-
|
|
1
|
+
import get from "./get.js";
|
|
2
|
+
function internalSet(entity, paths, value, removeIfUndefined) {
|
|
3
|
+
if (!paths.length)
|
|
4
|
+
return value;
|
|
5
|
+
const [path, ...restPath] = paths;
|
|
6
|
+
let clone;
|
|
7
|
+
if (!entity && typeof path === "number")
|
|
8
|
+
clone = [];
|
|
9
|
+
else if (Array.isArray(entity))
|
|
10
|
+
clone = [...entity];
|
|
11
|
+
else
|
|
12
|
+
clone = { ...entity };
|
|
13
|
+
if (removeIfUndefined && value === void 0 && restPath.length === 1)
|
|
14
|
+
delete clone[path][restPath[0]];
|
|
15
|
+
else
|
|
16
|
+
clone[path] = internalSet(clone[path], restPath, value, removeIfUndefined);
|
|
17
|
+
return clone;
|
|
8
18
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
19
|
+
function set(entity, paths, value, removeIfUndefined = false) {
|
|
20
|
+
if (paths.length && removeIfUndefined && value === void 0 && !get(entity, paths.slice(0, -1))) {
|
|
21
|
+
return entity;
|
|
22
|
+
}
|
|
23
|
+
return internalSet(entity, paths, value, removeIfUndefined);
|
|
11
24
|
}
|
|
12
|
-
function
|
|
13
|
-
return typeof
|
|
25
|
+
function isObject(obj) {
|
|
26
|
+
return typeof obj === "object" && obj !== null && Object.getPrototypeOf(obj) === Object.prototype;
|
|
14
27
|
}
|
|
15
|
-
function
|
|
16
|
-
return Array.isArray(
|
|
28
|
+
function createEmpty(source) {
|
|
29
|
+
return Array.isArray(source) ? [] : {};
|
|
17
30
|
}
|
|
18
|
-
const
|
|
19
|
-
function
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
const keys = typeof Reflect === "undefined" ? Object.keys : Reflect.ownKeys;
|
|
32
|
+
function merge(...sources) {
|
|
33
|
+
let clone = createEmpty(sources[0]);
|
|
34
|
+
sources.forEach((src) => {
|
|
35
|
+
function internalMerge(path, parentLoopSet) {
|
|
36
|
+
const loopSet = new Set(parentLoopSet);
|
|
37
|
+
const value = get(src, path);
|
|
38
|
+
const isArr = Array.isArray(value);
|
|
39
|
+
if (isArr || isObject(value)) {
|
|
40
|
+
if (!loopSet.has(value)) {
|
|
41
|
+
loopSet.add(value);
|
|
42
|
+
const originValue = get(clone, path);
|
|
43
|
+
if (isArr) {
|
|
44
|
+
clone = set(clone, path, []);
|
|
45
|
+
} else if (!originValue || typeof originValue !== "object") {
|
|
46
|
+
clone = set(clone, path, createEmpty(value));
|
|
47
|
+
}
|
|
48
|
+
keys(value).forEach((key) => {
|
|
49
|
+
internalMerge([...path, key], loopSet);
|
|
30
50
|
});
|
|
31
51
|
}
|
|
32
|
-
} else
|
|
33
|
-
|
|
52
|
+
} else {
|
|
53
|
+
clone = set(clone, path, value);
|
|
54
|
+
}
|
|
34
55
|
}
|
|
35
|
-
|
|
36
|
-
})
|
|
56
|
+
internalMerge([]);
|
|
57
|
+
});
|
|
58
|
+
return clone;
|
|
37
59
|
}
|
|
38
60
|
export {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
61
|
+
set as default,
|
|
62
|
+
isObject,
|
|
63
|
+
merge
|
|
42
64
|
};
|
|
@@ -1 +1,96 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
function getTransitionDirection(placement) {
|
|
5
|
+
if (placement !== void 0 && (placement === "topLeft" || placement === "topRight")) {
|
|
6
|
+
return `slide-down`;
|
|
7
|
+
}
|
|
8
|
+
return `slide-up`;
|
|
9
|
+
}
|
|
10
|
+
function getTransitionProps(transitionName, opt = {}) {
|
|
11
|
+
if (!transitionName) {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
const transitionProps = transitionName ? {
|
|
15
|
+
name: transitionName,
|
|
16
|
+
appear: true,
|
|
17
|
+
// type: 'animation',
|
|
18
|
+
// appearFromClass: `${transitionName}-appear ${transitionName}-appear-prepare`,
|
|
19
|
+
// appearActiveClass: `antdv-base-transtion`,
|
|
20
|
+
// appearToClass: `${transitionName}-appear ${transitionName}-appear-active`,
|
|
21
|
+
enterFromClass: `${transitionName}-enter ${transitionName}-appear ${transitionName}-appear-prepare ${transitionName}-enter-prepare ${transitionName}-enter-start`,
|
|
22
|
+
enterActiveClass: `${transitionName}-enter ${transitionName}-appear ${transitionName}-appear-prepare ${transitionName}-enter-prepare `,
|
|
23
|
+
enterToClass: `${transitionName}-enter ${transitionName}-appear ${transitionName}-appear-active ${transitionName}-enter-active`,
|
|
24
|
+
leaveFromClass: ` ${transitionName}-leave`,
|
|
25
|
+
leaveActiveClass: `${transitionName}-leave ${transitionName}-leave-active`,
|
|
26
|
+
leaveToClass: `${transitionName}-leave ${transitionName}-leave-active`,
|
|
27
|
+
...opt
|
|
28
|
+
} : { css: false, ...opt };
|
|
29
|
+
return transitionProps;
|
|
30
|
+
}
|
|
31
|
+
function getTransitionGroupProps(transitionName, opt = {}) {
|
|
32
|
+
const transitionProps = transitionName ? {
|
|
33
|
+
name: transitionName,
|
|
34
|
+
appear: true,
|
|
35
|
+
// appearFromClass: `${transitionName}-appear ${transitionName}-appear-prepare`,
|
|
36
|
+
appearActiveClass: `${transitionName}`,
|
|
37
|
+
appearToClass: `${transitionName}-appear ${transitionName}-appear-active`,
|
|
38
|
+
enterFromClass: `${transitionName}-appear ${transitionName}-enter ${transitionName}-appear-prepare ${transitionName}-enter-prepare`,
|
|
39
|
+
enterActiveClass: `${transitionName}`,
|
|
40
|
+
enterToClass: `${transitionName}-enter ${transitionName}-appear ${transitionName}-appear-active ${transitionName}-enter-active`,
|
|
41
|
+
leaveActiveClass: `${transitionName} ${transitionName}-leave`,
|
|
42
|
+
leaveToClass: `${transitionName}-leave-active`,
|
|
43
|
+
...opt
|
|
44
|
+
} : { css: false, ...opt };
|
|
45
|
+
return transitionProps;
|
|
46
|
+
}
|
|
47
|
+
const getCollapsedHeight = () => ({ height: 0, opacity: 0 });
|
|
48
|
+
const getRealHeight = (node) => ({
|
|
49
|
+
height: `${node.scrollHeight}px`,
|
|
50
|
+
opacity: 1
|
|
51
|
+
});
|
|
52
|
+
const getCurrentHeight = (node) => ({ height: `${node.offsetHeight}px` });
|
|
53
|
+
function collapseMotion(name = "ant-motion-collapse", style, className) {
|
|
54
|
+
return {
|
|
55
|
+
name,
|
|
56
|
+
appear: true,
|
|
57
|
+
css: true,
|
|
58
|
+
onBeforeEnter: (node) => {
|
|
59
|
+
className.value = name;
|
|
60
|
+
style.value = getCollapsedHeight();
|
|
61
|
+
},
|
|
62
|
+
onEnter: (node) => {
|
|
63
|
+
vue.nextTick(() => {
|
|
64
|
+
style.value = getRealHeight(node);
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
onAfterEnter: () => {
|
|
68
|
+
className.value = "";
|
|
69
|
+
style.value = {};
|
|
70
|
+
},
|
|
71
|
+
onBeforeLeave: (node) => {
|
|
72
|
+
className.value = name;
|
|
73
|
+
style.value = getCurrentHeight(node);
|
|
74
|
+
},
|
|
75
|
+
onLeave: (node) => {
|
|
76
|
+
setTimeout(() => {
|
|
77
|
+
style.value = getCollapsedHeight();
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
onAfterLeave: () => {
|
|
81
|
+
className.value = "";
|
|
82
|
+
style.value = {};
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function getTransitionName(rootPrefixCls, motion, transitionName) {
|
|
87
|
+
if (transitionName !== void 0) {
|
|
88
|
+
return transitionName;
|
|
89
|
+
}
|
|
90
|
+
return `${rootPrefixCls}-${motion}`;
|
|
91
|
+
}
|
|
92
|
+
exports.collapseMotion = collapseMotion;
|
|
93
|
+
exports.getTransitionDirection = getTransitionDirection;
|
|
94
|
+
exports.getTransitionGroupProps = getTransitionGroupProps;
|
|
95
|
+
exports.getTransitionName = getTransitionName;
|
|
96
|
+
exports.getTransitionProps = getTransitionProps;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CSSProperties, Ref, TransitionGroupProps, TransitionProps } from 'vue';
|
|
1
|
+
import { BaseTransitionProps, CSSProperties, Ref, TransitionGroupProps, TransitionProps } from 'vue';
|
|
2
2
|
declare const SelectPlacements: ["bottomLeft", "bottomRight", "topLeft", "topRight"];
|
|
3
3
|
export type SelectCommonPlacement = (typeof SelectPlacements)[number];
|
|
4
4
|
declare function getTransitionDirection(placement: SelectCommonPlacement | undefined): "slide-down" | "slide-up";
|
|
@@ -9,7 +9,7 @@ export declare type MotionEvent = (TransitionEvent | AnimationEvent) & {
|
|
|
9
9
|
};
|
|
10
10
|
export declare type MotionEventHandler = (element: Element, done?: () => void) => CSSProperties;
|
|
11
11
|
export declare type MotionEndEventHandler = (element: Element, done?: () => void) => boolean | void;
|
|
12
|
-
export interface CSSMotionProps extends Partial<
|
|
12
|
+
export interface CSSMotionProps extends Partial<BaseTransitionProps<Element>> {
|
|
13
13
|
name?: string;
|
|
14
14
|
css?: boolean;
|
|
15
15
|
}
|