@xrenders/schema-builder 1.0.0-alpha.1 → 1.0.0-alpha.11
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/README.md +3 -5
- package/es/createIframe.js +1 -1
- package/es/main.d.ts +4 -6
- package/es/main.js +29 -7
- package/es/type.d.ts +32 -0
- package/es/type.js +1 -0
- package/lib/createIframe.js +3 -4
- package/lib/index.js +1 -2
- package/lib/main.d.ts +4 -6
- package/lib/main.js +28 -8
- package/lib/type.d.ts +32 -0
- package/lib/type.js +5 -0
- package/package.json +5 -5
- package/es/utils/createIconFont.d.ts +0 -3
- package/es/utils/createIconFont.js +0 -9
- package/lib/utils/createIconFont.d.ts +0 -3
- package/lib/utils/createIconFont.js +0 -18
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
### 安装
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
npm i @
|
|
6
|
+
npm i @xrenders/schema-builder
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
### 代码演示
|
|
@@ -14,7 +14,7 @@ npm i @xrender/schema-builder
|
|
|
14
14
|
* defaultShowCode: true
|
|
15
15
|
*/
|
|
16
16
|
import React from 'react';
|
|
17
|
-
import
|
|
17
|
+
import SchemaBuilder from '@xrenders/schema-builder';
|
|
18
18
|
|
|
19
19
|
const defaultValue = {
|
|
20
20
|
type: 'object',
|
|
@@ -29,7 +29,7 @@ const defaultValue = {
|
|
|
29
29
|
const Demo = () => {
|
|
30
30
|
return (
|
|
31
31
|
<div style={{ height: '80vh' }}>
|
|
32
|
-
<
|
|
32
|
+
<SchemaBuilder defaultValue={defaultValue} />
|
|
33
33
|
</div>
|
|
34
34
|
);
|
|
35
35
|
};
|
|
@@ -37,5 +37,3 @@ const Demo = () => {
|
|
|
37
37
|
export default Demo;
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
## API
|
|
41
|
-
|
package/es/createIframe.js
CHANGED
|
@@ -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.1.
|
|
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.11-beta.8/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.0.10/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.11-beta.8/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\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.11/js/index.js\"></script>\n </body>\n </html>\n ";
|
|
3
3
|
return html;
|
|
4
4
|
};
|
|
5
5
|
export default (function () {
|
package/es/main.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare const Design: (props: IProps) => JSX.Element;
|
|
6
|
-
export default Design;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TSchemaBuilder } from './type';
|
|
3
|
+
declare const _default: React.ForwardRefExoticComponent<Pick<TSchemaBuilder, keyof TSchemaBuilder> & React.RefAttributes<unknown>>;
|
|
4
|
+
export default _default;
|
package/es/main.js
CHANGED
|
@@ -1,10 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["widgets", "settings"];
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
8
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
10
|
+
import React, { useEffect, useRef, useImperativeHandle, forwardRef } from 'react';
|
|
2
11
|
import createIframe from './createIframe';
|
|
3
12
|
var iframe;
|
|
4
|
-
var Design = function Design(props) {
|
|
13
|
+
var Design = function Design(props, ref) {
|
|
5
14
|
var widgets = props.widgets,
|
|
6
|
-
settings = props.settings
|
|
15
|
+
settings = props.settings,
|
|
16
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
7
17
|
var containerRef = useRef();
|
|
18
|
+
useImperativeHandle(ref, function () {
|
|
19
|
+
return {
|
|
20
|
+
getValue: function getValue() {
|
|
21
|
+
var _iframe, _iframe$contentWindow, _iframe$contentWindow2, _iframe$contentWindow3;
|
|
22
|
+
return (_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$contentWindow3 = _iframe$contentWindow2.exportSchema) === null || _iframe$contentWindow3 === void 0 ? void 0 : _iframe$contentWindow3.call(_iframe$contentWindow2);
|
|
23
|
+
},
|
|
24
|
+
setValue: function setValue(schema) {
|
|
25
|
+
var _iframe2, _iframe2$contentWindo, _iframe2$contentWindo2, _iframe2$contentWindo3;
|
|
26
|
+
return (_iframe2 = iframe) === null || _iframe2 === void 0 ? void 0 : (_iframe2$contentWindo = _iframe2.contentWindow) === null || _iframe2$contentWindo === void 0 ? void 0 : (_iframe2$contentWindo2 = _iframe2$contentWindo.__FR_ENGINE__) === null || _iframe2$contentWindo2 === void 0 ? void 0 : (_iframe2$contentWindo3 = _iframe2$contentWindo2.importSchema) === null || _iframe2$contentWindo3 === void 0 ? void 0 : _iframe2$contentWindo3.call(_iframe2$contentWindo2, schema);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
});
|
|
8
30
|
useEffect(function () {
|
|
9
31
|
initIframe();
|
|
10
32
|
window.addEventListener('message', engineOnLoad);
|
|
@@ -17,18 +39,18 @@ var Design = function Design(props) {
|
|
|
17
39
|
containerRef.current.appendChild(iframe);
|
|
18
40
|
};
|
|
19
41
|
var engineOnLoad = function engineOnLoad(event) {
|
|
20
|
-
var
|
|
42
|
+
var _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2;
|
|
21
43
|
if (event.data.type !== 'engine-load') {
|
|
22
44
|
return;
|
|
23
45
|
}
|
|
24
|
-
(
|
|
46
|
+
(_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$contentWindo2.init(_objectSpread({
|
|
25
47
|
settings: settings,
|
|
26
48
|
widgets: widgets,
|
|
27
49
|
// recordEnable: true,
|
|
28
50
|
logo: {
|
|
29
51
|
title: 'XRender'
|
|
30
52
|
}
|
|
31
|
-
});
|
|
53
|
+
}, restProps));
|
|
32
54
|
};
|
|
33
55
|
return /*#__PURE__*/React.createElement("div", {
|
|
34
56
|
ref: containerRef,
|
|
@@ -38,4 +60,4 @@ var Design = function Design(props) {
|
|
|
38
60
|
}
|
|
39
61
|
});
|
|
40
62
|
};
|
|
41
|
-
export default Design;
|
|
63
|
+
export default /*#__PURE__*/forwardRef(Design);
|
package/es/type.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
onMount?: () => void;
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
package/es/type.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/createIframe.js
CHANGED
|
@@ -5,15 +5,14 @@ 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.1.
|
|
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.11-beta.8/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.0.10/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.11-beta.8/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\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.11/js/index.js\"></script>\n </body>\n </html>\n ";
|
|
9
9
|
return html;
|
|
10
10
|
};
|
|
11
|
-
var _default = function _default() {
|
|
11
|
+
var _default = exports.default = function _default() {
|
|
12
12
|
var iframe = document.createElement('iframe');
|
|
13
13
|
iframe.width = '100%';
|
|
14
14
|
iframe.height = '100%';
|
|
15
15
|
iframe.frameBorder = '0';
|
|
16
16
|
iframe.srcdoc = createIframeContent();
|
|
17
17
|
return iframe;
|
|
18
|
-
};
|
|
19
|
-
exports.default = _default;
|
|
18
|
+
};
|
package/lib/index.js
CHANGED
|
@@ -6,5 +6,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _main = _interopRequireDefault(require("./main"));
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
var _default = _main.default;
|
|
10
|
-
exports.default = _default;
|
|
9
|
+
var _default = exports.default = _main.default;
|
package/lib/main.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare const Design: (props: IProps) => JSX.Element;
|
|
6
|
-
export default Design;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TSchemaBuilder } from './type';
|
|
3
|
+
declare const _default: React.ForwardRefExoticComponent<Pick<TSchemaBuilder, keyof TSchemaBuilder> & React.RefAttributes<unknown>>;
|
|
4
|
+
export default _default;
|
package/lib/main.js
CHANGED
|
@@ -1,20 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _createIframe = _interopRequireDefault(require("./createIframe"));
|
|
10
|
+
var _excluded = ["widgets", "settings"];
|
|
10
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
12
|
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
13
|
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; }
|
|
14
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
18
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
19
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
20
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
13
21
|
var iframe;
|
|
14
|
-
var Design = function Design(props) {
|
|
22
|
+
var Design = function Design(props, ref) {
|
|
15
23
|
var widgets = props.widgets,
|
|
16
|
-
settings = props.settings
|
|
24
|
+
settings = props.settings,
|
|
25
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
17
26
|
var containerRef = (0, _react.useRef)();
|
|
27
|
+
(0, _react.useImperativeHandle)(ref, function () {
|
|
28
|
+
return {
|
|
29
|
+
getValue: function getValue() {
|
|
30
|
+
var _iframe, _iframe$contentWindow, _iframe$contentWindow2, _iframe$contentWindow3;
|
|
31
|
+
return (_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$contentWindow3 = _iframe$contentWindow2.exportSchema) === null || _iframe$contentWindow3 === void 0 ? void 0 : _iframe$contentWindow3.call(_iframe$contentWindow2);
|
|
32
|
+
},
|
|
33
|
+
setValue: function setValue(schema) {
|
|
34
|
+
var _iframe2, _iframe2$contentWindo, _iframe2$contentWindo2, _iframe2$contentWindo3;
|
|
35
|
+
return (_iframe2 = iframe) === null || _iframe2 === void 0 ? void 0 : (_iframe2$contentWindo = _iframe2.contentWindow) === null || _iframe2$contentWindo === void 0 ? void 0 : (_iframe2$contentWindo2 = _iframe2$contentWindo.__FR_ENGINE__) === null || _iframe2$contentWindo2 === void 0 ? void 0 : (_iframe2$contentWindo3 = _iframe2$contentWindo2.importSchema) === null || _iframe2$contentWindo3 === void 0 ? void 0 : _iframe2$contentWindo3.call(_iframe2$contentWindo2, schema);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
});
|
|
18
39
|
(0, _react.useEffect)(function () {
|
|
19
40
|
initIframe();
|
|
20
41
|
window.addEventListener('message', engineOnLoad);
|
|
@@ -27,18 +48,18 @@ var Design = function Design(props) {
|
|
|
27
48
|
containerRef.current.appendChild(iframe);
|
|
28
49
|
};
|
|
29
50
|
var engineOnLoad = function engineOnLoad(event) {
|
|
30
|
-
var
|
|
51
|
+
var _iframe3, _iframe3$contentWindo, _iframe3$contentWindo2;
|
|
31
52
|
if (event.data.type !== 'engine-load') {
|
|
32
53
|
return;
|
|
33
54
|
}
|
|
34
|
-
(
|
|
55
|
+
(_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$contentWindo2.init(_objectSpread({
|
|
35
56
|
settings: settings,
|
|
36
57
|
widgets: widgets,
|
|
37
58
|
// recordEnable: true,
|
|
38
59
|
logo: {
|
|
39
60
|
title: 'XRender'
|
|
40
61
|
}
|
|
41
|
-
});
|
|
62
|
+
}, restProps));
|
|
42
63
|
};
|
|
43
64
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
44
65
|
ref: containerRef,
|
|
@@ -48,5 +69,4 @@ var Design = function Design(props) {
|
|
|
48
69
|
}
|
|
49
70
|
});
|
|
50
71
|
};
|
|
51
|
-
var _default = Design;
|
|
52
|
-
exports.default = _default;
|
|
72
|
+
var _default = exports.default = /*#__PURE__*/(0, _react.forwardRef)(Design);
|
package/lib/type.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
onMount?: () => void;
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
package/lib/type.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xrenders/schema-builder",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.11",
|
|
4
4
|
"description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Form",
|
|
@@ -86,8 +86,8 @@
|
|
|
86
86
|
"pre-commit": "lint-staged"
|
|
87
87
|
},
|
|
88
88
|
"types": "./lib/index.d.ts",
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
"publishConfig": {
|
|
90
|
+
"registry": "https://registry.npmjs.org/",
|
|
91
|
+
"access": "public"
|
|
92
|
+
}
|
|
93
93
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
}
|