diff --git a/packages/amis-core/src/renderers/Item.tsx b/packages/amis-core/src/renderers/Item.tsx index 53975e25b99..249a3835486 100644 --- a/packages/amis-core/src/renderers/Item.tsx +++ b/packages/amis-core/src/renderers/Item.tsx @@ -1266,10 +1266,13 @@ export class FormItemWrap extends React.Component { (props.labelAlign !== 'inherit' && props.labelAlign) || props.formLabelAlign; const labelWidth = props.labelWidth || props.formLabelWidth; - + const dataId = props.name + ? `amis-form-item-${props.name?.split('.').pop()}` + : undefined; return (
{ } = props; description = description || desc; - + const dataId = props.name + ? `amis-form-item-${props.name?.split('.').pop()}` + : undefined; return (
{ const labelWidth = props.labelWidth || props.formLabelWidth; description = description || desc; + const dataId = props.name + ? `amis-form-item-${props.name?.split('.').pop()}` + : undefined; return (
{ } = props; description = description || desc; const labelWidth = props.labelWidth || props.formLabelWidth; + const dataId = props.name + ? `amis-form-item-${props.name?.split('.').pop()}` + : undefined; return (
{ const labelWidth = props.labelWidth || props.formLabelWidth; description = description || desc; + const dataId = props.name + ? `amis-form-item-${props.name?.split('.').pop()}` + : undefined; return (
; testIdBuilder?: TestIdBuilder; + dataId?: string; } export class Checkbox extends React.Component { @@ -99,6 +100,7 @@ export class Checkbox extends React.Component { })} data-role="checkbox" {...testIdBuilder?.getTestId()} + data-id={this.props.dataId} > JSX.Element; + dataId?: string; } export interface InputBoxState { @@ -91,6 +92,7 @@ export class InputBox extends React.Component { mobileUI, testIdBuilder, inputRender, + dataId, ...rest } = this.props; const isFocused = this.state.isFocused; @@ -106,6 +108,7 @@ export class InputBox extends React.Component { [`InputBox--border${ucFirst(borderMode)}`]: borderMode })} onClick={onClick} + data-id={dataId} > {result} diff --git a/packages/amis-ui/src/components/Select.tsx b/packages/amis-ui/src/components/Select.tsx index 08ebb366942..9d0e4505c3a 100644 --- a/packages/amis-ui/src/components/Select.tsx +++ b/packages/amis-ui/src/components/Select.tsx @@ -401,6 +401,8 @@ export interface SelectProps * 检索函数 */ filterOption?: FilterOption; + + dataId?: string; } interface SelectState { @@ -1375,6 +1377,7 @@ export class Select extends React.Component { }, className )} + data-id={this.props.dataId} >
{showInfo !== false ? ( <> diff --git a/packages/amis-ui/src/components/schema-editor/Common.tsx b/packages/amis-ui/src/components/schema-editor/Common.tsx index c702cd92103..5c81a1a83ab 100644 --- a/packages/amis-ui/src/components/schema-editor/Common.tsx +++ b/packages/amis-ui/src/components/schema-editor/Common.tsx @@ -27,6 +27,7 @@ export type SchemaEditorItemPlaceholder = Partial< export interface SchemaEditorItemCommonProps extends LocaleProps, ThemeProps { label?: string; value?: JSONSchema; + dataId?: string; onChange: (value: JSONSchema) => void; types: Array<{ label: string; @@ -141,7 +142,8 @@ export class SchemaEditorItemCommon< mobileUI, mini, formPrefixRender, - formAffixRender + formAffixRender, + showInfo } = this.props; return ( @@ -175,6 +177,11 @@ export class SchemaEditorItemCommon< simpleValue mobileUI={mobileUI} popOverContainer={popOverContainer} + dataId={ + showInfo === false + ? `amis-schema-editor-${this.props.dataId}-type` + : '' + } /> ) : null} @@ -185,6 +192,7 @@ export class SchemaEditorItemCommon< value={required} onChange={onRequiredChange} disabled={disabled} + dataId={`amis-schema-editor-${this.props.dataId}-required`} /> ) : null} @@ -371,6 +379,7 @@ export class SchemaEditorItemCommon< className={cx('SchemaEditorItem', { 'SchemaEditorItem--mini': mini })} + data-id={'amis-schema-editor-' + this.props.dataId} > {this.renderCommon()}
diff --git a/packages/amis-ui/src/components/schema-editor/Object.tsx b/packages/amis-ui/src/components/schema-editor/Object.tsx index f4608a153f6..8cc2ac49623 100644 --- a/packages/amis-ui/src/components/schema-editor/Object.tsx +++ b/packages/amis-ui/src/components/schema-editor/Object.tsx @@ -288,7 +288,8 @@ export class SchemaEditorItemObject extends SchemaEditorItemCommon< placeholder, mobileUI, mini, - addButtonText + addButtonText, + dataId } = this.props; const members = this.state.members; @@ -299,74 +300,86 @@ export class SchemaEditorItemObject extends SchemaEditorItemCommon< })} > {members.length ? ( - members.map((member, index) => ( - - - - - - ) - } - affix={ - - } - value={ - mini - ? ({ - ...member.schema, - key: member.key, - isRequired: member.required - } as any) - : member.schema - } - onChange={this.handlePropChange.bind(this, index)} - onFormConfirm={this.handleEditProppertyConfirm.bind(this, index)} - renderExtraProps={renderExtraProps} - renderModalProps={renderModalProps} - locale={locale} - translate={__} - classnames={cx} - classPrefix={classPrefix} - disabled={disabled || !!value?.$ref} - required={member.required} - onRequiredChange={this.handlePropRequiredChange.bind(this, index)} - placeholder={placeholder} - formPrefixRender={this.renderFormPrefix} - /> - )) + members.map((member, index) => { + const memberKey = dataId ? dataId + '-' + member.key : member.key; + return ( + + + + + + ) + } + affix={ + + } + value={ + mini + ? ({ + ...member.schema, + key: member.key, + isRequired: member.required + } as any) + : member.schema + } + onChange={this.handlePropChange.bind(this, index)} + onFormConfirm={this.handleEditProppertyConfirm.bind( + this, + index + )} + renderExtraProps={renderExtraProps} + renderModalProps={renderModalProps} + locale={locale} + translate={__} + classnames={cx} + classPrefix={classPrefix} + disabled={disabled || !!value?.$ref} + required={member.required} + onRequiredChange={this.handlePropRequiredChange.bind( + this, + index + )} + placeholder={placeholder} + formPrefixRender={this.renderFormPrefix} + /> + ); + }) ) : (
{__(placeholder?.empty ?? '')} @@ -492,6 +505,7 @@ export class SchemaEditorItemObject extends SchemaEditorItemCommon< 'is-collapsed': this.state.collapsed, 'SchemaEditorItem--mini': mini })} + data-id={'amis-schema-editor-' + this.props.dataId} > {showInfo !== false ? ( <>