Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sz-mx-cabin

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sz-mx-cabin - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

es/MainGenerator.d.ts

@@ -19,6 +19,4 @@ interface mainGenratorProps {

eventHandlers?: any;
setInvokeMethod: any;
setPostMessageMethod: any;
}
export default function MainGenerator(props: mainGenratorProps): JSX.Element;
export {};

118

es/MainGenerator.js

@@ -66,3 +66,2 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

import { useCabinGeneretorStore } from './CabinGeneratorContext';
import useRefCallback from './useRefCallback';
export default function MainGenerator(props) {

@@ -93,5 +92,3 @@ var _this = this;

forwardLowCodePage = props.forwardLowCodePage,
eventHandlers = props.eventHandlers,
setInvokeMethod = props.setInvokeMethod,
setPostMessageMethod = props.setPostMessageMethod;
eventHandlers = props.eventHandlers;
/**

@@ -172,3 +169,3 @@ * state维护:

});
}, [props.pageJson, props.pageFunction]); // 设置formInstance
}, [props.pageJson, props.pageFunction, props.defaultAttributes]); // 设置formInstance
// 用useRef是为了 setData 重新渲染之后 不会发生变化

@@ -221,7 +218,6 @@ // 他自己变 也不需要重新啊渲染UI

values = _context.sent;
console.log(values, 'validateForm');
return _context.abrupt("return", true);
case 11:
_context.prev = 11;
case 10:
_context.prev = 10;
_context.t0 = _context["catch"](3);

@@ -231,3 +227,3 @@ console.log(_context.t0, "validateForm[".concat(formName, "]"));

case 15:
case 14:
case "end":

@@ -237,3 +233,3 @@ return _context.stop();

}
}, _callee, null, [[3, 11]]);
}, _callee, null, [[3, 10]]);
}));

@@ -265,7 +261,5 @@ }

values = _context2.sent;
console.log(values, 'validateTable'); // todo 待mx修改 暂时先这么着
// 没改之前 如果校验成功,返回的是data数组 否则是个对象里边message是提示信息
if (!Array.isArray(values)) {
_context2.next = 12;
_context2.next = 11;
break;

@@ -276,11 +270,11 @@ }

case 12:
case 11:
return _context2.abrupt("return", false);
case 13:
_context2.next = 19;
case 12:
_context2.next = 18;
break;
case 15:
_context2.prev = 15;
case 14:
_context2.prev = 14;
_context2.t0 = _context2["catch"](3);

@@ -290,3 +284,3 @@ console.log(_context2.t0, "validateTable[".concat(tableName, "]"));

case 19:
case 18:
case "end":

@@ -296,3 +290,3 @@ return _context2.stop();

}
}, _callee2, null, [[3, 15]]);
}, _callee2, null, [[3, 14]]);
}));

@@ -474,3 +468,3 @@ }

}, [mainGeneratorState.pageFunction]);
var pageFunctionObj = useMemo(function () {
useMemo(function () {
// 添加额外的代码

@@ -505,2 +499,18 @@ var addExport = initPageFunction(pageJson, esPageFunction);

}
}, [isPageFunctionRevert, esPageFunction]);
var pageFunctionObj = useMemo(function () {
// 添加额外的代码
var addExport = initPageFunction(pageJson, esPageFunction);
var result = evalCode(addExport, {
DLCUtil: DLCUtil,
message: message,
moment: moment,
request: request
});
if (!result && isPageFunctionRevert) {
return {};
} else {
return result;
}
}, [isPageFunctionRevert, esPageFunction, JSON.stringify(mainGeneratorState)]); // 处理函数的接口 input上事件配置onEventHandler

@@ -720,5 +730,31 @@ // inputName 。。好多input 用同一个onChange方法的情况

return pageFunctionObj[fnName](mainGeneratorState.data, mainGeneratorState.attributes);
}; // schema 转成 flattenJson
// @ts-ignore
var flattenJson = schemaToFlattenedJson(mainGeneratorState.pageJson); // dataToFlattenJson(flattenJson, data); 不单独管理每个from了。通过antd的from展示数据
attributesToFlattenJson(flattenJson, mainGeneratorState.attributes); // attributes变了之后要生效
var store = {
flattenedJson: flattenJson,
pageFunctionObj: pageFunctionObj,
onEventHandler: onEventHandler,
setFormAndTableInstance: setFormAndTableInstance,
getFormCustomRules: getFormCustomRules,
onFormDataChange: onFormDataChange,
onTableEventHandler: onTableEventHandler,
data: mainGeneratorState.data,
attrs: mainGeneratorState.attributes,
setData: handleData
};
var dialogFooter = {};
var invoke = useRefCallback(function (functionName) {
if (props.isDialog && dialogOptions.showFooter == false) {
dialogFooter = {
footer: null
};
}
var invoke = function invoke(functionName) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -772,34 +808,12 @@ return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {

}));
}, []);
}; // 更新cabin对外暴露的方法,如果pageFunctionObj变了就得变
useEffect(function () {
if (pageFunctionObj) {
setInvokeMethod(invoke);
if (pageFunctionObj && cabinGeneretor.setCabinPublicMethods) {
cabinGeneretor.setCabinPublicMethods({
invoke: invoke
});
}
}, [pageFunctionObj]); // schema 转成 flattenJson
// @ts-ignore
var flattenJson = schemaToFlattenedJson(mainGeneratorState.pageJson); // dataToFlattenJson(flattenJson, data); 不单独管理每个from了。通过antd的from展示数据
attributesToFlattenJson(flattenJson, mainGeneratorState.attributes); // attributes变了之后要生效
var store = {
flattenedJson: flattenJson,
pageFunctionObj: pageFunctionObj,
onEventHandler: onEventHandler,
setFormAndTableInstance: setFormAndTableInstance,
getFormCustomRules: getFormCustomRules,
onFormDataChange: onFormDataChange,
onTableEventHandler: onTableEventHandler,
data: mainGeneratorState.data,
attrs: mainGeneratorState.attributes,
setData: handleData
};
var dialogFooter = {};
if (props.isDialog && dialogOptions.showFooter == false) {
dialogFooter = {
footer: null
};
}
}, [pageFunctionObj, JSON.stringify(mainGeneratorState ? mainGeneratorState : {})]);
return /*#__PURE__*/React.createElement(React.Fragment, null, props.isDialog ? /*#__PURE__*/React.createElement(Modal, _extends({

@@ -806,0 +820,0 @@ title: dialogOptions.title,

@@ -22,6 +22,4 @@ export interface DialogConfig {

isPreview?: boolean;
setInvokeMethod: any;
setPostMessageMethod: any;
}
export default function ModalGeneratorEntrance(props: ModalGeneratorEntranceProps): JSX.Element;
export {};

@@ -66,5 +66,3 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";

isDialog = _props$isDialog === void 0 ? false : _props$isDialog,
eventHandlers = props.eventHandlers,
setInvokeMethod = props.setInvokeMethod,
setPostMessageMethod = props.setPostMessageMethod; // 只需要解析一遍的东西在这解析完成
eventHandlers = props.eventHandlers; // 只需要解析一遍的东西在这解析完成

@@ -273,6 +271,4 @@ var data = parseDataStructure(pageJson);

});
}, [pageJson, pageFunction, propOptions]);
}, [pageJson, pageFunction, JSON.stringify(propOptions ? propOptions : {})]);
return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(MainGenerator, {
setPostMessageMethod: setPostMessageMethod,
setInvokeMethod: setInvokeMethod,
appid: appid,

@@ -296,4 +292,2 @@ pageJson: pageConfigJson.pageJson,

}), dialogState.visible && /*#__PURE__*/React.createElement(UIGeneratorEntrance, {
setPostMessageMethod: setPostMessageMethod,
setInvokeMethod: setInvokeMethod,
eventHandlers: eventHandlers,

@@ -300,0 +294,0 @@ appid: appid,

@@ -22,6 +22,4 @@ export interface DialogConfig {

isPreview?: boolean;
setInvokeMethod: any;
setPostMessageMethod: any;
}
export default function UIGeneratorEntrance(props: UIGeneratorEntranceProps): JSX.Element;
export {};

@@ -66,5 +66,3 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";

isDialog = _props$isDialog === void 0 ? false : _props$isDialog,
eventHandlers = props.eventHandlers,
setInvokeMethod = props.setInvokeMethod,
setPostMessageMethod = props.setPostMessageMethod; // 只需要解析一遍的东西在这解析完成
eventHandlers = props.eventHandlers; // 只需要解析一遍的东西在这解析完成

@@ -275,4 +273,2 @@ var data = parseDataStructure(pageJson);

return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(MainGenerator, {
setPostMessageMethod: setPostMessageMethod,
setInvokeMethod: setInvokeMethod,
appid: appid,

@@ -296,4 +292,2 @@ pageJson: pageConfigJson.pageJson,

}), dialogState.visible && /*#__PURE__*/React.createElement(ModalGeneratorEntrance, {
setInvokeMethod: setInvokeMethod,
setPostMessageMethod: setPostMessageMethod,
eventHandlers: eventHandlers,

@@ -300,0 +294,0 @@ appid: appid,

@@ -1,2 +0,1 @@

import React from 'react';
interface UIGeneratorIndexProps {

@@ -9,4 +8,5 @@ cabinName: string;

cabinJ?: any;
setCabinPublicMethods?: any;
}
declare const _default: React.ForwardRefExoticComponent<UIGeneratorIndexProps & React.RefAttributes<unknown>>;
export default _default;
export default function UIGeneratorIndex(props: UIGeneratorIndexProps): JSX.Element;
export {};

@@ -0,1 +1,3 @@

import _regeneratorRuntime from "@babel/runtime/regenerator";
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

@@ -13,4 +15,2 @@

import _regeneratorRuntime from "@babel/runtime/regenerator";
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {

@@ -48,3 +48,3 @@ function adopt(value) {

import React, { useEffect, useState, useRef, useImperativeHandle } from 'react';
import React, { useEffect, useState } from 'react';
import UIGeneratorEntrance from './UIGeneratorEntrance';

@@ -54,3 +54,4 @@ import { getCustomPageInfo, getPageInfoByName } from './api/api';

import ErrorBoundary from './ErrorBoundary';
export default /*#__PURE__*/React.forwardRef(function UIGeneratorIndex(props, ref) {
import { CabinGeneretorContext } from './CabinGeneratorContext';
export default function UIGeneratorIndex(props) {
var _this = this;

@@ -64,3 +65,4 @@

eventHandlers = props.eventHandlers,
cabinJ = props.cabinJ;
cabinJ = props.cabinJ,
setCabinPublicMethods = props.setCabinPublicMethods;

@@ -72,61 +74,2 @@ if (!cabinName) {

var appId = propsAppId;
var invokeRef = useRef();
useImperativeHandle(ref, function () {
return {
invoke: function invoke(methodname) {
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (!invokeRef.current.invoke) {
_context.next = 4;
break;
}
return _context.abrupt("return", invokeRef.current.invoke(methodname, props));
case 4:
return _context.abrupt("return", new Promise(function (resolve, reject) {
var totalTime = 0;
var interval = setInterval(function () {
totalTime = totalTime + 100;
if (invokeRef.current.invoke || totalTime > 3000) {
clearInterval(interval);
resolve(invokeRef.current.invoke(methodname, props));
}
}, 100);
}));
case 5:
case "end":
return _context.stop();
}
}
}, _callee);
}));
},
postMessage: function postMessage(methodname) {
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (invokeRef.current.postMessage) {
invokeRef.current.postMessage(methodname, props);
}
}
};
});
var setInvokeMethod = function setInvokeMethod(invokeMethod) {
if (invokeMethod) {
invokeRef.current.invoke = invokeMethod;
}
};
var setPostMessageMethod = function setPostMessageMethod(postMessageMethod) {
if (postMessageMethod) {
invokeRef.current.postMessage = postMessageMethod;
}
};
/**

@@ -136,3 +79,2 @@ * 若props中不存在appid,从context中取出当前的appid

if (!appId) {

@@ -161,11 +103,11 @@ //从context中取值

var getPageData = function getPageData() {
return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
var pageDataResult, _pageDataResult, pagecontent, pageJsonResult;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context2.prev = _context2.next) {
switch (_context.prev = _context.next) {
case 0:
if (!cabinJ) {
_context2.next = 4;
_context.next = 4;
break;

@@ -176,24 +118,24 @@ }

setPageJson(cabinJ.pagejson);
return _context2.abrupt("return");
return _context.abrupt("return");
case 4:
if (!biz) {
_context2.next = 10;
_context.next = 10;
break;
}
_context2.next = 7;
_context.next = 7;
return getCustomPageInfo(biz, cabinName, appId);
case 7:
pageDataResult = _context2.sent;
_context2.next = 13;
pageDataResult = _context.sent;
_context.next = 13;
break;
case 10:
_context2.next = 12;
_context.next = 12;
return getPageInfoByName(cabinName, appId);
case 12:
pageDataResult = _context2.sent;
pageDataResult = _context.sent;

@@ -214,6 +156,6 @@ case 13:

case "end":
return _context2.stop();
return _context.stop();
}
}
}, _callee2);
}, _callee);
}));

@@ -223,6 +165,2 @@ };

useEffect(function () {
invokeRef.current = {
invoke: undefined,
postMessage: undefined
};
getPageData();

@@ -235,5 +173,7 @@ }, [cabinName, biz, appId, cabinJ]);

return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(UIGeneratorEntrance, {
setInvokeMethod: setInvokeMethod,
setPostMessageMethod: setPostMessageMethod,
return /*#__PURE__*/React.createElement(CabinGeneretorContext.Provider, {
value: {
setCabinPublicMethods: setCabinPublicMethods
}
}, /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(UIGeneratorEntrance, {
pageJson: pageJson,

@@ -244,3 +184,4 @@ pageFunction: pageFunction,

eventHandlers: eventHandlers
}));
});
})));
}
;

