Skip to content

Commit

Permalink
feat: labelWidget、descWidget 增加 addons 对象
Browse files Browse the repository at this point in the history
  • Loading branch information
lhbxs committed Nov 2, 2023
1 parent 497ddef commit 4933b25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions packages/form-render/src/render-core/FieldItem/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default (props: any) => {
}

// Render field components
let label = getLabel(schema, displayType, widgets);
let label = getLabel(schema, displayType, widgets, fieldProps.addons);
let noStyle = getValueFromKey('noStyle');

const span = getColSpan(formCtx, upperCtx, schema);
Expand All @@ -144,7 +144,7 @@ export default (props: any) => {
const maxWidth = getValueFromKey('maxWidth');
const { labelCol, fieldCol } = getFormItemLayout(Math.floor(24 / span * 1), schema, { displayType, labelWidth, _labelCol, _fieldCol });
const valuePropName = schema.valuePropName || valuePropNameMap[widgetName] || undefined;
debugger;

if (readOnly) {
fieldProps.readOnly = readOnly;
}
Expand Down Expand Up @@ -172,10 +172,8 @@ export default (props: any) => {
}

const initialValue = schema.default ?? schema.defaultValue;
debugger;
const classRest = { 'fr-hide-label': label === 'fr-hide-label', 'fr-inline-field': inlineSelf, 'fr-field-visibility': !visible, [schema.className] : !! schema.className };


const formItem = (
<Form.Item
className={classnames('fr-field', classRest)}
Expand Down
6 changes: 3 additions & 3 deletions packages/form-render/src/render-core/FieldItem/module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ export const getPath = (path: any) => {
return path;
};

export const getLabel = (schema: any, displayType: string, widgets: any) => {
export const getLabel = (schema: any, displayType: string, widgets: any, addons: any) => {
const { title, description, descWidget, labelWidget } = schema;

const LabelNode = widgets[labelWidget];

if (LabelNode) {
return <LabelNode schema={schema} />
return <LabelNode schema={schema} addons={addons} />
}

if ((!description && !descWidget)) {
Expand All @@ -113,7 +113,7 @@ export const getLabel = (schema: any, displayType: string, widgets: any) => {
const RenderDesc = () => {
const Widget = widgets[descWidget];
if (Widget) {
return <Widget schema={schema} />;
return <Widget schema={schema} addons={addons} />;
}

if (description) {
Expand Down

0 comments on commit 4933b25

Please sign in to comment.