/** * This file is part of the NocoBase (R) project. * Copyright (c) 2020-2024 NocoBase Co., Ltd. * Authors: NocoBase Team. * * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. * For more information, please refer to: https://www.nocobase.com/agreement. */ import { ISchema, useField, useFieldSchema } from '@formily/react'; import _ from 'lodash'; import React from 'react'; import { useTranslation } from 'react-i18next'; import { SchemaSettingsModalItem } from './SchemaSettings'; import { useDesignable } from '../schema-component/hooks/useDesignable'; export const Layout = { VERTICAL: 'vertical', HORIZONTAL: 'horizontal', }; export const SchemaSettingsLayoutItem = function LayoutItem() { const field = useField(); const fieldSchema = useFieldSchema(); const { dn } = useDesignable(); const { t } = useTranslation(); return ( { const componentProps = fieldSchema['x-component-props'] || {}; componentProps.layout = layout; componentProps.labelAlign = labelAlign; componentProps.labelWidth = layout === 'horizontal' ? labelWidth : null; componentProps.labelWrap = labelWrap; fieldSchema['x-component-props'] = componentProps; field.componentProps.layout = layout; field.componentProps.labelAlign = labelAlign; field.componentProps.labelWidth = labelWidth; field.componentProps.labelWrap = labelWrap; dn.emit('patch', { schema: { ['x-uid']: fieldSchema['x-uid'], 'x-component-props': fieldSchema['x-component-props'], }, }); dn.refresh(); }} /> ); };