@@ -34,3 +34,3 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

} // "IDCardRule:身份证,EmailRule:邮箱,MobilePhoneRule:移动电话," +
// "TelephoneRule:固定电话,ZipCodeRule:邮政编码,IPRule:IP地址,ChnEngRule:中英文,ChnengNumberRule:中英文数字"
// "TelephoneRule:固定电话,ZipCodeRule:邮政编码,IPRule:IP地址,ChnEngRule:中英文,ChnengNumberRule:中英文数字,engNumberRule:英文数字"

@@ -37,0 +37,0 @@

@@ -31,5 +31,3 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

var itemProperties = resultAttributes.props;
var itemAddition = resultAttributes.addition; // console.log(itemAddition, 'itemAddition');
// console.log(itemProperties, 'itemProperties');
//当前列的类型
var itemAddition = resultAttributes.addition; //当前列的类型

@@ -36,0 +34,0 @@ var componentType = get(schema, 'type', '').replace('table', ''); //column的属性

@@ -17,5 +17,3 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

var itemProperties = resultAttributes.props;
var itemAddition = resultAttributes.addition; // console.log(itemAddition, 'itemAddition');
// console.log(itemProperties, 'itemProperties');
//column的属性
var itemAddition = resultAttributes.addition; //column的属性

@@ -22,0 +20,0 @@ var componentObj = {}; //组装componentType的props

