@zhubangyun/lowcode-core 5.4.115 → 5.4.120
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/es/index.d.ts +1 -2
- package/es/index.js +2 -3
- package/{lib/utils/form/form.api.d.ts → es/utils/api/form-api.d.ts} +2 -2
- package/es/utils/{form/form.api.js → api/form-api.js} +10 -5
- package/es/utils/api/index.d.ts +5 -3
- package/es/utils/api/index.js +4 -2
- package/es/utils/api/{RestApi.js → rest-api.js} +1 -1
- package/es/utils/cache/index.d.ts +1 -1
- package/es/utils/cache/index.js +1 -1
- package/es/utils/page/index.d.ts +3 -3
- package/es/utils/page/index.js +69 -1
- package/{lib/utils/page/page.form.d.ts → es/utils/page/page-form.d.ts} +2 -2
- package/es/utils/page/page-form.js +122 -0
- package/{lib/utils/page/page.layout.d.ts → es/utils/page/page-layout.d.ts} +5 -0
- package/es/utils/page/{page.layout.js → page-layout.js} +20 -7
- package/lib/index.d.ts +1 -2
- package/lib/index.js +6 -6
- package/{es/utils/form/form.api.d.ts → lib/utils/api/form-api.d.ts} +2 -2
- package/lib/utils/{form/form.api.js → api/form-api.js} +12 -7
- package/lib/utils/api/index.d.ts +5 -3
- package/lib/utils/api/index.js +9 -5
- package/lib/utils/api/{RestApi.js → rest-api.js} +2 -2
- package/lib/utils/cache/index.d.ts +1 -1
- package/lib/utils/cache/index.js +2 -2
- package/lib/utils/page/index.d.ts +3 -3
- package/lib/utils/page/index.js +73 -2
- package/{es/utils/page/page.form.d.ts → lib/utils/page/page-form.d.ts} +2 -2
- package/lib/utils/page/page-form.js +127 -0
- package/{es/utils/page/page.layout.d.ts → lib/utils/page/page-layout.d.ts} +5 -0
- package/lib/utils/page/{page.layout.js → page-layout.js} +20 -7
- package/package.json +1 -1
- package/es/utils/page/page.form.js +0 -69
- package/lib/utils/page/page.form.js +0 -74
- /package/es/utils/{form/form.instance.d.ts → api/form-instance.d.ts} +0 -0
- /package/es/utils/{form/form.instance.js → api/form-instance.js} +0 -0
- /package/es/utils/api/{Request.d.ts → request.d.ts} +0 -0
- /package/es/utils/api/{Request.js → request.js} +0 -0
- /package/es/utils/api/{RestApi.d.ts → rest-api.d.ts} +0 -0
- /package/es/utils/api/{UserInfo.d.ts → user-info.d.ts} +0 -0
- /package/es/utils/api/{UserInfo.js → user-info.js} +0 -0
- /package/es/utils/page/{page.load-schema.d.ts → page-load-schema.d.ts} +0 -0
- /package/es/utils/page/{page.load-schema.js → page-load-schema.js} +0 -0
- /package/lib/utils/{form/form.instance.d.ts → api/form-instance.d.ts} +0 -0
- /package/lib/utils/{form/form.instance.js → api/form-instance.js} +0 -0
- /package/lib/utils/api/{Request.d.ts → request.d.ts} +0 -0
- /package/lib/utils/api/{Request.js → request.js} +0 -0
- /package/lib/utils/api/{RestApi.d.ts → rest-api.d.ts} +0 -0
- /package/lib/utils/api/{UserInfo.d.ts → user-info.d.ts} +0 -0
- /package/lib/utils/api/{UserInfo.js → user-info.js} +0 -0
- /package/lib/utils/page/{page.load-schema.d.ts → page-load-schema.d.ts} +0 -0
- /package/lib/utils/page/{page.load-schema.js → page-load-schema.js} +0 -0
package/es/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import utils from "./utils";
|
|
2
|
-
export { RestApi } from "./utils/api
|
|
3
|
-
export { RestFormApi } from "./utils/form/form.api";
|
|
2
|
+
export { RestApi, RestFormApi, apiRequest } from "./utils/api";
|
|
4
3
|
export { Layout } from "./components/layout";
|
|
5
4
|
export { ReactRender } from "./components/react-render";
|
|
6
5
|
export { utils };
|
package/es/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import utils from "./utils";
|
|
2
|
-
export { RestApi } from "./utils/api
|
|
3
|
-
export { RestFormApi } from "./utils/form/form.api";
|
|
2
|
+
export { RestApi, RestFormApi, apiRequest } from "./utils/api";
|
|
4
3
|
export { Layout } from "./components/layout";
|
|
5
4
|
export { ReactRender } from "./components/react-render";
|
|
6
5
|
// @ts-ignore
|
|
7
|
-
window.utils =
|
|
6
|
+
window.utils = utils;
|
|
8
7
|
export { utils };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { RestApi } from "
|
|
1
|
+
import { RestApi } from "./rest-api";
|
|
2
2
|
import { AxiosRequestConfig } from "axios";
|
|
3
3
|
export declare class RestFormApi<DataType> extends RestApi<DataType> {
|
|
4
4
|
private readonly formId;
|
|
5
|
-
private readonly fieldId
|
|
5
|
+
private readonly fieldId?;
|
|
6
6
|
private readonly mock;
|
|
7
7
|
private initialized;
|
|
8
8
|
private schema;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
-
import { RestApi } from "
|
|
5
|
-
import { getSchema } from "
|
|
4
|
+
import { RestApi } from "./rest-api";
|
|
5
|
+
import { getSchema } from "./index";
|
|
6
6
|
export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
7
7
|
function RestFormApi(formId, fieldId, mock) {
|
|
8
8
|
var _this;
|
|
9
|
+
console.log(formId, fieldId);
|
|
9
10
|
_this = _RestApi.call(this, "forms", {}) || this;
|
|
10
11
|
_this.formId = void 0;
|
|
11
12
|
_this.fieldId = void 0;
|
|
@@ -13,7 +14,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
13
14
|
_this.initialized = false;
|
|
14
15
|
_this.schema = void 0;
|
|
15
16
|
_this.formId = formId;
|
|
16
|
-
_this.fieldId =
|
|
17
|
+
_this.fieldId = fieldId;
|
|
17
18
|
_this.mock = !!mock;
|
|
18
19
|
return _this;
|
|
19
20
|
}
|
|
@@ -72,8 +73,12 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
72
73
|
case 2:
|
|
73
74
|
config.params = config.params || {};
|
|
74
75
|
config.params.formId = this.formId;
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
if (this.fieldId) {
|
|
77
|
+
config.params.fieldId = this.fieldId;
|
|
78
|
+
}
|
|
79
|
+
if (this.mock) {
|
|
80
|
+
config.params.mock = this.mock;
|
|
81
|
+
}
|
|
77
82
|
case 6:
|
|
78
83
|
case "end":
|
|
79
84
|
return _context2.stop();
|
package/es/utils/api/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { OneResult } from "./
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { OneResult } from "./rest-api";
|
|
2
|
+
export { RestApi } from "./rest-api";
|
|
3
|
+
import { RestFormApi } from "./form-api";
|
|
4
|
+
export { loadUserInfo } from "./user-info";
|
|
5
|
+
export { RestFormApi } from "./form-api";
|
|
4
6
|
export declare const apiRequest: import("axios").AxiosInstance;
|
|
5
7
|
export declare function getSchema(pageId: string, mock?: boolean): Promise<OneResult<any>>;
|
|
6
8
|
export declare function getFormApi(formId: string, fieldId?: string, mock?: boolean): Promise<RestFormApi<any>>;
|
package/es/utils/api/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
3
|
import axios from "axios";
|
|
4
|
-
import { onFulfilled, onRejected } from "./
|
|
4
|
+
import { onFulfilled, onRejected } from "./request";
|
|
5
5
|
import { formApi, schema } from "../cache";
|
|
6
|
-
export {
|
|
6
|
+
export { RestApi } from "./rest-api";
|
|
7
|
+
export { loadUserInfo } from "./user-info";
|
|
8
|
+
export { RestFormApi } from "./form-api";
|
|
7
9
|
export var apiRequest = axios.create({
|
|
8
10
|
baseURL: "/api",
|
|
9
11
|
// 基础URL
|
|
@@ -2,7 +2,7 @@ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import axios from "axios";
|
|
5
|
-
import { onFulfilled, onRejected } from "./
|
|
5
|
+
import { onFulfilled, onRejected } from "./request";
|
|
6
6
|
export var BaseRestApi = /*#__PURE__*/function () {
|
|
7
7
|
function BaseRestApi(uri, options) {
|
|
8
8
|
this.uri = void 0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SingletonInstanceMap } from "../common/SingletonInstanceMap";
|
|
2
|
-
import { RestFormApi } from "../
|
|
2
|
+
import { RestFormApi } from "../api/form-api";
|
|
3
3
|
export declare class SchemaCache extends SingletonInstanceMap<any, {
|
|
4
4
|
mock?: boolean;
|
|
5
5
|
pageId: string;
|
package/es/utils/cache/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
2
2
|
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import { SingletonInstanceMap } from "../common/SingletonInstanceMap";
|
|
5
|
-
import { RestFormApi } from "../
|
|
5
|
+
import { RestFormApi } from "../api/form-api";
|
|
6
6
|
import { handleFormSchema } from "./schema";
|
|
7
7
|
import { apiRequest } from "../api";
|
|
8
8
|
export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
|
package/es/utils/page/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { showForm } from "./page
|
|
2
|
-
export
|
|
3
|
-
|
|
1
|
+
export { showForm } from "./page-form";
|
|
2
|
+
export declare function openPage(url: string, target?: string): Promise<any>;
|
|
3
|
+
export declare function closePage(url: string, target?: string): Promise<void>;
|
package/es/utils/page/index.js
CHANGED
|
@@ -1 +1,69 @@
|
|
|
1
|
-
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
export { showForm } from "./page-form";
|
|
4
|
+
export function openPage(_x, _x2) {
|
|
5
|
+
return _openPage.apply(this, arguments);
|
|
6
|
+
}
|
|
7
|
+
function _openPage() {
|
|
8
|
+
_openPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url, target) {
|
|
9
|
+
var _window$parent;
|
|
10
|
+
var page, func;
|
|
11
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
12
|
+
while (1) switch (_context.prev = _context.next) {
|
|
13
|
+
case 0:
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
func = (_window$parent = window.parent) === null || _window$parent === void 0 ? void 0 : _window$parent.openWorkPlatformTab;
|
|
16
|
+
if (!func) {
|
|
17
|
+
_context.next = 7;
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
_context.next = 4;
|
|
21
|
+
return func({
|
|
22
|
+
value: target,
|
|
23
|
+
url: url
|
|
24
|
+
});
|
|
25
|
+
case 4:
|
|
26
|
+
page = _context.sent;
|
|
27
|
+
_context.next = 8;
|
|
28
|
+
break;
|
|
29
|
+
case 7:
|
|
30
|
+
page = window.open(url, target);
|
|
31
|
+
case 8:
|
|
32
|
+
console.log("openPage", page);
|
|
33
|
+
return _context.abrupt("return", page);
|
|
34
|
+
case 10:
|
|
35
|
+
case "end":
|
|
36
|
+
return _context.stop();
|
|
37
|
+
}
|
|
38
|
+
}, _callee);
|
|
39
|
+
}));
|
|
40
|
+
return _openPage.apply(this, arguments);
|
|
41
|
+
}
|
|
42
|
+
export function closePage(_x3, _x4) {
|
|
43
|
+
return _closePage.apply(this, arguments);
|
|
44
|
+
}
|
|
45
|
+
function _closePage() {
|
|
46
|
+
_closePage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(url, target) {
|
|
47
|
+
var _window$parent2;
|
|
48
|
+
var func;
|
|
49
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
50
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
51
|
+
case 0:
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
func = (_window$parent2 = window.parent) === null || _window$parent2 === void 0 ? void 0 : _window$parent2.closeWorkPlatformTab;
|
|
54
|
+
if (func) {
|
|
55
|
+
func({
|
|
56
|
+
value: target,
|
|
57
|
+
url: url
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
window.close();
|
|
61
|
+
}
|
|
62
|
+
case 2:
|
|
63
|
+
case "end":
|
|
64
|
+
return _context2.stop();
|
|
65
|
+
}
|
|
66
|
+
}, _callee2);
|
|
67
|
+
}));
|
|
68
|
+
return _closePage.apply(this, arguments);
|
|
69
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PageLayoutType } from "./page
|
|
1
|
+
import { PageLayoutType } from "./page-layout";
|
|
2
2
|
export declare type PageFormModeType = "add" | "edit" | "detail";
|
|
3
3
|
export interface ShowFormProps {
|
|
4
4
|
container?: HTMLDivElement;
|
|
@@ -13,4 +13,4 @@ export interface ShowFormProps {
|
|
|
13
13
|
onRemoveOk?: () => void;
|
|
14
14
|
onClose?: () => void | Promise<void>;
|
|
15
15
|
}
|
|
16
|
-
export declare function showForm(options: ShowFormProps): void
|
|
16
|
+
export declare function showForm(options: ShowFormProps): Promise<void>;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
5
|
+
var _excluded = ["layout", "form", "onClose"],
|
|
6
|
+
_excluded2 = ["container", "onClose"];
|
|
7
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
|
+
import { PageLayout } from "./page-layout";
|
|
9
|
+
import ReactDOM from "react-dom";
|
|
10
|
+
import { Component } from "react";
|
|
11
|
+
import { PageLoadSchema } from "./page-load-schema";
|
|
12
|
+
import { ReactRender } from "../../components/react-render";
|
|
13
|
+
import { openPage } from "./index";
|
|
14
|
+
export function showForm(_x) {
|
|
15
|
+
return _showForm.apply(this, arguments);
|
|
16
|
+
}
|
|
17
|
+
function _showForm() {
|
|
18
|
+
_showForm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
|
|
19
|
+
var container, onClose, restProps, unmount, _options$form, paths, mode, dataId, params, page;
|
|
20
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
21
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
22
|
+
case 0:
|
|
23
|
+
container = options.container, onClose = options.onClose, restProps = _objectWithoutPropertiesLoose(options, _excluded2); //容器不存在需要手动取消挂载
|
|
24
|
+
unmount = !container;
|
|
25
|
+
console.log("showForm.options", options);
|
|
26
|
+
if (container) {
|
|
27
|
+
_context2.next = 16;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
if (!(options.layout == "page")) {
|
|
31
|
+
_context2.next = 14;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
paths = window.location.pathname.split("/");
|
|
35
|
+
mode = options.mode, dataId = options.dataId;
|
|
36
|
+
params = new URLSearchParams();
|
|
37
|
+
params.set("dataId", dataId || "");
|
|
38
|
+
_context2.next = 11;
|
|
39
|
+
return openPage("/" + paths[1] + "/" + paths[2] + "/" + ((_options$form = options.form) === null || _options$form === void 0 ? void 0 : _options$form.id) + "/" + mode + "?" + params.toString());
|
|
40
|
+
case 11:
|
|
41
|
+
page = _context2.sent;
|
|
42
|
+
console.debug("openPage", page);
|
|
43
|
+
return _context2.abrupt("return");
|
|
44
|
+
case 14:
|
|
45
|
+
container = document.createElement("div");
|
|
46
|
+
document.body.append(container);
|
|
47
|
+
case 16:
|
|
48
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(FormRender, _extends({}, restProps, {
|
|
49
|
+
onClose: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
50
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
51
|
+
while (1) switch (_context.prev = _context.next) {
|
|
52
|
+
case 0:
|
|
53
|
+
if (unmount) {
|
|
54
|
+
//等待动画结束
|
|
55
|
+
setTimeout(function () {
|
|
56
|
+
var _container;
|
|
57
|
+
//取消挂载
|
|
58
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
59
|
+
//移除
|
|
60
|
+
(_container = container) === null || _container === void 0 ? void 0 : _container.remove();
|
|
61
|
+
}, 1000);
|
|
62
|
+
}
|
|
63
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
64
|
+
case 2:
|
|
65
|
+
case "end":
|
|
66
|
+
return _context.stop();
|
|
67
|
+
}
|
|
68
|
+
}, _callee);
|
|
69
|
+
}))
|
|
70
|
+
})), container);
|
|
71
|
+
case 17:
|
|
72
|
+
case "end":
|
|
73
|
+
return _context2.stop();
|
|
74
|
+
}
|
|
75
|
+
}, _callee2);
|
|
76
|
+
}));
|
|
77
|
+
return _showForm.apply(this, arguments);
|
|
78
|
+
}
|
|
79
|
+
var FormRender = /*#__PURE__*/function (_Component) {
|
|
80
|
+
function FormRender() {
|
|
81
|
+
var _this;
|
|
82
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
83
|
+
args[_key] = arguments[_key];
|
|
84
|
+
}
|
|
85
|
+
_this = _Component.call.apply(_Component, [this].concat(args)) || this;
|
|
86
|
+
_this.layoutRef = void 0;
|
|
87
|
+
return _this;
|
|
88
|
+
}
|
|
89
|
+
_inheritsLoose(FormRender, _Component);
|
|
90
|
+
var _proto = FormRender.prototype;
|
|
91
|
+
_proto.render = function render() {
|
|
92
|
+
var _this2 = this;
|
|
93
|
+
var self = this;
|
|
94
|
+
var _this$props = this.props,
|
|
95
|
+
layout = _this$props.layout,
|
|
96
|
+
form = _this$props.form,
|
|
97
|
+
onClose = _this$props.onClose,
|
|
98
|
+
restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
99
|
+
// @ts-ignore
|
|
100
|
+
restProps.layout = layout || "drawer";
|
|
101
|
+
// @ts-ignore
|
|
102
|
+
restProps.onClose = function () {
|
|
103
|
+
var _self$layoutRef;
|
|
104
|
+
(_self$layoutRef = self.layoutRef) === null || _self$layoutRef === void 0 ? void 0 : _self$layoutRef.close();
|
|
105
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
106
|
+
};
|
|
107
|
+
return /*#__PURE__*/React.createElement(PageLayout, {
|
|
108
|
+
layout: layout,
|
|
109
|
+
ref: function ref(layout) {
|
|
110
|
+
return _this2.layoutRef = layout;
|
|
111
|
+
}
|
|
112
|
+
}, /*#__PURE__*/React.createElement(PageLoadSchema, {
|
|
113
|
+
pageId: form === null || form === void 0 ? void 0 : form.id
|
|
114
|
+
}, function (schema) {
|
|
115
|
+
return /*#__PURE__*/React.createElement(ReactRender, _extends({
|
|
116
|
+
schema: schema,
|
|
117
|
+
components: window.__components
|
|
118
|
+
}, restProps));
|
|
119
|
+
}));
|
|
120
|
+
};
|
|
121
|
+
return FormRender;
|
|
122
|
+
}(Component);
|
|
@@ -6,10 +6,15 @@ interface PageLayoutProps {
|
|
|
6
6
|
}
|
|
7
7
|
interface PageLayoutState {
|
|
8
8
|
open: boolean;
|
|
9
|
+
width?: number;
|
|
9
10
|
}
|
|
10
11
|
export declare class PageLayout extends Component<PageLayoutProps, PageLayoutState> {
|
|
11
12
|
state: PageLayoutState;
|
|
12
13
|
close: () => void;
|
|
14
|
+
constructor(props: any);
|
|
15
|
+
componentDidMount(): void;
|
|
16
|
+
componentWillUnmount(): void;
|
|
17
|
+
handleResize: () => void;
|
|
13
18
|
render(): any;
|
|
14
19
|
}
|
|
15
20
|
export {};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import _Drawer from "antd/es/drawer";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
3
|
import _Modal from "antd/es/modal";
|
|
3
4
|
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
4
5
|
import React, { Component } from "react";
|
|
5
6
|
export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
6
|
-
function PageLayout() {
|
|
7
|
+
function PageLayout(props) {
|
|
7
8
|
var _this;
|
|
8
|
-
|
|
9
|
-
args[_key] = arguments[_key];
|
|
10
|
-
}
|
|
11
|
-
_this = _Component.call.apply(_Component, [this].concat(args)) || this;
|
|
9
|
+
_this = _Component.call(this, props) || this;
|
|
12
10
|
_this.state = {
|
|
13
11
|
open: true
|
|
14
12
|
};
|
|
@@ -17,10 +15,22 @@ export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
17
15
|
open: false
|
|
18
16
|
});
|
|
19
17
|
};
|
|
18
|
+
_this.handleResize = function () {
|
|
19
|
+
_this.setState({
|
|
20
|
+
width: Math.min(window.innerWidth, 1400)
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
_this.state.width = Math.min(window.innerWidth, 1400);
|
|
20
24
|
return _this;
|
|
21
25
|
}
|
|
22
26
|
_inheritsLoose(PageLayout, _Component);
|
|
23
27
|
var _proto = PageLayout.prototype;
|
|
28
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
29
|
+
window.addEventListener("resize", this.handleResize);
|
|
30
|
+
};
|
|
31
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
32
|
+
window.removeEventListener("resize", this.handleResize);
|
|
33
|
+
};
|
|
24
34
|
_proto.render = function render() {
|
|
25
35
|
var _this$props = this.props,
|
|
26
36
|
layout = _this$props.layout,
|
|
@@ -28,6 +38,8 @@ export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
28
38
|
var state = this.state;
|
|
29
39
|
var restProps = {
|
|
30
40
|
open: state.open,
|
|
41
|
+
width: state.width,
|
|
42
|
+
onClose: this.close,
|
|
31
43
|
footer: false,
|
|
32
44
|
closable: false,
|
|
33
45
|
styles: {
|
|
@@ -41,14 +53,15 @@ export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
41
53
|
padding: 0
|
|
42
54
|
}
|
|
43
55
|
},
|
|
44
|
-
onClose: this.close,
|
|
45
56
|
keyboard: false,
|
|
46
57
|
maskClosable: false
|
|
47
58
|
};
|
|
48
59
|
if (layout == "modal") {
|
|
49
60
|
return /*#__PURE__*/React.createElement(_Modal, restProps, children);
|
|
50
61
|
} else if (layout == "drawer") {
|
|
51
|
-
return /*#__PURE__*/React.createElement(_Drawer, restProps,
|
|
62
|
+
return /*#__PURE__*/React.createElement(_Drawer, _extends({}, restProps, {
|
|
63
|
+
width: Math.max(1200, window.innerWidth)
|
|
64
|
+
}), children);
|
|
52
65
|
}
|
|
53
66
|
return children;
|
|
54
67
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import utils from "./utils";
|
|
2
|
-
export { RestApi } from "./utils/api
|
|
3
|
-
export { RestFormApi } from "./utils/form/form.api";
|
|
2
|
+
export { RestApi, RestFormApi, apiRequest } from "./utils/api";
|
|
4
3
|
export { Layout } from "./components/layout";
|
|
5
4
|
export { ReactRender } from "./components/react-render";
|
|
6
5
|
export { utils };
|
package/lib/index.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
exports.__esModule = true;
|
|
5
|
-
exports.RestFormApi = exports.RestApi = exports.ReactRender = exports.Layout = void 0;
|
|
5
|
+
exports.apiRequest = exports.RestFormApi = exports.RestApi = exports.ReactRender = exports.Layout = void 0;
|
|
6
6
|
var _utils = _interopRequireDefault(require("./utils"));
|
|
7
7
|
exports.utils = _utils["default"];
|
|
8
|
-
var
|
|
9
|
-
exports.RestApi =
|
|
10
|
-
|
|
11
|
-
exports.
|
|
8
|
+
var _api = require("./utils/api");
|
|
9
|
+
exports.RestApi = _api.RestApi;
|
|
10
|
+
exports.RestFormApi = _api.RestFormApi;
|
|
11
|
+
exports.apiRequest = _api.apiRequest;
|
|
12
12
|
var _layout = require("./components/layout");
|
|
13
13
|
exports.Layout = _layout.Layout;
|
|
14
14
|
var _reactRender = require("./components/react-render");
|
|
15
15
|
exports.ReactRender = _reactRender.ReactRender;
|
|
16
16
|
// @ts-ignore
|
|
17
|
-
window.utils =
|
|
17
|
+
window.utils = _utils["default"];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { RestApi } from "
|
|
1
|
+
import { RestApi } from "./rest-api";
|
|
2
2
|
import { AxiosRequestConfig } from "axios";
|
|
3
3
|
export declare class RestFormApi<DataType> extends RestApi<DataType> {
|
|
4
4
|
private readonly formId;
|
|
5
|
-
private readonly fieldId
|
|
5
|
+
private readonly fieldId?;
|
|
6
6
|
private readonly mock;
|
|
7
7
|
private initialized;
|
|
8
8
|
private schema;
|
|
@@ -6,11 +6,12 @@ exports.RestFormApi = void 0;
|
|
|
6
6
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
7
7
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
8
|
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var _restApi = require("./rest-api");
|
|
10
|
+
var _index = require("./index");
|
|
11
11
|
var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
12
12
|
function RestFormApi(formId, fieldId, mock) {
|
|
13
13
|
var _this;
|
|
14
|
+
console.log(formId, fieldId);
|
|
14
15
|
_this = _RestApi.call(this, "forms", {}) || this;
|
|
15
16
|
_this.formId = void 0;
|
|
16
17
|
_this.fieldId = void 0;
|
|
@@ -18,7 +19,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
18
19
|
_this.initialized = false;
|
|
19
20
|
_this.schema = void 0;
|
|
20
21
|
_this.formId = formId;
|
|
21
|
-
_this.fieldId =
|
|
22
|
+
_this.fieldId = fieldId;
|
|
22
23
|
_this.mock = !!mock;
|
|
23
24
|
return _this;
|
|
24
25
|
}
|
|
@@ -38,7 +39,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
38
39
|
case 4:
|
|
39
40
|
_context.prev = 4;
|
|
40
41
|
_context.next = 7;
|
|
41
|
-
return (0,
|
|
42
|
+
return (0, _index.getSchema)(this.formId, this.mock);
|
|
42
43
|
case 7:
|
|
43
44
|
res = _context.sent;
|
|
44
45
|
this.schema = res.data;
|
|
@@ -77,8 +78,12 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
77
78
|
case 2:
|
|
78
79
|
config.params = config.params || {};
|
|
79
80
|
config.params.formId = this.formId;
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
if (this.fieldId) {
|
|
82
|
+
config.params.fieldId = this.fieldId;
|
|
83
|
+
}
|
|
84
|
+
if (this.mock) {
|
|
85
|
+
config.params.mock = this.mock;
|
|
86
|
+
}
|
|
82
87
|
case 6:
|
|
83
88
|
case "end":
|
|
84
89
|
return _context2.stop();
|
|
@@ -91,4 +96,4 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
91
96
|
return handleRequestConfig;
|
|
92
97
|
}();
|
|
93
98
|
return RestFormApi;
|
|
94
|
-
}(
|
|
99
|
+
}(_restApi.RestApi);
|
package/lib/utils/api/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { OneResult } from "./
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { OneResult } from "./rest-api";
|
|
2
|
+
export { RestApi } from "./rest-api";
|
|
3
|
+
import { RestFormApi } from "./form-api";
|
|
4
|
+
export { loadUserInfo } from "./user-info";
|
|
5
|
+
export { RestFormApi } from "./form-api";
|
|
4
6
|
export declare const apiRequest: import("axios").AxiosInstance;
|
|
5
7
|
export declare function getSchema(pageId: string, mock?: boolean): Promise<OneResult<any>>;
|
|
6
8
|
export declare function getFormApi(formId: string, fieldId?: string, mock?: boolean): Promise<RestFormApi<any>>;
|
package/lib/utils/api/index.js
CHANGED
|
@@ -2,17 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
exports.__esModule = true;
|
|
5
|
-
exports.apiRequest = void 0;
|
|
5
|
+
exports.apiRequest = exports.RestFormApi = exports.RestApi = void 0;
|
|
6
6
|
exports.getFormApi = getFormApi;
|
|
7
7
|
exports.getSchema = getSchema;
|
|
8
8
|
exports.loadUserInfo = void 0;
|
|
9
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
11
|
var _axios = _interopRequireDefault(require("axios"));
|
|
12
|
-
var
|
|
12
|
+
var _request = require("./request");
|
|
13
13
|
var _cache = require("../cache");
|
|
14
|
-
var
|
|
15
|
-
exports.
|
|
14
|
+
var _restApi = require("./rest-api");
|
|
15
|
+
exports.RestApi = _restApi.RestApi;
|
|
16
|
+
var _userInfo = require("./user-info");
|
|
17
|
+
exports.loadUserInfo = _userInfo.loadUserInfo;
|
|
18
|
+
var _formApi = require("./form-api");
|
|
19
|
+
exports.RestFormApi = _formApi.RestFormApi;
|
|
16
20
|
var apiRequest = exports.apiRequest = _axios["default"].create({
|
|
17
21
|
baseURL: "/api",
|
|
18
22
|
// 基础URL
|
|
@@ -22,7 +26,7 @@ var apiRequest = exports.apiRequest = _axios["default"].create({
|
|
|
22
26
|
'Content-Type': 'application/json;charset=UTF-8'
|
|
23
27
|
}
|
|
24
28
|
});
|
|
25
|
-
apiRequest.interceptors.response.use(
|
|
29
|
+
apiRequest.interceptors.response.use(_request.onFulfilled, _request.onRejected);
|
|
26
30
|
function getSchema(_x, _x2) {
|
|
27
31
|
return _getSchema.apply(this, arguments);
|
|
28
32
|
}
|
|
@@ -7,7 +7,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
7
7
|
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
8
8
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
9
9
|
var _axios = _interopRequireDefault(require("axios"));
|
|
10
|
-
var
|
|
10
|
+
var _request = require("./request");
|
|
11
11
|
var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
|
|
12
12
|
function BaseRestApi(uri, options) {
|
|
13
13
|
this.uri = void 0;
|
|
@@ -24,7 +24,7 @@ var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
|
|
|
24
24
|
'Content-Type': 'application/json;charset=UTF-8'
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
this.request.interceptors.response.use(
|
|
27
|
+
this.request.interceptors.response.use(_request.onFulfilled, _request.onRejected);
|
|
28
28
|
}
|
|
29
29
|
var _proto = BaseRestApi.prototype;
|
|
30
30
|
_proto.search = /*#__PURE__*/function () {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SingletonInstanceMap } from "../common/SingletonInstanceMap";
|
|
2
|
-
import { RestFormApi } from "../
|
|
2
|
+
import { RestFormApi } from "../api/form-api";
|
|
3
3
|
export declare class SchemaCache extends SingletonInstanceMap<any, {
|
|
4
4
|
mock?: boolean;
|
|
5
5
|
pageId: string;
|
package/lib/utils/cache/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
7
7
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
8
|
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
9
9
|
var _SingletonInstanceMap3 = require("../common/SingletonInstanceMap");
|
|
10
|
-
var
|
|
10
|
+
var _formApi = require("../api/form-api");
|
|
11
11
|
var _schema = require("./schema");
|
|
12
12
|
var _api = require("../api");
|
|
13
13
|
var SchemaCache = exports.SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
|
|
@@ -65,7 +65,7 @@ var FormApiCache = exports.FormApiCache = /*#__PURE__*/function (_SingletonInsta
|
|
|
65
65
|
options = {};
|
|
66
66
|
}
|
|
67
67
|
_options = options, formId = _options.formId, fieldId = _options.fieldId, mock = _options.mock;
|
|
68
|
-
formApi = new
|
|
68
|
+
formApi = new _formApi.RestFormApi(formId, fieldId, mock);
|
|
69
69
|
_context2.next = 5;
|
|
70
70
|
return formApi.initialize();
|
|
71
71
|
case 5:
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { showForm } from "./page
|
|
2
|
-
export
|
|
3
|
-
|
|
1
|
+
export { showForm } from "./page-form";
|
|
2
|
+
export declare function openPage(url: string, target?: string): Promise<any>;
|
|
3
|
+
export declare function closePage(url: string, target?: string): Promise<void>;
|
package/lib/utils/page/index.js
CHANGED
|
@@ -1,6 +1,77 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
exports.__esModule = true;
|
|
5
|
+
exports.closePage = closePage;
|
|
6
|
+
exports.openPage = openPage;
|
|
4
7
|
exports.showForm = void 0;
|
|
5
|
-
var
|
|
6
|
-
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _pageForm = require("./page-form");
|
|
11
|
+
exports.showForm = _pageForm.showForm;
|
|
12
|
+
function openPage(_x, _x2) {
|
|
13
|
+
return _openPage.apply(this, arguments);
|
|
14
|
+
}
|
|
15
|
+
function _openPage() {
|
|
16
|
+
_openPage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(url, target) {
|
|
17
|
+
var _window$parent;
|
|
18
|
+
var page, func;
|
|
19
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
20
|
+
while (1) switch (_context.prev = _context.next) {
|
|
21
|
+
case 0:
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
func = (_window$parent = window.parent) === null || _window$parent === void 0 ? void 0 : _window$parent.openWorkPlatformTab;
|
|
24
|
+
if (!func) {
|
|
25
|
+
_context.next = 7;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
_context.next = 4;
|
|
29
|
+
return func({
|
|
30
|
+
value: target,
|
|
31
|
+
url: url
|
|
32
|
+
});
|
|
33
|
+
case 4:
|
|
34
|
+
page = _context.sent;
|
|
35
|
+
_context.next = 8;
|
|
36
|
+
break;
|
|
37
|
+
case 7:
|
|
38
|
+
page = window.open(url, target);
|
|
39
|
+
case 8:
|
|
40
|
+
console.log("openPage", page);
|
|
41
|
+
return _context.abrupt("return", page);
|
|
42
|
+
case 10:
|
|
43
|
+
case "end":
|
|
44
|
+
return _context.stop();
|
|
45
|
+
}
|
|
46
|
+
}, _callee);
|
|
47
|
+
}));
|
|
48
|
+
return _openPage.apply(this, arguments);
|
|
49
|
+
}
|
|
50
|
+
function closePage(_x3, _x4) {
|
|
51
|
+
return _closePage.apply(this, arguments);
|
|
52
|
+
}
|
|
53
|
+
function _closePage() {
|
|
54
|
+
_closePage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(url, target) {
|
|
55
|
+
var _window$parent2;
|
|
56
|
+
var func;
|
|
57
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
58
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
59
|
+
case 0:
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
func = (_window$parent2 = window.parent) === null || _window$parent2 === void 0 ? void 0 : _window$parent2.closeWorkPlatformTab;
|
|
62
|
+
if (func) {
|
|
63
|
+
func({
|
|
64
|
+
value: target,
|
|
65
|
+
url: url
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
window.close();
|
|
69
|
+
}
|
|
70
|
+
case 2:
|
|
71
|
+
case "end":
|
|
72
|
+
return _context2.stop();
|
|
73
|
+
}
|
|
74
|
+
}, _callee2);
|
|
75
|
+
}));
|
|
76
|
+
return _closePage.apply(this, arguments);
|
|
77
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PageLayoutType } from "./page
|
|
1
|
+
import { PageLayoutType } from "./page-layout";
|
|
2
2
|
export declare type PageFormModeType = "add" | "edit" | "detail";
|
|
3
3
|
export interface ShowFormProps {
|
|
4
4
|
container?: HTMLDivElement;
|
|
@@ -13,4 +13,4 @@ export interface ShowFormProps {
|
|
|
13
13
|
onRemoveOk?: () => void;
|
|
14
14
|
onClose?: () => void | Promise<void>;
|
|
15
15
|
}
|
|
16
|
-
export declare function showForm(options: ShowFormProps): void
|
|
16
|
+
export declare function showForm(options: ShowFormProps): Promise<void>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.showForm = showForm;
|
|
6
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
7
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
8
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
9
|
+
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
var _pageLayout = require("./page-layout");
|
|
12
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
13
|
+
var _react = require("react");
|
|
14
|
+
var _pageLoadSchema = require("./page-load-schema");
|
|
15
|
+
var _reactRender = require("../../components/react-render");
|
|
16
|
+
var _index = require("./index");
|
|
17
|
+
var _excluded = ["layout", "form", "onClose"],
|
|
18
|
+
_excluded2 = ["container", "onClose"];
|
|
19
|
+
function showForm(_x) {
|
|
20
|
+
return _showForm.apply(this, arguments);
|
|
21
|
+
}
|
|
22
|
+
function _showForm() {
|
|
23
|
+
_showForm = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(options) {
|
|
24
|
+
var container, onClose, restProps, unmount, _options$form, paths, mode, dataId, params, page;
|
|
25
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
26
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
27
|
+
case 0:
|
|
28
|
+
container = options.container, onClose = options.onClose, restProps = (0, _objectWithoutPropertiesLoose2["default"])(options, _excluded2); //容器不存在需要手动取消挂载
|
|
29
|
+
unmount = !container;
|
|
30
|
+
console.log("showForm.options", options);
|
|
31
|
+
if (container) {
|
|
32
|
+
_context2.next = 16;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
if (!(options.layout == "page")) {
|
|
36
|
+
_context2.next = 14;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
paths = window.location.pathname.split("/");
|
|
40
|
+
mode = options.mode, dataId = options.dataId;
|
|
41
|
+
params = new URLSearchParams();
|
|
42
|
+
params.set("dataId", dataId || "");
|
|
43
|
+
_context2.next = 11;
|
|
44
|
+
return (0, _index.openPage)("/" + paths[1] + "/" + paths[2] + "/" + ((_options$form = options.form) === null || _options$form === void 0 ? void 0 : _options$form.id) + "/" + mode + "?" + params.toString());
|
|
45
|
+
case 11:
|
|
46
|
+
page = _context2.sent;
|
|
47
|
+
console.debug("openPage", page);
|
|
48
|
+
return _context2.abrupt("return");
|
|
49
|
+
case 14:
|
|
50
|
+
container = document.createElement("div");
|
|
51
|
+
document.body.append(container);
|
|
52
|
+
case 16:
|
|
53
|
+
_reactDom["default"].render( /*#__PURE__*/React.createElement(FormRender, (0, _extends2["default"])({}, restProps, {
|
|
54
|
+
onClose: /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
55
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
56
|
+
while (1) switch (_context.prev = _context.next) {
|
|
57
|
+
case 0:
|
|
58
|
+
if (unmount) {
|
|
59
|
+
//等待动画结束
|
|
60
|
+
setTimeout(function () {
|
|
61
|
+
var _container;
|
|
62
|
+
//取消挂载
|
|
63
|
+
_reactDom["default"].unmountComponentAtNode(container);
|
|
64
|
+
//移除
|
|
65
|
+
(_container = container) === null || _container === void 0 ? void 0 : _container.remove();
|
|
66
|
+
}, 1000);
|
|
67
|
+
}
|
|
68
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
69
|
+
case 2:
|
|
70
|
+
case "end":
|
|
71
|
+
return _context.stop();
|
|
72
|
+
}
|
|
73
|
+
}, _callee);
|
|
74
|
+
}))
|
|
75
|
+
})), container);
|
|
76
|
+
case 17:
|
|
77
|
+
case "end":
|
|
78
|
+
return _context2.stop();
|
|
79
|
+
}
|
|
80
|
+
}, _callee2);
|
|
81
|
+
}));
|
|
82
|
+
return _showForm.apply(this, arguments);
|
|
83
|
+
}
|
|
84
|
+
var FormRender = /*#__PURE__*/function (_Component) {
|
|
85
|
+
function FormRender() {
|
|
86
|
+
var _this;
|
|
87
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
88
|
+
args[_key] = arguments[_key];
|
|
89
|
+
}
|
|
90
|
+
_this = _Component.call.apply(_Component, [this].concat(args)) || this;
|
|
91
|
+
_this.layoutRef = void 0;
|
|
92
|
+
return _this;
|
|
93
|
+
}
|
|
94
|
+
(0, _inheritsLoose2["default"])(FormRender, _Component);
|
|
95
|
+
var _proto = FormRender.prototype;
|
|
96
|
+
_proto.render = function render() {
|
|
97
|
+
var _this2 = this;
|
|
98
|
+
var self = this;
|
|
99
|
+
var _this$props = this.props,
|
|
100
|
+
layout = _this$props.layout,
|
|
101
|
+
form = _this$props.form,
|
|
102
|
+
onClose = _this$props.onClose,
|
|
103
|
+
restProps = (0, _objectWithoutPropertiesLoose2["default"])(_this$props, _excluded);
|
|
104
|
+
// @ts-ignore
|
|
105
|
+
restProps.layout = layout || "drawer";
|
|
106
|
+
// @ts-ignore
|
|
107
|
+
restProps.onClose = function () {
|
|
108
|
+
var _self$layoutRef;
|
|
109
|
+
(_self$layoutRef = self.layoutRef) === null || _self$layoutRef === void 0 ? void 0 : _self$layoutRef.close();
|
|
110
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
111
|
+
};
|
|
112
|
+
return /*#__PURE__*/React.createElement(_pageLayout.PageLayout, {
|
|
113
|
+
layout: layout,
|
|
114
|
+
ref: function ref(layout) {
|
|
115
|
+
return _this2.layoutRef = layout;
|
|
116
|
+
}
|
|
117
|
+
}, /*#__PURE__*/React.createElement(_pageLoadSchema.PageLoadSchema, {
|
|
118
|
+
pageId: form === null || form === void 0 ? void 0 : form.id
|
|
119
|
+
}, function (schema) {
|
|
120
|
+
return /*#__PURE__*/React.createElement(_reactRender.ReactRender, (0, _extends2["default"])({
|
|
121
|
+
schema: schema,
|
|
122
|
+
components: window.__components
|
|
123
|
+
}, restProps));
|
|
124
|
+
}));
|
|
125
|
+
};
|
|
126
|
+
return FormRender;
|
|
127
|
+
}(_react.Component);
|
|
@@ -6,10 +6,15 @@ interface PageLayoutProps {
|
|
|
6
6
|
}
|
|
7
7
|
interface PageLayoutState {
|
|
8
8
|
open: boolean;
|
|
9
|
+
width?: number;
|
|
9
10
|
}
|
|
10
11
|
export declare class PageLayout extends Component<PageLayoutProps, PageLayoutState> {
|
|
11
12
|
state: PageLayoutState;
|
|
12
13
|
close: () => void;
|
|
14
|
+
constructor(props: any);
|
|
15
|
+
componentDidMount(): void;
|
|
16
|
+
componentWillUnmount(): void;
|
|
17
|
+
handleResize: () => void;
|
|
13
18
|
render(): any;
|
|
14
19
|
}
|
|
15
20
|
export {};
|
|
@@ -4,18 +4,16 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.PageLayout = void 0;
|
|
6
6
|
var _drawer = _interopRequireDefault(require("antd/lib/drawer"));
|
|
7
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
8
|
var _modal = _interopRequireDefault(require("antd/lib/modal"));
|
|
8
9
|
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
9
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
11
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
11
12
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
12
13
|
var PageLayout = exports.PageLayout = /*#__PURE__*/function (_Component) {
|
|
13
|
-
function PageLayout() {
|
|
14
|
+
function PageLayout(props) {
|
|
14
15
|
var _this;
|
|
15
|
-
|
|
16
|
-
args[_key] = arguments[_key];
|
|
17
|
-
}
|
|
18
|
-
_this = _Component.call.apply(_Component, [this].concat(args)) || this;
|
|
16
|
+
_this = _Component.call(this, props) || this;
|
|
19
17
|
_this.state = {
|
|
20
18
|
open: true
|
|
21
19
|
};
|
|
@@ -24,10 +22,22 @@ var PageLayout = exports.PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
24
22
|
open: false
|
|
25
23
|
});
|
|
26
24
|
};
|
|
25
|
+
_this.handleResize = function () {
|
|
26
|
+
_this.setState({
|
|
27
|
+
width: Math.min(window.innerWidth, 1400)
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
_this.state.width = Math.min(window.innerWidth, 1400);
|
|
27
31
|
return _this;
|
|
28
32
|
}
|
|
29
33
|
(0, _inheritsLoose2["default"])(PageLayout, _Component);
|
|
30
34
|
var _proto = PageLayout.prototype;
|
|
35
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
36
|
+
window.addEventListener("resize", this.handleResize);
|
|
37
|
+
};
|
|
38
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
39
|
+
window.removeEventListener("resize", this.handleResize);
|
|
40
|
+
};
|
|
31
41
|
_proto.render = function render() {
|
|
32
42
|
var _this$props = this.props,
|
|
33
43
|
layout = _this$props.layout,
|
|
@@ -35,6 +45,8 @@ var PageLayout = exports.PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
35
45
|
var state = this.state;
|
|
36
46
|
var restProps = {
|
|
37
47
|
open: state.open,
|
|
48
|
+
width: state.width,
|
|
49
|
+
onClose: this.close,
|
|
38
50
|
footer: false,
|
|
39
51
|
closable: false,
|
|
40
52
|
styles: {
|
|
@@ -48,14 +60,15 @@ var PageLayout = exports.PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
48
60
|
padding: 0
|
|
49
61
|
}
|
|
50
62
|
},
|
|
51
|
-
onClose: this.close,
|
|
52
63
|
keyboard: false,
|
|
53
64
|
maskClosable: false
|
|
54
65
|
};
|
|
55
66
|
if (layout == "modal") {
|
|
56
67
|
return /*#__PURE__*/_react["default"].createElement(_modal["default"], restProps, children);
|
|
57
68
|
} else if (layout == "drawer") {
|
|
58
|
-
return /*#__PURE__*/_react["default"].createElement(_drawer["default"], restProps,
|
|
69
|
+
return /*#__PURE__*/_react["default"].createElement(_drawer["default"], (0, _extends2["default"])({}, restProps, {
|
|
70
|
+
width: Math.max(1200, window.innerWidth)
|
|
71
|
+
}), children);
|
|
59
72
|
}
|
|
60
73
|
return children;
|
|
61
74
|
};
|
package/package.json
CHANGED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
2
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
5
|
-
var _excluded = ["container", "onClose"],
|
|
6
|
-
_excluded2 = ["layout", "form"];
|
|
7
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
|
-
import { PageLayout } from "./page.layout";
|
|
9
|
-
import ReactDOM from "react-dom";
|
|
10
|
-
import { Component } from "react";
|
|
11
|
-
import { PageLoadSchema } from "./page.load-schema";
|
|
12
|
-
import { ReactRender } from "../../components/react-render";
|
|
13
|
-
export function showForm(options) {
|
|
14
|
-
var container = options.container,
|
|
15
|
-
onClose = options.onClose,
|
|
16
|
-
restProps = _objectWithoutPropertiesLoose(options, _excluded);
|
|
17
|
-
//容器不存在需要手动取消挂载
|
|
18
|
-
var unmount = !container;
|
|
19
|
-
if (!container) {
|
|
20
|
-
container = document.createElement("div");
|
|
21
|
-
document.body.append(container);
|
|
22
|
-
}
|
|
23
|
-
ReactDOM.render( /*#__PURE__*/React.createElement(FormRender, _extends({}, restProps, {
|
|
24
|
-
onClose: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
25
|
-
var _container;
|
|
26
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
27
|
-
while (1) switch (_context.prev = _context.next) {
|
|
28
|
-
case 0:
|
|
29
|
-
if (unmount) {
|
|
30
|
-
//取消挂载
|
|
31
|
-
ReactDOM.unmountComponentAtNode(container);
|
|
32
|
-
//移除
|
|
33
|
-
(_container = container) === null || _container === void 0 ? void 0 : _container.remove();
|
|
34
|
-
}
|
|
35
|
-
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
36
|
-
case 2:
|
|
37
|
-
case "end":
|
|
38
|
-
return _context.stop();
|
|
39
|
-
}
|
|
40
|
-
}, _callee);
|
|
41
|
-
}))
|
|
42
|
-
})), container);
|
|
43
|
-
}
|
|
44
|
-
var FormRender = /*#__PURE__*/function (_Component) {
|
|
45
|
-
function FormRender() {
|
|
46
|
-
return _Component.apply(this, arguments) || this;
|
|
47
|
-
}
|
|
48
|
-
_inheritsLoose(FormRender, _Component);
|
|
49
|
-
var _proto = FormRender.prototype;
|
|
50
|
-
_proto.render = function render() {
|
|
51
|
-
var _this$props = this.props,
|
|
52
|
-
layout = _this$props.layout,
|
|
53
|
-
form = _this$props.form,
|
|
54
|
-
restProps = _objectWithoutPropertiesLoose(_this$props, _excluded2);
|
|
55
|
-
// @ts-ignore
|
|
56
|
-
restProps.layout = layout || "drawer";
|
|
57
|
-
return /*#__PURE__*/React.createElement(PageLayout, {
|
|
58
|
-
layout: layout
|
|
59
|
-
}, /*#__PURE__*/React.createElement(PageLoadSchema, {
|
|
60
|
-
pageId: form === null || form === void 0 ? void 0 : form.id
|
|
61
|
-
}, function (schema) {
|
|
62
|
-
return /*#__PURE__*/React.createElement(ReactRender, _extends({
|
|
63
|
-
schema: schema,
|
|
64
|
-
components: window.__components
|
|
65
|
-
}, restProps));
|
|
66
|
-
}));
|
|
67
|
-
};
|
|
68
|
-
return FormRender;
|
|
69
|
-
}(Component);
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
exports.__esModule = true;
|
|
5
|
-
exports.showForm = showForm;
|
|
6
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
7
|
-
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
|
-
var _page = require("./page.layout");
|
|
12
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
13
|
-
var _react = require("react");
|
|
14
|
-
var _page2 = require("./page.load-schema");
|
|
15
|
-
var _reactRender = require("../../components/react-render");
|
|
16
|
-
var _excluded = ["container", "onClose"],
|
|
17
|
-
_excluded2 = ["layout", "form"];
|
|
18
|
-
function showForm(options) {
|
|
19
|
-
var container = options.container,
|
|
20
|
-
onClose = options.onClose,
|
|
21
|
-
restProps = (0, _objectWithoutPropertiesLoose2["default"])(options, _excluded);
|
|
22
|
-
//容器不存在需要手动取消挂载
|
|
23
|
-
var unmount = !container;
|
|
24
|
-
if (!container) {
|
|
25
|
-
container = document.createElement("div");
|
|
26
|
-
document.body.append(container);
|
|
27
|
-
}
|
|
28
|
-
_reactDom["default"].render( /*#__PURE__*/React.createElement(FormRender, (0, _extends2["default"])({}, restProps, {
|
|
29
|
-
onClose: /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
30
|
-
var _container;
|
|
31
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
32
|
-
while (1) switch (_context.prev = _context.next) {
|
|
33
|
-
case 0:
|
|
34
|
-
if (unmount) {
|
|
35
|
-
//取消挂载
|
|
36
|
-
_reactDom["default"].unmountComponentAtNode(container);
|
|
37
|
-
//移除
|
|
38
|
-
(_container = container) === null || _container === void 0 ? void 0 : _container.remove();
|
|
39
|
-
}
|
|
40
|
-
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
41
|
-
case 2:
|
|
42
|
-
case "end":
|
|
43
|
-
return _context.stop();
|
|
44
|
-
}
|
|
45
|
-
}, _callee);
|
|
46
|
-
}))
|
|
47
|
-
})), container);
|
|
48
|
-
}
|
|
49
|
-
var FormRender = /*#__PURE__*/function (_Component) {
|
|
50
|
-
function FormRender() {
|
|
51
|
-
return _Component.apply(this, arguments) || this;
|
|
52
|
-
}
|
|
53
|
-
(0, _inheritsLoose2["default"])(FormRender, _Component);
|
|
54
|
-
var _proto = FormRender.prototype;
|
|
55
|
-
_proto.render = function render() {
|
|
56
|
-
var _this$props = this.props,
|
|
57
|
-
layout = _this$props.layout,
|
|
58
|
-
form = _this$props.form,
|
|
59
|
-
restProps = (0, _objectWithoutPropertiesLoose2["default"])(_this$props, _excluded2);
|
|
60
|
-
// @ts-ignore
|
|
61
|
-
restProps.layout = layout || "drawer";
|
|
62
|
-
return /*#__PURE__*/React.createElement(_page.PageLayout, {
|
|
63
|
-
layout: layout
|
|
64
|
-
}, /*#__PURE__*/React.createElement(_page2.PageLoadSchema, {
|
|
65
|
-
pageId: form === null || form === void 0 ? void 0 : form.id
|
|
66
|
-
}, function (schema) {
|
|
67
|
-
return /*#__PURE__*/React.createElement(_reactRender.ReactRender, (0, _extends2["default"])({
|
|
68
|
-
schema: schema,
|
|
69
|
-
components: window.__components
|
|
70
|
-
}, restProps));
|
|
71
|
-
}));
|
|
72
|
-
};
|
|
73
|
-
return FormRender;
|
|
74
|
-
}(_react.Component);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|