fix: design menu not show (#1083)
Reviewed-on: daoyoucloud/tachybase#1083
This commit is contained in:
parent
53cd459654
commit
23283af669
@ -1,16 +1,17 @@
|
|||||||
import { createForm } from '@tachybase/schema';
|
|
||||||
import { RecursionField, Schema, useField, useFieldSchema } from '@tachybase/schema';
|
|
||||||
import { Spin } from 'antd';
|
|
||||||
import React, { createContext, useContext, useEffect, useMemo, useRef } from 'react';
|
import React, { createContext, useContext, useEffect, useMemo, useRef } from 'react';
|
||||||
|
import { createForm, RecursionField, Schema, useField, useFieldSchema } from '@tachybase/schema';
|
||||||
|
|
||||||
|
import { Spin } from 'antd';
|
||||||
|
|
||||||
|
import { withDynamicSchemaProps } from '../application/hoc/withDynamicSchemaProps';
|
||||||
import { useCollection_deprecated } from '../collection-manager';
|
import { useCollection_deprecated } from '../collection-manager';
|
||||||
import { CollectionRecord, useCollectionParentRecordData, useCollectionRecord } from '../data-source';
|
import { CollectionRecord, useCollectionParentRecordData, useCollectionRecord } from '../data-source';
|
||||||
import { RecordProvider, useRecord } from '../record-provider';
|
import { RecordProvider, useRecord } from '../record-provider';
|
||||||
import { useActionContext, useDesignable } from '../schema-component';
|
import { useActionContext, useDesignable } from '../schema-component';
|
||||||
import { Templates as DataTemplateSelect } from '../schema-component/antd/form-v2/Templates';
|
import { Templates as DataTemplateSelect } from '../schema-component/antd/form-v2/Templates';
|
||||||
import { BlockProvider, useBlockRequestContext } from './BlockProvider';
|
import { BlockProvider, useBlockRequestContext } from './BlockProvider';
|
||||||
import { TemplateBlockProvider } from './TemplateBlockProvider';
|
|
||||||
import { FormActiveFieldsProvider } from './hooks/useFormActiveFields';
|
import { FormActiveFieldsProvider } from './hooks/useFormActiveFields';
|
||||||
import { withDynamicSchemaProps } from '../application/hoc/withDynamicSchemaProps';
|
import { TemplateBlockProvider } from './TemplateBlockProvider';
|
||||||
|
|
||||||
export const FormBlockContext = createContext<{
|
export const FormBlockContext = createContext<{
|
||||||
form?: any;
|
form?: any;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Field } from '@tachybase/schema';
|
|
||||||
import { connect, useField, useFieldSchema } from '@tachybase/schema';
|
|
||||||
import { merge } from '@tachybase/schema';
|
|
||||||
import { concat } from 'lodash';
|
|
||||||
import React, { useEffect, useMemo } from 'react';
|
import React, { useEffect, useMemo } from 'react';
|
||||||
|
import { connect, Field, merge, useField, useFieldSchema } from '@tachybase/schema';
|
||||||
|
|
||||||
|
import { concat } from 'lodash';
|
||||||
|
|
||||||
import { useFormBlockContext } from '../../block-provider/FormBlockProvider';
|
import { useFormBlockContext } from '../../block-provider/FormBlockProvider';
|
||||||
import { useCompile, useComponent } from '../../schema-component';
|
import { useCompile, useComponent } from '../../schema-component';
|
||||||
import { useIsAllowToSetDefaultValue } from '../../schema-settings/hooks/useIsAllowToSetDefaultValue';
|
import { useIsAllowToSetDefaultValue } from '../../schema-settings/hooks/useIsAllowToSetDefaultValue';
|
||||||
@ -14,17 +14,16 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: 初步适配
|
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export const CollectionFieldInternalField: React.FC = (props: Props) => {
|
export const CollectionFieldInternalField = (props: Props) => {
|
||||||
const { component } = props;
|
const { component } = props;
|
||||||
const compile = useCompile();
|
const compile = useCompile();
|
||||||
const field = useField<Field>();
|
const field = useField<Field>();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const { uiSchema: uiSchemaOrigin, defaultValue } = useCollectionField();
|
const { uiSchema: uiSchemaOrigin, defaultValue } = useCollectionField();
|
||||||
const { isAllowToSetDefaultValue } = useIsAllowToSetDefaultValue();
|
const { isAllowToSetDefaultValue } = useIsAllowToSetDefaultValue();
|
||||||
const uiSchema = useMemo(() => compile(uiSchemaOrigin), [JSON.stringify(uiSchemaOrigin)]);
|
const uiSchema = compile(uiSchemaOrigin);
|
||||||
const Component = useComponent(component || uiSchema?.['x-component'] || 'Input');
|
const Component = useComponent(component || uiSchema?.['x-component'] || 'Input');
|
||||||
const setFieldProps = (key, value) => {
|
const setFieldProps = (key, value) => {
|
||||||
field[key] = typeof field[key] === 'undefined' ? value : field[key];
|
field[key] = typeof field[key] === 'undefined' ? value : field[key];
|
||||||
@ -42,7 +41,6 @@ export const CollectionFieldInternalField: React.FC = (props: Props) => {
|
|||||||
ctx.field.added.add(fieldSchema.name);
|
ctx.field.added.add(fieldSchema.name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// TODO: 初步适配
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!uiSchema) {
|
if (!uiSchema) {
|
||||||
return;
|
return;
|
||||||
@ -71,7 +69,8 @@ export const CollectionFieldInternalField: React.FC = (props: Props) => {
|
|||||||
const originalProps = compile(uiSchema['x-component-props']) || {};
|
const originalProps = compile(uiSchema['x-component-props']) || {};
|
||||||
const componentProps = merge(originalProps, field.componentProps || {});
|
const componentProps = merge(originalProps, field.componentProps || {});
|
||||||
field.component = [Component, componentProps];
|
field.component = [Component, componentProps];
|
||||||
}, [JSON.stringify(uiSchema)]);
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [uiSchema]);
|
||||||
if (!uiSchema) {
|
if (!uiSchema) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import React, { FC, ReactNode, createContext, useContext, useMemo } from 'react';
|
import React, { createContext, FC, ReactNode, useContext, useMemo } from 'react';
|
||||||
|
|
||||||
import { useFieldSchema, type SchemaKey } from '@tachybase/schema';
|
import { useFieldSchema, type SchemaKey } from '@tachybase/schema';
|
||||||
import type { CollectionFieldOptions } from '../collection';
|
|
||||||
|
|
||||||
import { useCollection, useCollectionManager } from '../collection';
|
import { useCollection, useCollectionManager, type CollectionFieldOptions } from '../collection';
|
||||||
import { CollectionDeletedPlaceholder } from '../components/CollectionDeletedPlaceholder';
|
import { CollectionDeletedPlaceholder } from '../components/CollectionDeletedPlaceholder';
|
||||||
|
|
||||||
export const CollectionFieldContext = createContext<CollectionFieldOptions>(null);
|
export const CollectionFieldContext = createContext<CollectionFieldOptions>(null);
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { Form } from '@tachybase/schema';
|
|
||||||
import { Schema, useFieldSchema } from '@tachybase/schema';
|
|
||||||
import React, { useContext, useMemo } from 'react';
|
import React, { useContext, useMemo } from 'react';
|
||||||
|
import { Form, Schema, useFieldSchema } from '@tachybase/schema';
|
||||||
|
|
||||||
import { CollectionFieldOptions_deprecated } from '../..';
|
import { CollectionFieldOptions_deprecated } from '../..';
|
||||||
import { isSystemField } from '../SchemaSettings';
|
|
||||||
import { isPatternDisabled } from '../isPatternDisabled';
|
|
||||||
import { useFormBlockContext, useFormBlockType } from '../../block-provider';
|
import { useFormBlockContext, useFormBlockType } from '../../block-provider';
|
||||||
import { useCollectionManager_deprecated } from '../../collection-manager/hooks/useCollectionManager_deprecated';
|
|
||||||
import { useCollection_deprecated } from '../../collection-manager/hooks/useCollection_deprecated';
|
import { useCollection_deprecated } from '../../collection-manager/hooks/useCollection_deprecated';
|
||||||
|
import { useCollectionManager_deprecated } from '../../collection-manager/hooks/useCollectionManager_deprecated';
|
||||||
|
import { isPatternDisabled } from '../isPatternDisabled';
|
||||||
|
import { isSystemField } from '../SchemaSettings';
|
||||||
|
|
||||||
interface DefaultValueProviderProps {
|
interface DefaultValueProviderProps {
|
||||||
isAllowToSetDefaultValue: (params: IsAllowToSetDefaultValueParams) => boolean;
|
isAllowToSetDefaultValue: (params: IsAllowToSetDefaultValueParams) => boolean;
|
||||||
|
Loading…
Reference in New Issue
Block a user