@@ -19,5 +19,3 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

var itemProperties = resultAttributes.props;
var itemAddition = resultAttributes.addition; // console.log(itemAddition, 'itemAddition');
// console.log(itemProperties, 'itemProperties');
//column的属性
var itemAddition = resultAttributes.addition; //column的属性

@@ -24,0 +22,0 @@ var componentObj = {}; //组装componentType的props

@@ -78,4 +78,3 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

}
}, render), sorterProps); // console.log("selectColumn",componentObj);
}, render), sorterProps);
return _extends(_extends({

@@ -82,0 +81,0 @@ title: get(schema, 'attributes.label', ''),

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import React, { useEffect, useRef } from 'react';
import { BasicTable, BasicEditTable } from 'dw-mx-table';
import { Table, Typography } from 'dw-mx';

@@ -13,2 +12,5 @@ var Text = Typography.Text;

import './TableWidget.less';
import _ from 'lodash';
import BasicEditTable from './BasicEditTable';
import BasicTable from './BasicTable';
export default function TableWidget(props) {

@@ -107,6 +109,6 @@ var _props$props = props.props,

//初始化表格数据
//const tableData = data[tableName];
//配置rowSelection
var tableData = data[tableName]; //配置rowSelection
var rowSelection = {};

@@ -157,3 +159,3 @@ var selectionMode = addition.selectionMode;

if (selectionMode == 'checkbox' || selectionMode == 'radio') {
if (tableData && tableData.length > 0) {
if (data[tableName] && data[tableName].length > 0) {
var rowKeyColumnDataIsExist = false;

@@ -163,6 +165,6 @@ var resultRowKey = 'key';

if (rowKey) {
rowKeyColumnDataIsExist = tableData[0][rowKey] != undefined;
rowKeyColumnDataIsExist = data[tableName][0][rowKey] != undefined;
resultRowKey = rowKey;
} else {
rowKeyColumnDataIsExist = tableData[0]['key'] != undefined;
rowKeyColumnDataIsExist = data[tableName][0]['key'] != undefined;
}

@@ -341,3 +343,3 @@

}, rowSelection, {
dataSource: tableData
dataSource: data[tableName]
}, properties, rowKey, {

@@ -358,3 +360,3 @@ onRow: onRowEvent,

}, rowSelection, {
dataSource: tableData
dataSource: data[tableName]
}, properties, rowKey, {

@@ -365,7 +367,12 @@ onRow: onRowEvent,

columns: columns,
getChildValues: function getChildValues() {},
getChildValues: function getChildValues(currentData) {
var newData = _.cloneDeep(data);
newData[tableName] = currentData;
setData(newData);
},
ref: tableRef,
summary: summaryFn
}, divCell));
}));
}
}

