@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 CHANGED
@@ -1,3 +1,7 @@
1
+ # @hzab/utils@1.0.6
2
+
3
+ feat: formily global components
4
+
1
5
  # @hzab/utils@1.0.5
2
6
 
3
7
  fix: upload 文件名简化
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/utils",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "utils",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -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
+ };