fix: record picker should support popupsize setting (#3299)

This commit is contained in:
katherinehhh 2024-01-02 15:48:42 +08:00 committed by GitHub
parent 5de28cd4c4
commit e8759588b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 31 deletions

View File

@ -62,7 +62,7 @@ const useTableSelectorProps = () => {
export const InternalPicker = observer( export const InternalPicker = observer(
(props: any) => { (props: any) => {
const { value, multiple, onChange, quickUpload, selectFile, shouldMountElement, ...others } = props; const { value, multiple, openSize, onChange, quickUpload, selectFile, shouldMountElement, ...others } = props;
const field: any = useField(); const field: any = useField();
const fieldNames = useFieldNames(props); const fieldNames = useFieldNames(props);
const [visibleSelector, setVisibleSelector] = useState(false); const [visibleSelector, setVisibleSelector] = useState(false);
@ -183,6 +183,7 @@ export const InternalPicker = observer(
</Input.Group> </Input.Group>
<ActionContextProvider <ActionContextProvider
value={{ value={{
openSize,
openMode: 'drawer', openMode: 'drawer',
visible: visibleSelector, visible: visibleSelector,
setVisible: setVisibleSelector, setVisible: setVisibleSelector,

View File

@ -349,7 +349,7 @@ export const formItemSettings = new SchemaSettings({
}, },
{ {
name: 'popupSize', name: 'popupSize',
type: 'item', type: 'select',
useComponentProps() { useComponentProps() {
const { t } = useTranslation(); const { t } = useTranslation();
const field = useField<Field>(); const field = useField<Field>();
@ -357,21 +357,15 @@ export const formItemSettings = new SchemaSettings({
const { dn } = useDesignable(); const { dn } = useDesignable();
return { return {
title: t('Popup size'), title: t('Popup size'),
children: ( options: [
<div style={{ alignItems: 'center', display: 'flex', justifyContent: 'space-between' }}>
{t('Popup size')}
<Select
bordered={false}
options={[
{ label: t('Small'), value: 'small' }, { label: t('Small'), value: 'small' },
{ label: t('Middle'), value: 'middle' }, { label: t('Middle'), value: 'middle' },
{ label: t('Large'), value: 'large' }, { label: t('Large'), value: 'large' },
]} ],
value={ value:
fieldSchema?.['x-component-props']?.['openSize'] ?? fieldSchema?.['x-component-props']?.['openSize'] ??
(fieldSchema?.['x-component-props']?.['openMode'] == 'modal' ? 'large' : 'middle') (fieldSchema?.['x-component-props']?.['openMode'] == 'modal' ? 'large' : 'middle'),
} onChange: (value) => {
onChange={(value) => {
field.componentProps.openSize = value; field.componentProps.openSize = value;
fieldSchema['x-component-props'] = field.componentProps; fieldSchema['x-component-props'] = field.componentProps;
dn.emit('patch', { dn.emit('patch', {
@ -381,11 +375,7 @@ export const formItemSettings = new SchemaSettings({
}, },
}); });
dn.refresh(); dn.refresh();
}} },
style={{ textAlign: 'right', minWidth: 100 }}
/>
</div>
),
}; };
}, },
useVisible() { useVisible() {