@@ -19,6 +19,4 @@ interface mainGenratorProps {

eventHandlers?: any;
setInvokeMethod: any;
setPostMessageMethod: any;
}
export default function MainGenerator(props: mainGenratorProps): JSX.Element;
export {};

@@ -40,4 +40,2 @@ "use strict";

var _useRefCallback = _interopRequireDefault(require("./useRefCallback"));
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); }

@@ -122,5 +120,3 @@

forwardLowCodePage = props.forwardLowCodePage,
eventHandlers = props.eventHandlers,
setInvokeMethod = props.setInvokeMethod,
setPostMessageMethod = props.setPostMessageMethod;
eventHandlers = props.eventHandlers;
/**

@@ -201,3 +197,3 @@ * state维护:

});
}, [props.pageJson, props.pageFunction]); // 设置formInstance
}, [props.pageJson, props.pageFunction, props.defaultAttributes]); // 设置formInstance
// 用useRef是为了 setData 重新渲染之后 不会发生变化

@@ -250,7 +246,6 @@ // 他自己变 也不需要重新啊渲染UI

values = _context.sent;
console.log(values, 'validateForm');
return _context.abrupt("return", true);
case 11:
_context.prev = 11;
case 10:
_context.prev = 10;
_context.t0 = _context["catch"](3);

@@ -260,3 +255,3 @@ console.log(_context.t0, "validateForm[".concat(formName, "]"));

case 15:
case 14:
case "end":

@@ -266,3 +261,3 @@ return _context.stop();

}
}, _callee, null, [[3, 11]]);
}, _callee, null, [[3, 10]]);
}));

@@ -294,7 +289,5 @@ }

values = _context2.sent;
console.log(values, 'validateTable'); // todo 待mx修改 暂时先这么着
// 没改之前 如果校验成功,返回的是data数组 否则是个对象里边message是提示信息
if (!Array.isArray(values)) {
_context2.next = 12;
_context2.next = 11;
break;

@@ -305,11 +298,11 @@ }

case 12:
case 11:
return _context2.abrupt("return", false);
case 13:
_context2.next = 19;
case 12:
_context2.next = 18;
break;
case 15:
_context2.prev = 15;
case 14:
_context2.prev = 14;
_context2.t0 = _context2["catch"](3);

@@ -319,3 +312,3 @@ console.log(_context2.t0, "validateTable[".concat(tableName, "]"));

case 19:
case 18:
case "end":

@@ -325,3 +318,3 @@ return _context2.stop();

}
}, _callee2, null, [[3, 15]]);
}, _callee2, null, [[3, 14]]);
}));

@@ -504,3 +497,3 @@ }

}, [mainGeneratorState.pageFunction]);
var pageFunctionObj = (0, _react.useMemo)(function () {
(0, _react.useMemo)(function () {
// 添加额外的代码

@@ -535,2 +528,18 @@ var addExport = (0, _UIGeneratorUtils.initPageFunction)(pageJson, esPageFunction);

}
}, [isPageFunctionRevert, esPageFunction]);
var pageFunctionObj = (0, _react.useMemo)(function () {
// 添加额外的代码
var addExport = (0, _UIGeneratorUtils.initPageFunction)(pageJson, esPageFunction);
var result = (0, _evalCode["default"])(addExport, {
DLCUtil: DLCUtil,
message: _dwMx.message,
moment: _moment["default"],
request: _dwMxRequest.request
});
if (!result && isPageFunctionRevert) {
return {};
} else {
return result;
}
}, [isPageFunctionRevert, esPageFunction, JSON.stringify(mainGeneratorState)]); // 处理函数的接口 input上事件配置onEventHandler

@@ -750,5 +759,31 @@ // inputName 。。好多input 用同一个onChange方法的情况

return pageFunctionObj[fnName](mainGeneratorState.data, mainGeneratorState.attributes);
}; // schema 转成 flattenJson
// @ts-ignore
var flattenJson = (0, _UIGeneratorUtils.schemaToFlattenedJson)(mainGeneratorState.pageJson); // dataToFlattenJson(flattenJson, data); 不单独管理每个from了。通过antd的from展示数据
(0, _UIGeneratorUtils.attributesToFlattenJson)(flattenJson, mainGeneratorState.attributes); // attributes变了之后要生效
var store = {
flattenedJson: flattenJson,
pageFunctionObj: pageFunctionObj,
onEventHandler: onEventHandler,
setFormAndTableInstance: setFormAndTableInstance,
getFormCustomRules: getFormCustomRules,
onFormDataChange: onFormDataChange,
onTableEventHandler: onTableEventHandler,
data: mainGeneratorState.data,
attrs: mainGeneratorState.attributes,
setData: handleData
};
var dialogFooter = {};
var invoke = (0, _useRefCallback["default"])(function (functionName) {
if (props.isDialog && dialogOptions.showFooter == false) {
dialogFooter = {
footer: null
};
}
var invoke = function invoke(functionName) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -802,34 +837,12 @@ return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regenerator["default"].mark(function _callee5() {

}));
}, []);
}; // 更新cabin对外暴露的方法,如果pageFunctionObj变了就得变
(0, _react.useEffect)(function () {
if (pageFunctionObj) {
setInvokeMethod(invoke);
if (pageFunctionObj && cabinGeneretor.setCabinPublicMethods) {
cabinGeneretor.setCabinPublicMethods({
invoke: invoke
});
}
}, [pageFunctionObj]); // schema 转成 flattenJson
// @ts-ignore
var flattenJson = (0, _UIGeneratorUtils.schemaToFlattenedJson)(mainGeneratorState.pageJson); // dataToFlattenJson(flattenJson, data); 不单独管理每个from了。通过antd的from展示数据
(0, _UIGeneratorUtils.attributesToFlattenJson)(flattenJson, mainGeneratorState.attributes); // attributes变了之后要生效
var store = {
flattenedJson: flattenJson,
pageFunctionObj: pageFunctionObj,
onEventHandler: onEventHandler,
setFormAndTableInstance: setFormAndTableInstance,
getFormCustomRules: getFormCustomRules,
onFormDataChange: onFormDataChange,
onTableEventHandler: onTableEventHandler,
data: mainGeneratorState.data,
attrs: mainGeneratorState.attributes,
setData: handleData
};
var dialogFooter = {};
if (props.isDialog && dialogOptions.showFooter == false) {
dialogFooter = {
footer: null
};
}
}, [pageFunctionObj, JSON.stringify(mainGeneratorState ? mainGeneratorState : {})]);
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, props.isDialog ? /*#__PURE__*/_react["default"].createElement(_dwMx.Modal, _extends({

@@ -836,0 +849,0 @@ title: dialogOptions.title,

@@ -22,6 +22,4 @@ export interface DialogConfig {

isPreview?: boolean;
setInvokeMethod: any;
setPostMessageMethod: any;
}
export default function ModalGeneratorEntrance(props: ModalGeneratorEntranceProps): JSX.Element;
export {};

@@ -84,5 +84,3 @@ "use strict";

isDialog = _props$isDialog === void 0 ? false : _props$isDialog,
eventHandlers = props.eventHandlers,
setInvokeMethod = props.setInvokeMethod,
setPostMessageMethod = props.setPostMessageMethod; // 只需要解析一遍的东西在这解析完成
eventHandlers = props.eventHandlers; // 只需要解析一遍的东西在这解析完成

@@ -291,6 +289,4 @@ var data = (0, _UIGeneratorUtils.parseDataStructure)(pageJson);

});
}, [pageJson, pageFunction, propOptions]);
}, [pageJson, pageFunction, JSON.stringify(propOptions ? propOptions : {})]);
return /*#__PURE__*/_react["default"].createElement(_ErrorBoundary["default"], null, /*#__PURE__*/_react["default"].createElement(_MainGenerator["default"], {
setPostMessageMethod: setPostMessageMethod,
setInvokeMethod: setInvokeMethod,
appid: appid,

@@ -314,4 +310,2 @@ pageJson: pageConfigJson.pageJson,

}), dialogState.visible && /*#__PURE__*/_react["default"].createElement(_UIGeneratorEntrance["default"], {
setPostMessageMethod: setPostMessageMethod,
setInvokeMethod: setInvokeMethod,
eventHandlers: eventHandlers,

@@ -318,0 +312,0 @@ appid: appid,

@@ -22,6 +22,4 @@ export interface DialogConfig {

isPreview?: boolean;
setInvokeMethod: any;
setPostMessageMethod: any;
}
export default function UIGeneratorEntrance(props: UIGeneratorEntranceProps): JSX.Element;
export {};

@@ -84,5 +84,3 @@ "use strict";

isDialog = _props$isDialog === void 0 ? false : _props$isDialog,
eventHandlers = props.eventHandlers,
setInvokeMethod = props.setInvokeMethod,
setPostMessageMethod = props.setPostMessageMethod; // 只需要解析一遍的东西在这解析完成
eventHandlers = props.eventHandlers; // 只需要解析一遍的东西在这解析完成

@@ -293,4 +291,2 @@ var data = (0, _UIGeneratorUtils.parseDataStructure)(pageJson);

return /*#__PURE__*/_react["default"].createElement(_ErrorBoundary["default"], null, /*#__PURE__*/_react["default"].createElement(_MainGenerator["default"], {
setPostMessageMethod: setPostMessageMethod,
setInvokeMethod: setInvokeMethod,
appid: appid,

@@ -314,4 +310,2 @@ pageJson: pageConfigJson.pageJson,

}), dialogState.visible && /*#__PURE__*/_react["default"].createElement(_ModalGeneratorEntrance["default"], {
setInvokeMethod: setInvokeMethod,
setPostMessageMethod: setPostMessageMethod,
eventHandlers: eventHandlers,

@@ -318,0 +312,0 @@ appid: appid,

@@ -1,2 +0,1 @@

import React from 'react';
interface UIGeneratorIndexProps {

@@ -9,4 +8,5 @@ cabinName: string;

cabinJ?: any;
setCabinPublicMethods?: any;
}
declare const _default: React.ForwardRefExoticComponent<UIGeneratorIndexProps & React.RefAttributes<unknown>>;
export default _default;
export default function UIGeneratorIndex(props: UIGeneratorIndexProps): JSX.Element;
export {};

@@ -8,3 +8,3 @@ "use strict";

});
exports["default"] = void 0;
exports["default"] = UIGeneratorIndex;

@@ -23,2 +23,4 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));

var _CabinGeneratorContext = require("./CabinGeneratorContext");
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); }

