@choerodon/master
Version:
A package of Master for Choerodon platform.
43 lines (35 loc) • 989 B
JavaScript
import React from 'react';
import { inject } from 'mobx-react';
import { observer } from 'mobx-react-lite';
export default inject('AppState')(observer(function (props) {
var map = props.map,
children = props.children,
AppState = props.AppState;
var theme;
switch (AppState.getCurrentTheme) {
case '':
theme = 'origin';
break;
case 'theme4':
theme = 'theme4';
break;
default:
theme = 'origin';
break;
}
var renderParams = function renderParams() {
var result = {};
if (map && map.key) {
Object.entries(map.key).forEach(function (item) {
result[item[0]] = item[1][theme];
});
}
if (map && map.style) {
result.styles = (map === null || map === void 0 ? void 0 : map.style[AppState.getCurrentTheme]) || null;
}
return result;
};
return React.Children.map(children, function (child) {
return /*#__PURE__*/React.cloneElement(child, renderParams());
});
}));