chore: checkboxes 显示 loading 当选项在加载过程中 (#9416)

This commit is contained in:
liaoxuezhi 2024-01-12 14:32:27 +08:00 committed by GitHub
parent e868976c33
commit 062872698f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,7 @@ import {
flattenTreeWithLeafNodes
} from 'amis-core';
import type {ActionObject, Api, OptionsControlProps, Option} from 'amis-core';
import {Checkbox, Icon} from 'amis-ui';
import {Checkbox, Icon, Spinner} from 'amis-ui';
import {FormOptionsSchema} from '../../Schema';
import {supportStatic} from './StaticHoc';
@ -349,7 +349,9 @@ export default class CheckboxesControl extends React.Component<
addApi,
createBtnLabel,
translate: __,
optionType
optionType,
loading,
loadingConfig
} = this.props;
let body: Array<React.ReactNode> = [];
@ -385,10 +387,20 @@ export default class CheckboxesControl extends React.Component<
<div className={cx(`CheckboxesControl`, className)} ref="checkboxRef">
{body && body.length ? (
body
) : (
) : loading ? null : (
<span className={`Form-placeholder`}>{__(placeholder)}</span>
)}
{loading ? (
<Spinner
show
icon="reload"
size="sm"
spinnerClassName={cx('Checkboxes-spinner')}
loadingConfig={loadingConfig}
/>
) : null}
{(creatable || addApi) && !disabled ? (
<a className={cx('Checkboxes-addBtn')} onClick={this.handleAddClick}>
<Icon icon="plus" className="icon" />