mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-08 23:19:26 +08:00
* feat: association field features * fix: remove comments * fix: association field in creation form will trigger error * fix: column decorator title * fix: column designer title * fix: association field in table * feat: adjust documents * fix: remove m2o subfield mode * fix: adjust title field display condition * fix: relation field title bug * fix: o2m multiple is true * feat: association fields are loaded on demand * fix: support sub field * feat: remove FormField require config * fix: two lines in Columns config menu of table block * fix: could not find schema node * fix: add form context to internal table block * fix(client): non-empty judgment * feat: translations * fix: add / edit field title compile * fix: unique * fix: association feature bugs * feat: add oho & o2m selector filter * fix: add field added logic in FormField and TableField * fix: remove updateAssociationValues middleware * feat: recordprovider in association fields * feat: add kanban association appends Co-authored-by: chenos <chenlinxh@gmail.com>
22 lines
836 B
TypeScript
22 lines
836 B
TypeScript
import { SchemaKey, useFieldSchema } from '@formily/react';
|
|
import React from 'react';
|
|
import { CollectionFieldContext } from './context';
|
|
import { useCollection, useCollectionManager } from './hooks';
|
|
import { CollectionFieldOptions } from './types';
|
|
|
|
export const CollectionFieldProvider: React.FC<{ name?: SchemaKey; field?: CollectionFieldOptions }> = (props) => {
|
|
const { name, field, children } = props;
|
|
const fieldSchema = useFieldSchema();
|
|
const { getField } = useCollection();
|
|
const { getCollectionJoinField } = useCollectionManager();
|
|
const value = field || getField(field?.name || name) || getCollectionJoinField(fieldSchema?.['x-collection-field']);
|
|
if (!value) {
|
|
return null;
|
|
}
|
|
return (
|
|
<CollectionFieldContext.Provider value={value}>
|
|
{children}
|
|
</CollectionFieldContext.Provider>
|
|
);
|
|
};
|