@xrenders/schema-builder 1.0.0-alpha.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019-present XRender Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ ## 如何使用
2
+
3
+ ### 安装
4
+
5
+ ```bash
6
+ npm i @xrender/schema-builder
7
+ ```
8
+
9
+ ### 代码演示
10
+
11
+ ```jsx
12
+ /**
13
+ * transform: true
14
+ * defaultShowCode: true
15
+ */
16
+ import React from 'react';
17
+ import S from '@xrender/schema-builder';
18
+
19
+ const defaultValue = {
20
+ type: 'object',
21
+ properties: {
22
+ inputName: {
23
+ title: '简单输入框',
24
+ type: 'string',
25
+ },
26
+ },
27
+ };
28
+
29
+ const Demo = () => {
30
+ return (
31
+ <div style={{ height: '80vh' }}>
32
+ <Generator defaultValue={defaultValue} />
33
+ </div>
34
+ );
35
+ };
36
+
37
+ export default Demo;
38
+ ```
39
+
40
+ ## API
41
+
@@ -0,0 +1,2 @@
1
+ declare const _default: () => HTMLIFrameElement;
2
+ export default _default;
@@ -0,0 +1,12 @@
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.1.5/dist/css/engine-core.css\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.5/dist/css/engine-ext.css\" />\n <link rel=\"stylesheet\" href=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.0.3/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.1.5/dist/js/engine-core.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.5/dist/js/engine-ext.js\"></script>\n\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.0.3/js/index.js\"></script>\n </body>\n </html>\n ";
3
+ return html;
4
+ };
5
+ export default (function () {
6
+ var iframe = document.createElement('iframe');
7
+ iframe.width = '100%';
8
+ iframe.height = '100%';
9
+ iframe.frameBorder = '0';
10
+ iframe.srcdoc = createIframeContent();
11
+ return iframe;
12
+ });
package/es/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import Main from './main';
2
+ export default Main;
package/es/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import Main from './main';
2
+ export default Main;
package/es/main.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ interface IProps {
2
+ widgets: any;
3
+ settings: any;
4
+ }
5
+ declare const Design: (props: IProps) => JSX.Element;
6
+ export default Design;
package/es/main.js ADDED
@@ -0,0 +1,41 @@
1
+ import React, { useEffect, useRef } from 'react';
2
+ import createIframe from './createIframe';
3
+ var iframe;
4
+ var Design = function Design(props) {
5
+ var widgets = props.widgets,
6
+ settings = props.settings;
7
+ var containerRef = useRef();
8
+ useEffect(function () {
9
+ initIframe();
10
+ window.addEventListener('message', engineOnLoad);
11
+ return function () {
12
+ window.removeEventListener('message', engineOnLoad);
13
+ };
14
+ }, []);
15
+ var initIframe = function initIframe() {
16
+ iframe = createIframe();
17
+ containerRef.current.appendChild(iframe);
18
+ };
19
+ var engineOnLoad = function engineOnLoad(event) {
20
+ var _iframe, _iframe$contentWindow, _iframe$contentWindow2;
21
+ if (event.data.type !== 'engine-load') {
22
+ return;
23
+ }
24
+ (_iframe = iframe) === null || _iframe === void 0 ? void 0 : (_iframe$contentWindow = _iframe.contentWindow) === null || _iframe$contentWindow === void 0 ? void 0 : (_iframe$contentWindow2 = _iframe$contentWindow.__FR_ENGINE__) === null || _iframe$contentWindow2 === void 0 ? void 0 : _iframe$contentWindow2.init({
25
+ settings: settings,
26
+ widgets: widgets,
27
+ // recordEnable: true,
28
+ logo: {
29
+ title: 'XRender'
30
+ }
31
+ });
32
+ };
33
+ return /*#__PURE__*/React.createElement("div", {
34
+ ref: containerRef,
35
+ style: {
36
+ width: '100%',
37
+ height: '100%'
38
+ }
39
+ });
40
+ };
41
+ export default Design;
@@ -0,0 +1,3 @@
1
+ declare const _default: () => import("react").FC<import("@ant-design/icons/lib/components/IconFont").IconFontProps<string>>;
2
+ export default _default;
3
+ export declare function uuid(): string;
@@ -0,0 +1,9 @@
1
+ import _createFromIconfontCN from "@ant-design/icons/lib/icons/createFromIconfontCN";
2
+ export default (function () {
3
+ return _createFromIconfontCN({
4
+ scriptUrl: '//at.alicdn.com/t/a/font_2705259_bm3cr8z1o4q.js'
5
+ });
6
+ });
7
+ export function uuid() {
8
+ return (Math.random() * 1e6 >> 0).toString(36);
9
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: () => HTMLIFrameElement;
2
+ export default _default;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
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.1.5/dist/css/engine-core.css\" />\n <link rel=\"stylesheet\" href=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.5/dist/css/engine-ext.css\" />\n <link rel=\"stylesheet\" href=\"https://g.alicdn.com/fone-lowcode/fr-generator/1.0.3/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.1.5/dist/js/engine-core.js\"></script>\n <script crossorigin=\"anonymous\" src=\"https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.5/dist/js/engine-ext.js\"></script>\n\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.0.3/js/index.js\"></script>\n </body>\n </html>\n ";
9
+ return html;
10
+ };
11
+ var _default = function _default() {
12
+ var iframe = document.createElement('iframe');
13
+ iframe.width = '100%';
14
+ iframe.height = '100%';
15
+ iframe.frameBorder = '0';
16
+ iframe.srcdoc = createIframeContent();
17
+ return iframe;
18
+ };
19
+ exports.default = _default;
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import Main from './main';
2
+ export default Main;
package/lib/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _main = _interopRequireDefault(require("./main"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ var _default = _main.default;
10
+ exports.default = _default;
package/lib/main.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ interface IProps {
2
+ widgets: any;
3
+ settings: any;
4
+ }
5
+ declare const Design: (props: IProps) => JSX.Element;
6
+ export default Design;
package/lib/main.js ADDED
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _createIframe = _interopRequireDefault(require("./createIframe"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+ var iframe;
14
+ var Design = function Design(props) {
15
+ var widgets = props.widgets,
16
+ settings = props.settings;
17
+ var containerRef = (0, _react.useRef)();
18
+ (0, _react.useEffect)(function () {
19
+ initIframe();
20
+ window.addEventListener('message', engineOnLoad);
21
+ return function () {
22
+ window.removeEventListener('message', engineOnLoad);
23
+ };
24
+ }, []);
25
+ var initIframe = function initIframe() {
26
+ iframe = (0, _createIframe.default)();
27
+ containerRef.current.appendChild(iframe);
28
+ };
29
+ var engineOnLoad = function engineOnLoad(event) {
30
+ var _iframe, _iframe$contentWindow, _iframe$contentWindow2;
31
+ if (event.data.type !== 'engine-load') {
32
+ return;
33
+ }
34
+ (_iframe = iframe) === null || _iframe === void 0 ? void 0 : (_iframe$contentWindow = _iframe.contentWindow) === null || _iframe$contentWindow === void 0 ? void 0 : (_iframe$contentWindow2 = _iframe$contentWindow.__FR_ENGINE__) === null || _iframe$contentWindow2 === void 0 ? void 0 : _iframe$contentWindow2.init({
35
+ settings: settings,
36
+ widgets: widgets,
37
+ // recordEnable: true,
38
+ logo: {
39
+ title: 'XRender'
40
+ }
41
+ });
42
+ };
43
+ return /*#__PURE__*/_react.default.createElement("div", {
44
+ ref: containerRef,
45
+ style: {
46
+ width: '100%',
47
+ height: '100%'
48
+ }
49
+ });
50
+ };
51
+ var _default = Design;
52
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ declare const _default: () => import("react").FC<import("@ant-design/icons/lib/components/IconFont").IconFontProps<string>>;
2
+ export default _default;
3
+ export declare function uuid(): string;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ exports.uuid = uuid;
8
+ var _createFromIconfontCN2 = _interopRequireDefault(require("@ant-design/icons/lib/icons/createFromIconfontCN"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ var _default = function _default() {
11
+ return (0, _createFromIconfontCN2.default)({
12
+ scriptUrl: '//at.alicdn.com/t/a/font_2705259_bm3cr8z1o4q.js'
13
+ });
14
+ };
15
+ exports.default = _default;
16
+ function uuid() {
17
+ return (Math.random() * 1e6 >> 0).toString(36);
18
+ }
package/package.json ADDED
@@ -0,0 +1,93 @@
1
+ {
2
+ "name": "@xrenders/schema-builder",
3
+ "version": "1.0.0-alpha.1",
4
+ "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
5
+ "keywords": [
6
+ "Form",
7
+ "FormRender",
8
+ "Render",
9
+ "XRender",
10
+ "React",
11
+ "Json Schema",
12
+ "Ant Design"
13
+ ],
14
+ "homepage": "https://xrender.fun/form-render",
15
+ "bugs": {
16
+ "url": "https://github.com/alibaba/x-render/issues"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git@github.com:alibaba/x-render.git"
21
+ },
22
+ "license": "MIT",
23
+ "main": "lib/index.js",
24
+ "module": "es/index.js",
25
+ "files": [
26
+ "es",
27
+ "lib",
28
+ "package.json"
29
+ ],
30
+ "scripts": {
31
+ "beta": "npm publish --tag beta",
32
+ "alpha": "npm publish --tag alpha --access public",
33
+ "build": "father-build",
34
+ "prepare": "yarn build",
35
+ "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"",
36
+ "postpublish": "git push --tags",
37
+ "test": "umi-test",
38
+ "test:coverage": "umi-test --coverage"
39
+ },
40
+ "lint-staged": {
41
+ "*.{js,jsx,less,md,json}": [
42
+ "prettier --write"
43
+ ],
44
+ "*.ts?(x)": [
45
+ "prettier --parser=typescript --write"
46
+ ]
47
+ },
48
+ "dependencies": {
49
+ "clone": "^2.1.2",
50
+ "i18next": "^21.8.11",
51
+ "nanoid": "^3.1.22",
52
+ "randombytes": "2.1.0",
53
+ "rc-color-picker": "^1.2.6",
54
+ "react-dnd": "^14.0.2",
55
+ "react-dnd-html5-backend": "^14.0.0",
56
+ "react-i18next": "^11.17.2",
57
+ "react-sortable-hoc": "^2.0.0"
58
+ },
59
+ "devDependencies": {
60
+ "father-build": "^1.17.2",
61
+ "less": "^3.0.0",
62
+ "@rollup/plugin-babel": "^6.0.3",
63
+ "rollup-plugin-commonjs": "^10.1.0",
64
+ "rollup-plugin-copy": "^3.4.0",
65
+ "@alib/build-scripts": "^0.1.18",
66
+ "@alilc/lowcode-engine": "^1.0.0",
67
+ "@alilc/lowcode-engine-ext": "^1.0.0",
68
+ "@alilc/lowcode-types": "^1.0.0",
69
+ "@types/events": "^3.0.0",
70
+ "@types/react": "^16.8.3",
71
+ "@types/react-dom": "^16.8.2",
72
+ "@types/streamsaver": "^2.0.0",
73
+ "@types/uuid": "^8.3.4",
74
+ "build-plugin-fusion": "^0.1.0",
75
+ "build-plugin-moment-locales": "^0.1.0",
76
+ "build-plugin-react-app": "^1.1.2",
77
+ "fs-extra": "^10.0.1",
78
+ "tsconfig-paths-webpack-plugin": "^3.2.0"
79
+ },
80
+ "peerDependencies": {
81
+ "antd": "4.x",
82
+ "react": ">=16.14.0",
83
+ "react-dom": ">=16.14.0"
84
+ },
85
+ "gitHooks": {
86
+ "pre-commit": "lint-staged"
87
+ },
88
+ "types": "./lib/index.d.ts",
89
+ "directories": {
90
+ "lib": "lib"
91
+ },
92
+ "author": "lhbxs"
93
+ }