@zzdadelu/schema-builder 1.0.0-alpha.13 → 1.0.0-alpha.130

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 (37) hide show
  1. package/dist/createIframe.d.ts +2 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +4208 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.min.js +2 -0
  6. package/dist/index.min.js.map +1 -0
  7. package/dist/main.d.ts +4 -0
  8. package/dist/settings/index.d.ts +21 -0
  9. package/dist/settings/meta/card.d.ts +2 -0
  10. package/dist/settings/meta/cardList.d.ts +2 -0
  11. package/dist/settings/meta/checkbox.d.ts +2 -0
  12. package/dist/settings/meta/checkboxes.d.ts +2 -0
  13. package/dist/settings/meta/color.d.ts +2 -0
  14. package/dist/settings/meta/date.d.ts +2 -0
  15. package/dist/settings/meta/dateRange.d.ts +2 -0
  16. package/dist/settings/meta/form.d.ts +2 -0
  17. package/dist/settings/meta/imageInput.d.ts +2 -0
  18. package/dist/settings/meta/input.d.ts +2 -0
  19. package/dist/settings/meta/number.d.ts +2 -0
  20. package/dist/settings/meta/radio.d.ts +2 -0
  21. package/dist/settings/meta/rate.d.ts +2 -0
  22. package/dist/settings/meta/select.d.ts +2 -0
  23. package/dist/settings/meta/slider.d.ts +2 -0
  24. package/dist/settings/meta/switch.d.ts +2 -0
  25. package/dist/settings/meta/textarea.d.ts +2 -0
  26. package/dist/settings/meta/time.d.ts +2 -0
  27. package/dist/settings/meta/timeRange.d.ts +2 -0
  28. package/dist/settings/meta/treeSelect.d.ts +2 -0
  29. package/dist/settings/meta/urlInput.d.ts +2 -0
  30. package/dist/settings/utils.d.ts +110 -0
  31. package/dist/type.d.ts +33 -0
  32. package/es/createIframe.js +1 -1
  33. package/es/main.js +21 -12
  34. package/lib/createIframe.js +1 -1
  35. package/lib/main.js +21 -12
  36. package/package.json +3 -1
  37. package/CHANGELOG.md +0 -1
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,110 @@
1
+ export declare const inputPropsBasic: ({
2
+ name: string;
3
+ title: {
4
+ label: string;
5
+ tip: string;
6
+ };
7
+ setter: string;
8
+ condition?: undefined;
9
+ } | {
10
+ name: string;
11
+ title: {
12
+ label: string;
13
+ tip: string;
14
+ };
15
+ setter: string;
16
+ condition: (target: any) => boolean;
17
+ })[];
18
+ export declare const notInputPropsBasic: ({
19
+ name: string;
20
+ title: {
21
+ label: string;
22
+ tip: string;
23
+ };
24
+ setter: string;
25
+ condition?: undefined;
26
+ } | {
27
+ name: string;
28
+ title: {
29
+ label: string;
30
+ tip: string;
31
+ };
32
+ setter: string;
33
+ condition: (target: any) => boolean;
34
+ })[];
35
+ export declare const optionsProp: {
36
+ display: string;
37
+ name: string;
38
+ title: {
39
+ label: string;
40
+ tip: string;
41
+ };
42
+ setter: {
43
+ componentName: string;
44
+ props: {
45
+ itemSetter: {
46
+ componentName: string;
47
+ initialValue: () => {
48
+ label: string;
49
+ value: string;
50
+ };
51
+ props: {
52
+ config: {
53
+ items: ({
54
+ name: string;
55
+ title: string;
56
+ important: boolean;
57
+ setter: string;
58
+ } | {
59
+ name: string;
60
+ title: string;
61
+ setter: string[];
62
+ important: boolean;
63
+ } | {
64
+ name: string;
65
+ title: string;
66
+ setter: string;
67
+ important?: undefined;
68
+ })[];
69
+ };
70
+ };
71
+ };
72
+ };
73
+ };
74
+ };
75
+ export declare const getInputPropsBasic: (defaultValueProp: any, placeholder?: any) => ({
76
+ name: string;
77
+ title: {
78
+ label: string;
79
+ tip: string;
80
+ };
81
+ setter: string;
82
+ condition?: undefined;
83
+ } | {
84
+ name: string;
85
+ title: {
86
+ label: string;
87
+ tip: string;
88
+ };
89
+ setter: string;
90
+ condition: (target: any) => boolean;
91
+ })[];
92
+ export declare const getNotInputPropsBasic: (defaultValueProp: any) => ({
93
+ name: string;
94
+ title: {
95
+ label: string;
96
+ tip: string;
97
+ };
98
+ setter: string;
99
+ condition?: undefined;
100
+ } | {
101
+ name: string;
102
+ title: {
103
+ label: string;
104
+ tip: string;
105
+ };
106
+ setter: string;
107
+ condition: (target: any) => boolean;
108
+ })[];
109
+ export declare const uuid: () => string;
110
+ export declare const createMeta: (componentName: string, params: any) => any;
package/dist/type.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ interface TProperties {
2
+ [key: string]: any;
3
+ }
4
+ interface TLogo {
5
+ title?: string;
6
+ image?: string;
7
+ href?: string;
8
+ }
9
+ interface TSchema {
10
+ "type": "object";
11
+ "properties": TProperties;
12
+ }
13
+ interface TToolBtn {
14
+ text: string;
15
+ order: number;
16
+ onClick: (schema: TSchema) => void;
17
+ }
18
+ export interface TSchemaBuilder {
19
+ logo?: TLogo;
20
+ importBtn?: boolean;
21
+ exportBtn?: boolean;
22
+ clearBtn?: boolean | TToolBtn;
23
+ saveBtn?: boolean | TToolBtn;
24
+ pubBtn?: boolean | TToolBtn;
25
+ extraBtns?: TToolBtn[];
26
+ defaultValue?: TSchema;
27
+ widgets?: any;
28
+ settings?: any;
29
+ editorWidgets?: any;
30
+ onMount?: () => void;
31
+ [key: string]: any;
32
+ }
33
+ export {};
@@ -1,5 +1,5 @@
1
1
  var createIframeContent = function createIframeContent() {
2
- var html = "\n <html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\" />\n <title>XRender</title>\n <link rel=\"icon\" href=\"https://img.alicdn.com/tfs/TB17UtINiLaK1RjSZFxXXamPFXa-606-643.png\">\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/variables.css\" rel=\"stylesheet\" />\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/dist/next.var.min.css\" rel=\"stylesheet\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/css/engine-core.css\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/css/engine-ext.css\" />\n <link rel=\"stylesheet\" href=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/css/index.css\" />\n\n <script>\n // \u5171\u4EAB\u7236\u7A97\u53E3\u7684 React/ReactDOM\uFF08\u4FDD\u6301\u539F\u884C\u4E3A\uFF09\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n\n // \u53EF\u63A7\u987A\u5E8F\u52A0\u8F7D\u811A\u672C\uFF08\u5728\u6DFB\u52A0\u4E4B\u524D\u68C0\u67E5\u5168\u5C40\u4EE5\u907F\u514D\u91CD\u590D\u52A0\u8F7D\uFF09\n function loadScriptsSequential(urls, cb) {\n var i = 0;\n function next() {\n if (i >= urls.length) { cb && cb(); return; }\n var url = urls[i++];\n // \u5982\u679C\u5E93\u5DF2\u5B58\u5728\u4E8E\u5168\u5C40\uFF0C\u5219\u8DF3\u8FC7\u52A0\u8F7D\uFF08\u907F\u514D\u91CD\u590D\u6CE8\u518C\uFF09\n try {\n if (url.indexOf('engine-core') !== -1 && window.AliLowCodeEngine) return next();\n if (url.indexOf('engine-ext') !== -1 && window.AliLowCodeEngineExt) return next();\n if (url.indexOf('fr-generator') !== -1 && window.__FR_GENERATOR_LOADED__) return next();\n } catch (e) {}\n var s = document.createElement('script');\n s.src = url;\n s.crossOrigin = 'anonymous';\n s.onload = next;\n s.onerror = function() { next(); };\n document.head.appendChild(s);\n }\n next();\n }\n\n // \u66F4\u7A33\u5065\u7684 getFormRenderMaterial \u4EE3\u7406\uFF1A\u4F7F\u7528 defineProperty \u62E6\u622A\u8D4B\u503C\u5E76\u7F13\u5B58\u8C03\u7528\u961F\u5217\n (function installGetFormRenderMaterialProxy() {\n if (window.__getFormRenderMaterial_installed) return;\n window.__getFormRenderMaterial_installed = true;\n window.__getFormRenderMaterial_queue = [];\n\n Object.defineProperty(window, 'getFormRenderMaterial', {\n configurable: true,\n enumerable: true,\n get: function() {\n if (window.__real_getFormRenderMaterial) return window.__real_getFormRenderMaterial;\n // \u8FD4\u56DE\u4E00\u4E2A\u4E34\u65F6\u51FD\u6570\uFF0C\u628A\u8C03\u7528\u53C2\u6570\u5165\u961F\n return function() {\n window.__getFormRenderMaterial_queue.push(Array.prototype.slice.call(arguments));\n };\n },\n set: function(val) {\n // \u53EA\u6709\u51FD\u6570\u624D\u89C6\u4E3A\u771F\u5B9E\u5B9E\u73B0\uFF1B\u5426\u5219\u5FFD\u7565\u8D4B\u503C\u5E76\u8BB0\u5F55\u8B66\u544A\n if (typeof val === 'function') {\n window.__real_getFormRenderMaterial = val;\n // \u628A\u961F\u5217\u91CC\u7684\u8C03\u7528\u91CD\u653E\u5230\u771F\u5B9E\u5B9E\u73B0\u4E0A\n var q = window.__getFormRenderMaterial_queue.splice(0);\n q.forEach(function(args) {\n try { window.__real_getFormRenderMaterial.apply(null, args); } catch (e) {}\n });\n // \u4E3A\u6027\u80FD\uFF0C\u628A window.getFormRenderMaterial \u76F4\u63A5\u5B9A\u4E49\u4E3A\u771F\u5B9E\u51FD\u6570\uFF08\u53EF\u88AB\u540E\u7EED\u8986\u76D6\uFF09\n try {\n Object.defineProperty(window, 'getFormRenderMaterial', {\n value: window.__real_getFormRenderMaterial,\n writable: true,\n configurable: true\n });\n } catch (e) {}\n } else {\n console.warn('Ignored non-function assignment to window.getFormRenderMaterial:', val);\n }\n }\n });\n\n // \u5982\u679C\u7236\u7A97\u53E3\uFF08\u540C\u6E90\uFF09\u5DF2\u6709\u5B9E\u73B0\uFF0C\u5219\u4EE3\u7406\u7ED9\u7236\u7A97\u53E3\n try {\n setTimeout(function tryProxyParent() {\n try {\n if (window.parent && window.parent !== window && typeof window.parent.getFormRenderMaterial === 'function') {\n window.getFormRenderMaterial = function() {\n return window.parent.getFormRenderMaterial.apply(window.parent, arguments);\n };\n }\n } catch (e) {}\n }, 0);\n } catch (e) {}\n })();\n </script>\n </head>\n <body>\n <div id=\"lce-container\"></div>\n\n <script>\n // \u987A\u5E8F\u52A0\u8F7D\uFF1A\u5728\u52A0\u8F7D\u5B8C\u6210\u540E\u518D\u52A0\u8F7D fr-generator\uFF1Bfr-generator \u52A0\u8F7D\u540E\u6807\u8BB0\u5E76 postMessage \u7ED9\u7236\u7A97\u53E3\n loadScriptsSequential([\n \"https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js\",\n \"https://g.alicdn.com/platform/c/react15-polyfill/0.0.1/dist/index.js\",\n \"https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js\",\n \"https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js\",\n \"https://g.alicdn.com/code/lib/alifd__next/1.23.24/next.min.js\",\n \"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/js/engine-core.js\",\n \"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/js/engine-ext.js\"\n ], function() {\n var s = document.createElement('script');\n s.type = 'text/javascript';\n s.src = 'https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js';\n s.onload = function() {\n try {\n window.__FR_GENERATOR_LOADED__ = true;\n parent.postMessage({ type: 'engine-load' }, '*');\n } catch (e) {}\n };\n s.onerror = function() {\n try { parent.postMessage({ type: 'engine-load' }, '*'); } catch(e) {}\n };\n document.body.appendChild(s);\n });\n </script>\n \n </body>\n </html>\n ";
2
+ var html = "\n <html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\" />\n <title>XRender</title>\n <link rel=\"icon\" href=\"https://img.alicdn.com/tfs/TB17UtINiLaK1RjSZFxXXamPFXa-606-643.png\">\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/variables.css\" rel=\"stylesheet\" />\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/dist/next.var.min.css\" rel=\"stylesheet\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/css/engine-core.css\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/css/engine-ext.css\" />\n <link rel=\"stylesheet\" href=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/css/index.css\" />\n\n <script>\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n </script>\n \n <script src=\"https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/react15-polyfill/0.0.1/dist/index.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js\"></script>\n <script src=\"https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js\"></script>\n <script src=\"https://g.alicdn.com/code/lib/alifd__next/1.23.24/next.min.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/js/engine-core.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/js/engine-ext.js\"></script>\n </head>\n\n <body>\n <div id=\"lce-container\"></div>\n <script type=\"text/javascript\" src=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js\"></script>\n </body>\n </html>\n ";
3
3
  return html;
4
4
  };