@@ -74,3 +76,3 @@

var _default = /*#__PURE__*/_react["default"].forwardRef(function UIGeneratorIndex(props, ref) {
function UIGeneratorIndex(props) {
var _this = this;

@@ -84,3 +86,4 @@

eventHandlers = props.eventHandlers,
cabinJ = props.cabinJ;
cabinJ = props.cabinJ,
setCabinPublicMethods = props.setCabinPublicMethods;

@@ -92,61 +95,2 @@ if (!cabinName) {

var appId = propsAppId;
var invokeRef = (0, _react.useRef)();
(0, _react.useImperativeHandle)(ref, function () {
return {
invoke: function invoke(methodname) {
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regenerator["default"].mark(function _callee() {
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (!invokeRef.current.invoke) {
_context.next = 4;
break;
}
return _context.abrupt("return", invokeRef.current.invoke(methodname, props));
case 4:
return _context.abrupt("return", new Promise(function (resolve, reject) {
var totalTime = 0;
var interval = setInterval(function () {
totalTime = totalTime + 100;
if (invokeRef.current.invoke || totalTime > 3000) {
clearInterval(interval);
resolve(invokeRef.current.invoke(methodname, props));
}
}, 100);
}));
case 5:
case "end":
return _context.stop();
}
}
}, _callee);
}));
},
postMessage: function postMessage(methodname) {
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (invokeRef.current.postMessage) {
invokeRef.current.postMessage(methodname, props);
}
}
};
});
var setInvokeMethod = function setInvokeMethod(invokeMethod) {
if (invokeMethod) {
invokeRef.current.invoke = invokeMethod;
}
};
var setPostMessageMethod = function setPostMessageMethod(postMessageMethod) {
if (postMessageMethod) {
invokeRef.current.postMessage = postMessageMethod;
}
};
/**

@@ -156,3 +100,2 @@ * 若props中不存在appid,从context中取出当前的appid

if (!appId) {

@@ -181,11 +124,11 @@ //从context中取值

var getPageData = function getPageData() {
return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regenerator["default"].mark(function _callee() {
var pageDataResult, _pageDataResult, pagecontent, pageJsonResult;
return _regenerator["default"].wrap(function _callee2$(_context2) {
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context2.prev = _context2.next) {
switch (_context.prev = _context.next) {
case 0:
if (!cabinJ) {
_context2.next = 4;
_context.next = 4;
break;

@@ -196,24 +139,24 @@ }

setPageJson(cabinJ.pagejson);
return _context2.abrupt("return");
return _context.abrupt("return");
case 4:
if (!biz) {
_context2.next = 10;
_context.next = 10;
break;
}
_context2.next = 7;
_context.next = 7;
return (0, _api.getCustomPageInfo)(biz, cabinName, appId);
case 7:
pageDataResult = _context2.sent;
_context2.next = 13;
pageDataResult = _context.sent;
_context.next = 13;
break;
case 10:
_context2.next = 12;
_context.next = 12;
return (0, _api.getPageInfoByName)(cabinName, appId);
case 12:
pageDataResult = _context2.sent;
pageDataResult = _context.sent;

@@ -234,6 +177,6 @@ case 13:

case "end":
return _context2.stop();
return _context.stop();
}
}
}, _callee2);
}, _callee);
}));

@@ -243,6 +186,2 @@ };

(0, _react.useEffect)(function () {
invokeRef.current = {
invoke: undefined,
postMessage: undefined
};
getPageData();

@@ -255,5 +194,7 @@ }, [cabinName, biz, appId, cabinJ]);

return /*#__PURE__*/_react["default"].createElement(_ErrorBoundary["default"], null, /*#__PURE__*/_react["default"].createElement(_UIGeneratorEntrance["default"], {
setInvokeMethod: setInvokeMethod,
setPostMessageMethod: setPostMessageMethod,
return /*#__PURE__*/_react["default"].createElement(_CabinGeneratorContext.CabinGeneretorContext.Provider, {
value: {
setCabinPublicMethods: setCabinPublicMethods
}
}, /*#__PURE__*/_react["default"].createElement(_ErrorBoundary["default"], null, /*#__PURE__*/_react["default"].createElement(_UIGeneratorEntrance["default"], {
pageJson: pageJson,

@@ -264,5 +205,5 @@ pageFunction: pageFunction,

eventHandlers: eventHandlers
}));
});
})));
}
exports["default"] = _default;
;

