Skip to content

Commit

Permalink
chore: checkboxes 显示 loading 当选项在加载过程中 (baidu#9416)
Browse files Browse the repository at this point in the history
  • Loading branch information
2betop committed Jan 12, 2024
1 parent e868976 commit 0628726
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/amis/src/renderers/Form/Checkboxes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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> = [];
Expand Down Expand Up @@ -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" />
Expand Down

0 comments on commit 0628726

Please sign in to comment.