5
5
  export default (function () {
package/es/main.js CHANGED
@@ -10,23 +10,27 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
10
10
  import React, { useEffect, useRef, useImperativeHandle, forwardRef } from 'react';
11
11
  import createIframe from './createIframe';
12
12
  import * as defaultSetting from './settings';
13
- var iframe;
13
+ if (typeof window !== 'undefined') {
14
+ console.log('设置全局方法 getFormRenderMaterial', window);
15
+ window.getFormRenderMaterial = function () {
16
+ return defaultSetting;
17
+ };
18
+ }
14
19
  var Design = function Design(props, ref) {
15
20
  var widgets = props.widgets,
16
21
  settings = props.settings,
17
22
  restProps = _objectWithoutProperties(props, _excluded);
18
23
  var containerRef = useRef();
24
+ var iframeRef = useRef(null);
19
25
  useImperativeHandle(ref, function () {
20
26
  return {
21
27
  getValue: function getValue() {
22
- var _iframe, _iframe2, _iframe2$contentWindo, _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2, _iframe3$contentWindo3;
23
- console.log("contentWindow", (_iframe = iframe) === null || _iframe === void 0 ? void 0 : _iframe.contentWindow);
24
- console.log("__FR_ENGINE__", (_iframe2 = iframe) === null || _iframe2 === void 0 ? void 0 : (_iframe2$contentWindo = _iframe2.contentWindow) === null || _iframe2$contentWindo === void 0 ? void 0 : _iframe2$contentWindo.__FR_ENGINE__);
25
- return (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : (_iframe3$contentWindo = _iframe3.contentWindow) === null || _iframe3$contentWindo === void 0 ? void 0 : (_iframe3$contentWindo2 = _iframe3$contentWindo.__FR_ENGINE__) === null || _iframe3$contentWindo2 === void 0 ? void 0 : (_iframe3$contentWindo3 = _iframe3$contentWindo2.exportSchema) === null || _iframe3$contentWindo3 === void 0 ? void 0 : _iframe3$contentWindo3.call(_iframe3$contentWindo2);
28
+ var _iframeRef$current, _iframeRef$current$co, _iframeRef$current$co2, _iframeRef$current$co3;
29
+ return (_iframeRef$current = iframeRef.current) === null || _iframeRef$current === void 0 ? void 0 : (_iframeRef$current$co = _iframeRef$current.contentWindow) === null || _iframeRef$current$co === void 0 ? void 0 : (_iframeRef$current$co2 = _iframeRef$current$co.__FR_ENGINE__) === null || _iframeRef$current$co2 === void 0 ? void 0 : (_iframeRef$current$co3 = _iframeRef$current$co2.exportSchema) === null || _iframeRef$current$co3 === void 0 ? void 0 : _iframeRef$current$co3.call(_iframeRef$current$co2);
26
30
  },
27
31
  setValue: function setValue(schema) {
28
- var _iframe4, _iframe4$contentWindo, _iframe4$contentWindo2, _iframe4$contentWindo3;
29
- return (_iframe4 = iframe) === null || _iframe4 === void 0 ? void 0 : (_iframe4$contentWindo = _iframe4.contentWindow) === null || _iframe4$contentWindo === void 0 ? void 0 : (_iframe4$contentWindo2 = _iframe4$contentWindo.__FR_ENGINE__) === null || _iframe4$contentWindo2 === void 0 ? void 0 : (_iframe4$contentWindo3 = _iframe4$contentWindo2.importSchema) === null || _iframe4$contentWindo3 === void 0 ? void 0 : _iframe4$contentWindo3.call(_iframe4$contentWindo2, schema);
32
+ var _iframeRef$current2, _iframeRef$current2$c, _iframeRef$current2$c2, _iframeRef$current2$c3;
33
+ return (_iframeRef$current2 = iframeRef.current) === null || _iframeRef$current2 === void 0 ? void 0 : (_iframeRef$current2$c = _iframeRef$current2.contentWindow) === null || _iframeRef$current2$c === void 0 ? void 0 : (_iframeRef$current2$c2 = _iframeRef$current2$c.__FR_ENGINE__) === null || _iframeRef$current2$c2 === void 0 ? void 0 : (_iframeRef$current2$c3 = _iframeRef$current2$c2.importSchema) === null || _iframeRef$current2$c3 === void 0 ? void 0 : _iframeRef$current2$c3.call(_iframeRef$current2$c2, schema);
30
34
  }
31
35
  };
32
36
  });
@@ -38,17 +42,22 @@ var Design = function Design(props, ref) {
38
42
  };
39
43
  }, []);
40
44
  var initIframe = function initIframe() {
41
- console.log("开始创建 iframe");
42
- iframe = createIframe();
45
+ var iframe = createIframe();
46
+ iframeRef.current = iframe;
43
47
  containerRef.current.appendChild(iframe);
48
+ // 关键修复:将 material 加载函数注入到设计器 iframe 的 window 中
49
+ if (iframe.contentWindow) {
50
+ iframe.contentWindow.getFormRenderMaterial = function () {
51
+ return defaultSetting;
52
+ };
53
+ }
44
54
  };
45
55
  var engineOnLoad = function engineOnLoad(event) {
46
- var _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
56
+ var _iframeRef$current3, _iframeRef$current3$c, _iframeRef$current3$c2;
47
57
  if (event.data.type !== 'engine-load') {
48
58
  return;
49
59
  }
50
- console.log("拿到 iframe props:", event);
51
- (_iframe5 = iframe) === null || _iframe5 === void 0 ? void 0 : (_iframe5$contentWindo = _iframe5.contentWindow) === null || _iframe5$contentWindo === void 0 ? void 0 : (_iframe5$contentWindo2 = _iframe5$contentWindo.__FR_ENGINE__) === null || _iframe5$contentWindo2 === void 0 ? void 0 : _iframe5$contentWindo2.init(_objectSpread({
60
+ (_iframeRef$current3 = iframeRef.current) === null || _iframeRef$current3 === void 0 ? void 0 : (_iframeRef$current3$c = _iframeRef$current3.contentWindow) === null || _iframeRef$current3$c === void 0 ? void 0 : (_iframeRef$current3$c2 = _iframeRef$current3$c.__FR_ENGINE__) === null || _iframeRef$current3$c2 === void 0 ? void 0 : _iframeRef$current3$c2.init(_objectSpread({
52
61
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
53
62
  widgets: widgets,
54
63
  // recordEnable: true,
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var createIframeContent = function createIframeContent() {
8
- var html = "\n <html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\" />\n <title>XRender</title>\n <link rel=\"icon\" href=\"https://img.alicdn.com/tfs/TB17UtINiLaK1RjSZFxXXamPFXa-606-643.png\">\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/variables.css\" rel=\"stylesheet\" />\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/dist/next.var.min.css\" rel=\"stylesheet\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/css/engine-core.css\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/css/engine-ext.css\" />\n <link rel=\"stylesheet\" href=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/css/index.css\" />\n\n <script>\n // \u5171\u4EAB\u7236\u7A97\u53E3\u7684 React/ReactDOM\uFF08\u4FDD\u6301\u539F\u884C\u4E3A\uFF09\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n\n // \u53EF\u63A7\u987A\u5E8F\u52A0\u8F7D\u811A\u672C\uFF08\u5728\u6DFB\u52A0\u4E4B\u524D\u68C0\u67E5\u5168\u5C40\u4EE5\u907F\u514D\u91CD\u590D\u52A0\u8F7D\uFF09\n function loadScriptsSequential(urls, cb) {\n var i = 0;\n function next() {\n if (i >= urls.length) { cb && cb(); return; }\n var url = urls[i++];\n // \u5982\u679C\u5E93\u5DF2\u5B58\u5728\u4E8E\u5168\u5C40\uFF0C\u5219\u8DF3\u8FC7\u52A0\u8F7D\uFF08\u907F\u514D\u91CD\u590D\u6CE8\u518C\uFF09\n try {\n if (url.indexOf('engine-core') !== -1 && window.AliLowCodeEngine) return next();\n if (url.indexOf('engine-ext') !== -1 && window.AliLowCodeEngineExt) return next();\n if (url.indexOf('fr-generator') !== -1 && window.__FR_GENERATOR_LOADED__) return next();\n } catch (e) {}\n var s = document.createElement('script');\n s.src = url;\n s.crossOrigin = 'anonymous';\n s.onload = next;\n s.onerror = function() { next(); };\n document.head.appendChild(s);\n }\n next();\n }\n\n // \u66F4\u7A33\u5065\u7684 getFormRenderMaterial \u4EE3\u7406\uFF1A\u4F7F\u7528 defineProperty \u62E6\u622A\u8D4B\u503C\u5E76\u7F13\u5B58\u8C03\u7528\u961F\u5217\n (function installGetFormRenderMaterialProxy() {\n if (window.__getFormRenderMaterial_installed) return;\n window.__getFormRenderMaterial_installed = true;\n window.__getFormRenderMaterial_queue = [];\n\n Object.defineProperty(window, 'getFormRenderMaterial', {\n configurable: true,\n enumerable: true,\n get: function() {\n if (window.__real_getFormRenderMaterial) return window.__real_getFormRenderMaterial;\n // \u8FD4\u56DE\u4E00\u4E2A\u4E34\u65F6\u51FD\u6570\uFF0C\u628A\u8C03\u7528\u53C2\u6570\u5165\u961F\n return function() {\n window.__getFormRenderMaterial_queue.push(Array.prototype.slice.call(arguments));\n };\n },\n set: function(val) {\n // \u53EA\u6709\u51FD\u6570\u624D\u89C6\u4E3A\u771F\u5B9E\u5B9E\u73B0\uFF1B\u5426\u5219\u5FFD\u7565\u8D4B\u503C\u5E76\u8BB0\u5F55\u8B66\u544A\n if (typeof val === 'function') {\n window.__real_getFormRenderMaterial = val;\n // \u628A\u961F\u5217\u91CC\u7684\u8C03\u7528\u91CD\u653E\u5230\u771F\u5B9E\u5B9E\u73B0\u4E0A\n var q = window.__getFormRenderMaterial_queue.splice(0);\n q.forEach(function(args) {\n try { window.__real_getFormRenderMaterial.apply(null, args); } catch (e) {}\n });\n // \u4E3A\u6027\u80FD\uFF0C\u628A window.getFormRenderMaterial \u76F4\u63A5\u5B9A\u4E49\u4E3A\u771F\u5B9E\u51FD\u6570\uFF08\u53EF\u88AB\u540E\u7EED\u8986\u76D6\uFF09\n try {\n Object.defineProperty(window, 'getFormRenderMaterial', {\n value: window.__real_getFormRenderMaterial,\n writable: true,\n configurable: true\n });\n } catch (e) {}\n } else {\n console.warn('Ignored non-function assignment to window.getFormRenderMaterial:', val);\n }\n }\n });\n\n // \u5982\u679C\u7236\u7A97\u53E3\uFF08\u540C\u6E90\uFF09\u5DF2\u6709\u5B9E\u73B0\uFF0C\u5219\u4EE3\u7406\u7ED9\u7236\u7A97\u53E3\n try {\n setTimeout(function tryProxyParent() {\n try {\n if (window.parent && window.parent !== window && typeof window.parent.getFormRenderMaterial === 'function') {\n window.getFormRenderMaterial = function() {\n return window.parent.getFormRenderMaterial.apply(window.parent, arguments);\n };\n }\n } catch (e) {}\n }, 0);\n } catch (e) {}\n })();\n </script>\n </head>\n <body>\n <div id=\"lce-container\"></div>\n\n <script>\n // \u987A\u5E8F\u52A0\u8F7D\uFF1A\u5728\u52A0\u8F7D\u5B8C\u6210\u540E\u518D\u52A0\u8F7D fr-generator\uFF1Bfr-generator \u52A0\u8F7D\u540E\u6807\u8BB0\u5E76 postMessage \u7ED9\u7236\u7A97\u53E3\n loadScriptsSequential([\n \"https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js\",\n \"https://g.alicdn.com/platform/c/react15-polyfill/0.0.1/dist/index.js\",\n \"https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js\",\n \"https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js\",\n \"https://g.alicdn.com/code/lib/alifd__next/1.23.24/next.min.js\",\n \"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/js/engine-core.js\",\n \"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/js/engine-ext.js\"\n ], function() {\n var s = document.createElement('script');\n s.type = 'text/javascript';\n s.src = 'https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js';\n s.onload = function() {\n try {\n window.__FR_GENERATOR_LOADED__ = true;\n parent.postMessage({ type: 'engine-load' }, '*');\n } catch (e) {}\n };\n s.onerror = function() {\n try { parent.postMessage({ type: 'engine-load' }, '*'); } catch(e) {}\n };\n document.body.appendChild(s);\n });\n </script>\n \n </body>\n </html>\n ";
8
+ var html = "\n <html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\" />\n <title>XRender</title>\n <link rel=\"icon\" href=\"https://img.alicdn.com/tfs/TB17UtINiLaK1RjSZFxXXamPFXa-606-643.png\">\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/variables.css\" rel=\"stylesheet\" />\n <link href=\"https://alifd.alicdn.com/npm/@alifd/theme-lowcode-light@0.2.1/dist/next.var.min.css\" rel=\"stylesheet\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/css/engine-core.css\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/css/engine-ext.css\" />\n <link rel=\"stylesheet\" href=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/css/index.css\" />\n\n <script>\n window.React = window.parent.React;\n window.ReactDOM = window.parent.ReactDOM;\n </script>\n \n <script src=\"https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/react15-polyfill/0.0.1/dist/index.js\"></script>\n <script src=\"https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js\"></script>\n <script src=\"https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js\"></script>\n <script src=\"https://g.alicdn.com/code/lib/alifd__next/1.23.24/next.min.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.2.3/dist/js/engine-core.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/js/engine-ext.js\"></script>\n </head>\n\n <body>\n <div id=\"lce-container\"></div>\n <script type=\"text/javascript\" src=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.1.0/js/index.js\"></script>\n </body>\n </html>\n ";
9
9
  return html;
10
10
  };
11
11
  var _default = exports.default = function _default() {
package/lib/main.js CHANGED
@@ -18,23 +18,27 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
18
18
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
19
19
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
20
20
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
21
- var iframe;
21
+ if (typeof window !== 'undefined') {
22
+ console.log('设置全局方法 getFormRenderMaterial', window);
23
+ window.getFormRenderMaterial = function () {
24
+ return defaultSetting;
25
+ };
26
+ }
22
27
  var Design = function Design(props, ref) {
23
28
  var widgets = props.widgets,
24
29
  settings = props.settings,
25
30
  restProps = _objectWithoutProperties(props, _excluded);
26
31
  var containerRef = (0, _react.useRef)();
32
+ var iframeRef = (0, _react.useRef)(null);
27
33
  (0, _react.useImperativeHandle)(ref, function () {
28
34
  return {
29
35
  getValue: function getValue() {
30
- var _iframe, _iframe2, _iframe2$contentWindo, _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2, _iframe3$contentWindo3;
31
- console.log("contentWindow", (_iframe = iframe) === null || _iframe === void 0 ? void 0 : _iframe.contentWindow);
32
- console.log("__FR_ENGINE__", (_iframe2 = iframe) === null || _iframe2 === void 0 ? void 0 : (_iframe2$contentWindo = _iframe2.contentWindow) === null || _iframe2$contentWindo === void 0 ? void 0 : _iframe2$contentWindo.__FR_ENGINE__);
33
- return (_iframe3 = iframe) === null || _iframe3 === void 0 ? void 0 : (_iframe3$contentWindo = _iframe3.contentWindow) === null || _iframe3$contentWindo === void 0 ? void 0 : (_iframe3$contentWindo2 = _iframe3$contentWindo.__FR_ENGINE__) === null || _iframe3$contentWindo2 === void 0 ? void 0 : (_iframe3$contentWindo3 = _iframe3$contentWindo2.exportSchema) === null || _iframe3$contentWindo3 === void 0 ? void 0 : _iframe3$contentWindo3.call(_iframe3$contentWindo2);
36
+ var _iframeRef$current, _iframeRef$current$co, _iframeRef$current$co2, _iframeRef$current$co3;
37
+ return (_iframeRef$current = iframeRef.current) === null || _iframeRef$current === void 0 ? void 0 : (_iframeRef$current$co = _iframeRef$current.contentWindow) === null || _iframeRef$current$co === void 0 ? void 0 : (_iframeRef$current$co2 = _iframeRef$current$co.__FR_ENGINE__) === null || _iframeRef$current$co2 === void 0 ? void 0 : (_iframeRef$current$co3 = _iframeRef$current$co2.exportSchema) === null || _iframeRef$current$co3 === void 0 ? void 0 : _iframeRef$current$co3.call(_iframeRef$current$co2);
34
38
  },
35
39
  setValue: function setValue(schema) {
36
- var _iframe4, _iframe4$contentWindo, _iframe4$contentWindo2, _iframe4$contentWindo3;
37
- return (_iframe4 = iframe) === null || _iframe4 === void 0 ? void 0 : (_iframe4$contentWindo = _iframe4.contentWindow) === null || _iframe4$contentWindo === void 0 ? void 0 : (_iframe4$contentWindo2 = _iframe4$contentWindo.__FR_ENGINE__) === null || _iframe4$contentWindo2 === void 0 ? void 0 : (_iframe4$contentWindo3 = _iframe4$contentWindo2.importSchema) === null || _iframe4$contentWindo3 === void 0 ? void 0 : _iframe4$contentWindo3.call(_iframe4$contentWindo2, schema);
40
+ var _iframeRef$current2, _iframeRef$current2$c, _iframeRef$current2$c2, _iframeRef$current2$c3;
41
+ return (_iframeRef$current2 = iframeRef.current) === null || _iframeRef$current2 === void 0 ? void 0 : (_iframeRef$current2$c = _iframeRef$current2.contentWindow) === null || _iframeRef$current2$c === void 0 ? void 0 : (_iframeRef$current2$c2 = _iframeRef$current2$c.__FR_ENGINE__) === null || _iframeRef$current2$c2 === void 0 ? void 0 : (_iframeRef$current2$c3 = _iframeRef$current2$c2.importSchema) === null || _iframeRef$current2$c3 === void 0 ? void 0 : _iframeRef$current2$c3.call(_iframeRef$current2$c2, schema);
38
42
  }
39
43
  };
40
44
  });
@@ -46,17 +50,22 @@ var Design = function Design(props, ref) {
46
50
  };
47
51
  }, []);
48
52
  var initIframe = function initIframe() {
49
- console.log("开始创建 iframe");
50
- iframe = (0, _createIframe.default)();
53
+ var iframe = (0, _createIframe.default)();
54
+ iframeRef.current = iframe;
51
55
  containerRef.current.appendChild(iframe);
56
+ // 关键修复:将 material 加载函数注入到设计器 iframe 的 window 中
57
+ if (iframe.contentWindow) {
58
+ iframe.contentWindow.getFormRenderMaterial = function () {
59
+ return defaultSetting;
60
+ };
61
+ }
52
62
  };
53
63
  var engineOnLoad = function engineOnLoad(event) {
54
- var _iframe5, _iframe5$contentWindo, _iframe5$contentWindo2;
64
+ var _iframeRef$current3, _iframeRef$current3$c, _iframeRef$current3$c2;
55
65
  if (event.data.type !== 'engine-load') {
56
66
  return;
57
67
  }
58
- console.log("拿到 iframe props:", event);
59
- (_iframe5 = iframe) === null || _iframe5 === void 0 ? void 0 : (_iframe5$contentWindo = _iframe5.contentWindow) === null || _iframe5$contentWindo === void 0 ? void 0 : (_iframe5$contentWindo2 = _iframe5$contentWindo.__FR_ENGINE__) === null || _iframe5$contentWindo2 === void 0 ? void 0 : _iframe5$contentWindo2.init(_objectSpread({
68
+ (_iframeRef$current3 = iframeRef.current) === null || _iframeRef$current3 === void 0 ? void 0 : (_iframeRef$current3$c = _iframeRef$current3.contentWindow) === null || _iframeRef$current3$c === void 0 ? void 0 : (_iframeRef$current3$c2 = _iframeRef$current3$c.__FR_ENGINE__) === null || _iframeRef$current3$c2 === void 0 ? void 0 : _iframeRef$current3$c2.init(_objectSpread({
60
69
  settings: _objectSpread(_objectSpread({}, defaultSetting), settings),
61
70
  widgets: widgets,
62
71
  // recordEnable: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzdadelu/schema-builder",
3
- "version": "1.0.0-alpha.13",
3
+ "version": "1.0.0-alpha.130",
4
4
  "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
5
5
  "keywords": [
6
6
  "Form",
@@ -22,9 +22,11 @@
22
22
  "license": "MIT",
23
23
  "main": "lib/index.js",
24
24
  "module": "es/index.js",
25
+ "unpkg": "dist/index.min.js",
25
26
  "files": [
26
27
  "es",
27
28
  "lib",
29
+ "dist",
28
30
  "package.json"
29
31
  ],
30
32
  "scripts": {
package/CHANGELOG.md DELETED
@@ -1 +0,0 @@
1
- # Change Log