@@ -48,3 +48,3 @@ "use strict";

} // "IDCardRule:身份证,EmailRule:邮箱,MobilePhoneRule:移动电话," +
// "TelephoneRule:固定电话,ZipCodeRule:邮政编码,IPRule:IP地址,ChnEngRule:中英文,ChnengNumberRule:中英文数字"
// "TelephoneRule:固定电话,ZipCodeRule:邮政编码,IPRule:IP地址,ChnEngRule:中英文,ChnengNumberRule:中英文数字,engNumberRule:英文数字"

@@ -51,0 +51,0 @@

@@ -47,5 +47,3 @@ "use strict";

var itemProperties = resultAttributes.props;
var itemAddition = resultAttributes.addition; // console.log(itemAddition, 'itemAddition');
// console.log(itemProperties, 'itemProperties');
//当前列的类型
var itemAddition = resultAttributes.addition; //当前列的类型

@@ -52,0 +50,0 @@ var componentType = (0, _lodash.get)(schema, 'type', '').replace('table', ''); //column的属性

@@ -32,5 +32,3 @@ "use strict";

var itemProperties = resultAttributes.props;
var itemAddition = resultAttributes.addition; // console.log(itemAddition, 'itemAddition');
// console.log(itemProperties, 'itemProperties');
//column的属性
var itemAddition = resultAttributes.addition; //column的属性

