@alifd/adaptor-render
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -24,2 +24,3 @@ import React from 'react'; | ||
height = _ref2.height; | ||
console.log(node); | ||
var demoNode = renderAdaptor(node.adaptor, node.props || {}, themeId); | ||
@@ -26,0 +27,0 @@ return React.createElement("div", { |
@@ -128,2 +128,18 @@ import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
if (!Adaptor) return []; | ||
if (Adaptor.demos && Adaptor.demos.length > 0) { | ||
return Adaptor.demos.map(function () { | ||
var demo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { | ||
node: { | ||
props: {} | ||
} | ||
}; | ||
return _objectSpread({}, demo, { | ||
node: _objectSpread({}, demo.node || {}, { | ||
props: _objectSpread({}, getDefaultProps(Adaptor, demo.node.props.shape || 'normal'), demo.node.props || {}) | ||
}) | ||
}); | ||
}); | ||
} | ||
return Adaptor.shape.map(function (_ref3) { | ||
@@ -138,3 +154,3 @@ var value = _ref3.value; | ||
if (levelProp.options && levelProp.options.find(function (_ref4) { | ||
if (levelProp && levelProp.options && levelProp.options.find(function (_ref4) { | ||
var v = _ref4.value; | ||
@@ -146,3 +162,3 @@ return v === 'primary'; | ||
return Adaptor.demoOptions({ | ||
var demo = { | ||
node: { | ||
@@ -152,3 +168,4 @@ adaptor: name, | ||
} | ||
}); | ||
}; | ||
return Adaptor.demoOptions ? Adaptor.demoOptions(demo) : demo; | ||
}); | ||
@@ -155,0 +172,0 @@ }; |
{ | ||
"name": "@alifd/adaptor-render", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"main": "umd/react/adaptor-render.development.js", | ||
@@ -5,0 +5,0 @@ "unpkg": "umd/react/adaptor-render.production.min.js", |
@@ -6,2 +6,3 @@ import React from 'react'; | ||
import Adaptors from '@alifd/next/dist/adaptor.min.js'; | ||
import init from './react/init'; | ||
// import '@alifd/next/dist/next.min.css'; | ||
@@ -42,5 +43,12 @@ | ||
AdaptorRender.init([ | ||
]); | ||
// init([ | ||
// { | ||
// "name": "layout-shell", | ||
// "script": "https://unpkg.alibaba-inc.com/@alife/whalemod-layout-shell@1.0.9/build/adaptor/adaptor.js", | ||
// "stylesheet": "https://theme-fusion.alibaba-inc.com/themes/204/biz-components/compile?name=layout-shell&version=1.0.9&scssUrl=https://unpkg.alibaba-inc.com/@alife/whalemod-layout-shell@1.0.10/build/index.scss" | ||
// } | ||
// ], () => {}, '2233', ['Button'], 'expanded') | ||
AdaptorRender.init([]); | ||
window.AdaptorRender = AdaptorRender; |
@@ -17,2 +17,3 @@ import React from 'react'; | ||
demos.map(({ node, background, height }) => { | ||
console.log(node); | ||
const demoNode = renderAdaptor(node.adaptor, node.props || {}, themeId); | ||
@@ -19,0 +20,0 @@ return ( |
@@ -123,2 +123,17 @@ import { normalizeAdaptor, generateDemos, getDefaultProps, STATE_MARK, Types, findProp } from '@alifd/adaptor-helper'; | ||
if (Adaptor.demos && Adaptor.demos.length > 0) { | ||
return Adaptor.demos.map((demo = { node: { props: {} } }) => { | ||
return { | ||
...demo, | ||
node: { | ||
...(demo.node || {}), | ||
props: { | ||
...(getDefaultProps(Adaptor, demo.node.props.shape || 'normal')), | ||
...(demo.node.props || {}), | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
return Adaptor.shape.map(({ value }) => { | ||
@@ -128,7 +143,7 @@ const defaultProps = getDefaultProps(Adaptor, value); | ||
const levelProp = findProp('level', props); | ||
if (levelProp.options && levelProp.options.find(({ value: v }) => v === 'primary')) { | ||
if (levelProp && levelProp.options && levelProp.options.find(({ value: v }) => v === 'primary')) { | ||
defaultProps.level = 'primary'; | ||
} | ||
return Adaptor.demoOptions({ | ||
const demo = { | ||
node: { | ||
@@ -138,3 +153,5 @@ adaptor: name, | ||
} | ||
}); | ||
}; | ||
return Adaptor.demoOptions ? Adaptor.demoOptions(demo) : demo; | ||
}); | ||
@@ -141,0 +158,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
820050
15976