import { ArrayItems } from '@formily/antd'; import type { ISchema } from '@formily/react'; import { useField, useFieldSchema } from '@formily/react'; import { GeneralSchemaDesigner, SchemaSettings, useDesignable } from '@nocobase/client'; import React, { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useShared } from './useShared'; export const ImportDesigner = () => { const field = useField(); const fieldSchema = useFieldSchema(); const { t } = useTranslation(); const { dn } = useDesignable(); const [schema, setSchema] = useState(); const { importSettingsSchema } = useShared(); useEffect(() => { setSchema(importSettingsSchema); }, [field.address, fieldSchema?.['x-action-settings']?.['importSettings']]); return ( { if (title) { fieldSchema.title = title; field.title = title; field.componentProps.icon = icon; field.componentProps.danger = type === 'danger'; field.componentProps.type = type; fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {}; fieldSchema['x-component-props'].icon = icon; fieldSchema['x-component-props'].danger = type === 'danger'; fieldSchema['x-component-props'].type = type; dn.emit('patch', { schema: { ['x-uid']: fieldSchema['x-uid'], title, 'x-component-props': { ...fieldSchema['x-component-props'], }, }, }); dn.refresh(); } }} /> { const columns = importColumns ?.filter((fieldItem) => fieldItem?.dataIndex?.length) .map((item) => ({ dataIndex: item.dataIndex.map((di) => di.name ?? di), title: item.title, })); fieldSchema['x-action-settings']['importSettings'] = { importColumns: columns, explain }; dn.emit('patch', { schema: { ['x-uid']: fieldSchema['x-uid'], 'x-action-settings': fieldSchema['x-action-settings'], }, }); dn.refresh(); }} /> { return s['x-component'] === 'Space' || s['x-component'].endsWith('ActionBar'); }} confirm={{ title: t('Delete action'), }} /> ); };