2022-10-31 11:52:17 +08:00
# CollectionManager
## Components
### CollectionManagerProvider
```jsx | pure
< CollectionManagerProvider interfaces = {{}} collections = {[]} > < / CollectionManagerProvider >
```
### CollectionProvider
```jsx | pure
const collection = {
name: 'tests',
fields: [
{
type: 'string',
name: 'title',
interface: 'input',
uiSchema: {
type: 'string',
'x-component': 'Input'
},
},
],
};
< CollectionProvider collection = {collection} > < / CollectionProvider >
```
2023-02-18 23:53:19 +08:00
If there is no collection parameter passed in, get the collection from CollectionManagerProvider with the corresponding name.
2022-10-31 11:52:17 +08:00
```jsx | pure
const collections = [
{
name: 'tests',
fields: [
{
type: 'string',
name: 'title',
interface: 'input',
uiSchema: {
type: 'string',
'x-component': 'Input'
},
},
],
}
];
< CollectionManagerProvider collections = {collections} >
< CollectionProvider name = {'tests'} > < / CollectionProvider >
< / CollectionManagerProvider >
```
### CollectionFieldProvider
```jsx | pure
const field = {
type: 'string',
name: 'title',
interface: 'input',
uiSchema: {
type: 'string',
'x-component': 'Input'
},
};
< CollectionFieldProvider field = {field} > < / CollectionFieldProvider >
```
2023-02-18 23:53:19 +08:00
If there is no field parameter passed in, get the field from CollectionProvider with the corresponding name.
2022-10-31 11:52:17 +08:00
```jsx | pure
const collection = {
name: 'tests',
fields: [
{
type: 'string',
name: 'title',
interface: 'input',
uiSchema: {
type: 'string',
'x-component': 'Input'
},
},
],
};
< CollectionProvider collection = {collection} >
< CollectionFieldProvider name = {'title'} > < / CollectionFieldProvider >
< / CollectionProvider >
```
### CollectionField
2023-02-18 23:53:19 +08:00
Universal field component that needs to be used with `<CollectionProvider/>` , but only in schema scenarios. Get the field schema from CollectionProvider with the corresponding name. Extend the configuration via the schema where the CollectionField is located.
2022-10-31 11:52:17 +08:00
```ts
{
name: 'title',
'x-decorator': 'FormItem',
'x-decorator-props': {},
'x-component': 'CollectionField',
'x-component-props': {},
properties: {},
}
```
## Hooks
### useCollectionManager()
2023-02-18 23:53:19 +08:00
Use with `<CollectionManagerProvider/>` .
2022-10-31 11:52:17 +08:00
```jsx | pure
const { collections, get } = useCollectionManager();
```
### useCollection()
2023-02-18 23:53:19 +08:00
Use with `<CollectionProvider/>` .
2022-10-31 11:52:17 +08:00
```jsx | pure
const { name, fields, getField, findField, resource } = useCollection();
```
### useCollectionField()
2023-02-18 23:53:19 +08:00
Use with `<CollectionFieldProvider/>` .
2022-10-31 11:52:17 +08:00
```jsx | pure
const { name, uiSchema, resource } = useCollectionField();
```
2023-02-18 23:53:19 +08:00
The resource needs to be used with `<RecordProvider/>` to provide context of the record of the current data table row.
2022-10-31 11:52:17 +08:00
# CollectionManager
## Components
### CollectionManagerProvider
```jsx | pure
< CollectionManagerProvider interfaces = {{}} collections = {[]} > < / CollectionManagerProvider >
```
### CollectionProvider
```jsx | pure
const collection = {
name: 'tests',
fields: [
{
type: 'string',
name: 'title',
interface: 'input',
uiSchema: {
type: 'string',
'x-component': 'Input'
},
},
],
};
< CollectionProvider collection = {collection} > < / CollectionProvider >
```
2023-02-18 23:53:19 +08:00
If there is no collection parameter passed in, get the collection from CollectionManagerProvider with the corresponding name.
2022-10-31 11:52:17 +08:00
```jsx | pure
const collections = [
{
name: 'tests',
fields: [
{
type: 'string',
name: 'title',
interface: 'input',
uiSchema: {
type: 'string',
'x-component': 'Input'
},
},
],
}
];
< CollectionManagerProvider collections = {collections} >
< CollectionProvider name = {'tests'} > < / CollectionProvider >
< / CollectionManagerProvider >
```
### CollectionFieldProvider
```jsx | pure
const field = {
type: 'string',
name: 'title',
interface: 'input',
uiSchema: {
type: 'string',
'x-component': 'Input'
},
};
< CollectionFieldProvider field = {field} > < / CollectionFieldProvider >
```
2023-02-18 23:53:19 +08:00
If there is no field parameter passed in, get the field from CollectionProvider with the corresponding name.
2022-10-31 11:52:17 +08:00
```jsx | pure
const collection = {
name: 'tests',
fields: [
{
type: 'string',
name: 'title',
interface: 'input',
uiSchema: {
type: 'string',
'x-component': 'Input'
},
},
],
};
< CollectionProvider collection = {collection} >
< CollectionFieldProvider name = {'title'} > < / CollectionFieldProvider >
< / CollectionProvider >
```
### CollectionField
2023-02-18 23:53:19 +08:00
Universal field component that needs to be used with `<CollectionProvider/>` , but only in schema scenarios. Get the field schema from CollectionProvider with the corresponding name. Extend the configuration via the schema where the CollectionField is located.
2022-10-31 11:52:17 +08:00
```ts
{
name: 'title',
'x-decorator': 'FormItem',
'x-decorator-props': {},
'x-component': 'CollectionField',
'x-component-props': {},
properties: {},
}
```
## Hooks
### useCollectionManager()
2023-02-18 23:53:19 +08:00
Use with `<CollectionManagerProvider/>` .
2022-10-31 11:52:17 +08:00
```jsx | pure
const { collections, get } = useCollectionManager();
```
### useCollection()
2023-02-18 23:53:19 +08:00
Use with `<CollectionProvider/>` .
2022-10-31 11:52:17 +08:00
```jsx | pure
const { name, fields, getField, findField, resource } = useCollection();
```
### useCollectionField()
2023-02-18 23:53:19 +08:00
Use with `<CollectionFieldProvider/>` .
2022-10-31 11:52:17 +08:00
```jsx | pure
const { name, uiSchema, resource } = useCollectionField();
```
2023-02-18 23:53:19 +08:00
The resource needs to be used with `<RecordProvider/>` to provide context of the record of the current data table row.