@@ -37,0 +35,0 @@ var componentObj = {}; //组装componentType的props

@@ -35,5 +35,3 @@ "use strict";

var itemProperties = resultAttributes.props;
var itemAddition = resultAttributes.addition; // console.log(itemAddition, 'itemAddition');
// console.log(itemProperties, 'itemProperties');
//column的属性
var itemAddition = resultAttributes.addition; //column的属性

@@ -40,0 +38,0 @@ var componentObj = {}; //组装componentType的props

@@ -94,4 +94,3 @@ "use strict";

}
}, render), sorterProps); // console.log("selectColumn",componentObj);
}, render), sorterProps);
return _extends(_extends({

@@ -98,0 +97,0 @@ title: (0, _lodash.get)(schema, 'attributes.label', ''),

@@ -12,4 +12,2 @@ "use strict";

var _dwMxTable = require("dw-mx-table");
var _dwMx = require("dw-mx");

@@ -23,3 +21,3 @@

var _lodash = require("lodash");
var _lodash = _interopRequireWildcard(require("lodash"));

@@ -30,2 +28,8 @@ var _NumberUtil = require("../utils/NumberUtil");

var _BasicEditTable = _interopRequireDefault(require("./BasicEditTable"));
var _BasicTable = _interopRequireDefault(require("./BasicTable"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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); }

@@ -132,6 +136,6 @@

//初始化表格数据
//const tableData = data[tableName];
//配置rowSelection
var tableData = data[tableName]; //配置rowSelection
var rowSelection = {};

@@ -182,3 +186,3 @@ var selectionMode = addition.selectionMode;

if (selectionMode == 'checkbox' || selectionMode == 'radio') {
if (tableData && tableData.length > 0) {
if (data[tableName] && data[tableName].length > 0) {
var rowKeyColumnDataIsExist = false;

@@ -188,6 +192,6 @@ var resultRowKey = 'key';

if (rowKey) {
rowKeyColumnDataIsExist = tableData[0][rowKey] != undefined;
rowKeyColumnDataIsExist = data[tableName][0][rowKey] != undefined;
resultRowKey = rowKey;
} else {
rowKeyColumnDataIsExist = tableData[0]['key'] != undefined;
rowKeyColumnDataIsExist = data[tableName][0]['key'] != undefined;
}

@@ -361,3 +365,3 @@

if (type == 'BasicTable') {
return /*#__PURE__*/_react["default"].createElement(_dwMxTable.BasicTable, _extends({
return /*#__PURE__*/_react["default"].createElement(_BasicTable["default"], _extends({
id: tableName,

@@ -367,3 +371,3 @@ tableNumber: tableNumber,

}, rowSelection, {
dataSource: tableData
dataSource: data[tableName]
}, properties, rowKey, {

@@ -379,3 +383,3 @@ onRow: onRowEvent,

// 编辑表格才有的事件
return /*#__PURE__*/_react["default"].createElement(_dwMxTable.BasicEditTable, _extends({
return /*#__PURE__*/_react["default"].createElement(_BasicEditTable["default"], _extends({
id: tableName,

@@ -385,3 +389,3 @@ tableNumber: tableNumber,

}, rowSelection, {
dataSource: tableData
dataSource: data[tableName]
}, properties, rowKey, {

@@ -392,7 +396,12 @@ onRow: onRowEvent,

columns: columns,
getChildValues: function getChildValues() {},
getChildValues: function getChildValues(currentData) {
var newData = _lodash["default"].cloneDeep(data);
newData[tableName] = currentData;
setData(newData);
},
ref: tableRef,
summary: summaryFn
}, divCell));
}));
}
}
{
"name": "sz-mx-cabin",
"version": "0.0.1",
"version": "0.0.2",
"description": "reactCabin",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc