Skip to content

Commit

Permalink
Merge pull request alibaba#849 from mylesshie/feature/add-layoutwidge…
Browse files Browse the repository at this point in the history
…ts-props

feat: 增加自定义layout组件的接口
  • Loading branch information
siyi98 authored Aug 6, 2022
2 parents f39ad46 + d788a3b commit 6af45bc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const RenderList = ({
displayType,
}) => {
const { formData, flatten } = useStore();
const { onItemChange, removeTouched, methods } = useTools();
const { onItemChange, removeTouched, methods, layoutWidgets } = useTools();

const { props = {} } = schema;

Expand Down Expand Up @@ -148,6 +148,11 @@ const RenderList = ({
getFieldsProps,
};

if (layoutWidgets && layoutWidgets[renderWidget]) {
const Component = layoutWidgets[renderWidget];
return <Component {...displayProps}/>
}

switch (renderWidget) {
case 'list1':
case 'simpleList':
Expand Down
2 changes: 2 additions & 0 deletions packages/form-render/src/form-render-core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export { defaultMapping as mapping };
function App({
id,
widgets,
layoutWidgets,
mapping,
form,
className,
Expand Down Expand Up @@ -219,6 +220,7 @@ function App({
const tools = useMemo(
() => ({
widgets,
layoutWidgets,
mapping: { ...defaultMapping, ...mapping },
onValuesChange,
renderTitle,
Expand Down
2 changes: 2 additions & 0 deletions packages/form-render/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ export interface FRProps {
onValuesChange?: (changedValues: any, formData: any) => void;
/** 隐藏的数据是否去掉,默认不去掉(false) */
removeHiddenData?: boolean;
/** 配置自定义layout组件 */
layoutWidgets?: any;
}

declare const FR: React.FC<FRProps>;
Expand Down

0 comments on commit 6af45bc

Please sign in to comment.