diff --git a/packages/amis-core/src/renderers/Item.tsx b/packages/amis-core/src/renderers/Item.tsx index 53975e25b..c6e51e6c4 100644 --- a/packages/amis-core/src/renderers/Item.tsx +++ b/packages/amis-core/src/renderers/Item.tsx @@ -1270,6 +1270,7 @@ export class FormItemWrap extends React.Component { return (
{ return (
{ return (
{ return (
{ props.formLabelAlign; const labelWidth = props.labelWidth || props.formLabelWidth; description = description || desc; - return (
; testIdBuilder?: TestIdBuilder; + dataName?: string; } export class Checkbox extends React.Component { @@ -99,6 +100,7 @@ export class Checkbox extends React.Component { })} data-role="checkbox" {...testIdBuilder?.getTestId()} + data-amis-name={this.props.dataName} > JSX.Element; + dataName?: string; } export interface InputBoxState { @@ -91,6 +92,7 @@ export class InputBox extends React.Component { mobileUI, testIdBuilder, inputRender, + dataName, ...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-amis-name={dataName} > {result} diff --git a/packages/amis-ui/src/components/Select.tsx b/packages/amis-ui/src/components/Select.tsx index 08ebb3669..606c7684d 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; + + dataName?: string; } interface SelectState { @@ -1375,6 +1377,7 @@ export class Select extends React.Component { }, className )} + data-amis-name={this.props.dataName} >
{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 c702cd921..991e8fee4 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; + dataName?: string; onChange: (value: JSONSchema) => void; types: Array<{ label: string; @@ -175,6 +176,7 @@ export class SchemaEditorItemCommon< simpleValue mobileUI={mobileUI} popOverContainer={popOverContainer} + dataName={onRequiredChange ? `${this.props.dataName}-type` : ''} /> ) : null} @@ -185,6 +187,7 @@ export class SchemaEditorItemCommon< value={required} onChange={onRequiredChange} disabled={disabled} + dataName={`${this.props.dataName}-required`} /> ) : null} @@ -371,6 +374,7 @@ export class SchemaEditorItemCommon< className={cx('SchemaEditorItem', { 'SchemaEditorItem--mini': mini })} + data-amis-name={this.props.dataName} > {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 f4608a153..e22f60945 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, + dataName } = this.props; const members = this.state.members; @@ -299,74 +300,88 @@ export class SchemaEditorItemObject extends SchemaEditorItemCommon< })} > {members.length ? ( - members.map((member, index) => ( - - + members.map((member, index) => { + const memberKey = dataName + ? dataName + '-' + 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} - /> - )) + + + ) + } + 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 +507,7 @@ export class SchemaEditorItemObject extends SchemaEditorItemCommon< 'is-collapsed': this.state.collapsed, 'SchemaEditorItem--mini': mini })} + data-amis-name={this.props.dataName} > {showInfo !== false ? ( <> diff --git a/packages/amis/__tests__/event-action/renderers/__snapshots__/page.test.tsx.snap b/packages/amis/__tests__/event-action/renderers/__snapshots__/page.test.tsx.snap index c957494cd..cf4a937c9 100644 --- a/packages/amis/__tests__/event-action/renderers/__snapshots__/page.test.tsx.snap +++ b/packages/amis/__tests__/event-action/renderers/__snapshots__/page.test.tsx.snap @@ -25,6 +25,7 @@ exports[`doAction:page reload 1`] = `