@hzab/utils 1.0.5 → 1.0.6
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/changelog.md +4 -0
- package/package.json +1 -1
- package/src/formily/global-components.ts +48 -0
package/changelog.md
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* formily 全局组件
|
|
3
|
+
* 项目初始化时进行 formily 组件的挂载,解决 form render 组件日益庞大的问题。
|
|
4
|
+
*/
|
|
5
|
+
window.formilyGlobalComponents = {};
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 获取全局 formily 组件对象
|
|
9
|
+
* @returns {Object} formilyGlobalComponents
|
|
10
|
+
*/
|
|
11
|
+
export const getFormilyGlobalComponents = function () {
|
|
12
|
+
return window.formilyGlobalComponents || {};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 批量设置全局 formily 组件
|
|
17
|
+
* @param {Object} components
|
|
18
|
+
* @returns {Object} formilyGlobalComponents
|
|
19
|
+
*/
|
|
20
|
+
export const setFormilyGlobalComponents = function (components) {
|
|
21
|
+
Object.assign(window.formilyGlobalComponents, components);
|
|
22
|
+
return window.formilyGlobalComponents;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 单个设置全局 formily 组件
|
|
27
|
+
* @returns {Object} formilyGlobalComponents
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* 单个设置全局 formily 组件
|
|
31
|
+
* @param {string} key
|
|
32
|
+
* @param {ReactComponent} component
|
|
33
|
+
* @returns {Object} formilyGlobalComponents
|
|
34
|
+
*/
|
|
35
|
+
export const setFormilyGlobalComponent = function (key, component) {
|
|
36
|
+
window.formilyGlobalComponents[key] = component;
|
|
37
|
+
return window.formilyGlobalComponents;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 单个删除全局 formily 组件
|
|
42
|
+
* @param {string} key
|
|
43
|
+
* @returns {Object} formilyGlobalComponents
|
|
44
|
+
*/
|
|
45
|
+
export const rmFormilyGlobalComponents = function (key) {
|
|
46
|
+
delete window.formilyGlobalComponents[key];
|
|
47
|
+
return window.formilyGlobalComponents;
|
|
48
|
+
};
|