refactor: fix lint error

This commit is contained in:
Rairn 2023-04-22 12:35:17 +08:00
parent 4c232980b5
commit 7b9bfa116f

View File

@ -46,7 +46,6 @@ import { getTargetKey } from '../schema-component/antd/association-filter/utilts
import { useSchemaTemplateManager } from '../schema-templates';
import { useBlockTemplateContext } from '../schema-templates/BlockTemplate';
import { FormDataTemplates } from './DataTemplates';
import { EnableChildCollections } from './EnableChildCollections';
import { FormLinkageRules } from './LinkageRules';
import { useLinkageCollectionFieldOptions } from './LinkageRules/action-hooks';
@ -144,7 +143,7 @@ export const SchemaSettings: React.FC<SchemaSettingsProps> & SchemaSettingsNeste
return DropdownMenu;
};
SchemaSettings.Template = (props) => {
SchemaSettings.Template = function Template(props) {
const { componentName, collectionName, resourceName } = props;
const { t } = useTranslation();
const { getCollection } = useCollectionManager();
@ -264,7 +263,7 @@ const findBlockTemplateSchema = (fieldSchema) => {
}, null);
};
SchemaSettings.FormItemTemplate = (props) => {
SchemaSettings.FormItemTemplate = function FormItemTemplate(props) {
const { insertAdjacentPosition = 'afterBegin', componentName, collectionName, resourceName } = props;
const { t } = useTranslation();
const compile = useCompile();
@ -381,7 +380,7 @@ SchemaSettings.FormItemTemplate = (props) => {
);
};
SchemaSettings.Item = (props) => {
SchemaSettings.Item = function Item(props) {
let { eventKey } = props;
const key = useMemo(() => uid(), []);
return (
@ -413,7 +412,7 @@ SchemaSettings.Divider = (props) => {
return <Menu.Divider {...props} />;
};
SchemaSettings.Remove = (props: any) => {
SchemaSettings.Remove = function Remove(props: any) {
const { confirm, removeParentsIfNoChildren, breakRemoveOn } = props;
const { dn, template } = useSchemaSettings();
const { t } = useTranslation();
@ -453,7 +452,10 @@ SchemaSettings.Remove = (props: any) => {
);
};
SchemaSettings.ConnectDataBlocks = (props: { type: FilterBlockType; emptyDescription?: string }) => {
SchemaSettings.ConnectDataBlocks = function ConnectDataBlocks(props: {
type: FilterBlockType;
emptyDescription?: string;
}) {
const { type, emptyDescription } = props;
const fieldSchema = useFieldSchema();
const { dn } = useDesignable();
@ -574,7 +576,7 @@ SchemaSettings.ConnectDataBlocks = (props: { type: FilterBlockType; emptyDescrip
);
};
SchemaSettings.SelectItem = (props) => {
SchemaSettings.SelectItem = function SelectItem(props) {
const { title, options, value, onChange, openOnHover, onClick: _onClick, ...others } = props;
const [open, setOpen] = useState(false);
@ -582,11 +584,12 @@ SchemaSettings.SelectItem = (props) => {
setOpen(false);
_onClick?.(...args);
};
const onMouseEnter = useCallback(() => setOpen(true), []);
// 鼠标 hover 时,打开下拉框
const moreProps = openOnHover
? {
onMouseEnter: useCallback(() => setOpen(true), []),
onMouseEnter,
open,
}
: {};
@ -633,7 +636,7 @@ interface SwitchItemProps extends Omit<MenuItemProps, 'onChange'> {
onChange?: (v: boolean) => void;
}
SchemaSettings.SwitchItem = (props) => {
SchemaSettings.SwitchItem = function SwitchItem(props) {
const { title, onChange, ...others } = props;
const [checked, setChecked] = useState(!!props.checked);
return (
@ -652,7 +655,7 @@ SchemaSettings.SwitchItem = (props) => {
);
};
SchemaSettings.PopupItem = (props) => {
SchemaSettings.PopupItem = function PopupItem(props) {
const { schema, ...others } = props;
const [visible, setVisible] = useState(false);
const ctx = useContext(SchemaSettingsContext);
@ -766,7 +769,7 @@ SchemaSettings.ActionModalItem = React.memo((props: any) => {
);
});
SchemaSettings.ModalItem = (props) => {
SchemaSettings.ModalItem = function ModalItem(props) {
const {
hidden,
title,
@ -818,7 +821,7 @@ SchemaSettings.ModalItem = (props) => {
);
};
SchemaSettings.BlockTitleItem = () => {
SchemaSettings.BlockTitleItem = function BlockTitleItem() {
const field = useField();
const fieldSchema = useFieldSchema();
const { dn } = useDesignable();
@ -859,7 +862,7 @@ SchemaSettings.BlockTitleItem = () => {
);
};
SchemaSettings.DefaultSortingRules = (props) => {
SchemaSettings.DefaultSortingRules = function DefaultSortingRules(props) {
const { sort, sortFields, onSubmit } = props;
const { t } = useTranslation();
@ -943,7 +946,7 @@ SchemaSettings.DefaultSortingRules = (props) => {
);
};
SchemaSettings.LinkageRules = (props) => {
SchemaSettings.LinkageRules = function LinkageRules(props) {
const { collectionName } = props;
const fieldSchema = useFieldSchema();
const { dn } = useDesignable();
@ -1009,7 +1012,7 @@ export const useDataTemplates = () => {
};
};
SchemaSettings.DataTemplates = (props) => {
SchemaSettings.DataTemplates = function DataTemplates(props) {
const { collectionName } = props;
const fieldSchema = useFieldSchema();
const { dn } = useDesignable();
@ -1057,7 +1060,7 @@ SchemaSettings.DataTemplates = (props) => {
);
};
SchemaSettings.EnableChildCollections = (props) => {
SchemaSettings.EnableChildCollections = function EnableChildCollections(props) {
const { collectionName } = props;
const fieldSchema = useFieldSchema();
const { dn } = useDesignable();