mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 10:37:01 +00:00
chore: add collectionName
This commit is contained in:
parent
2f30eb148d
commit
44656b4f6f
@ -1,23 +1,26 @@
|
||||
import { useFieldSchema } from '@formily/react';
|
||||
import { useCallback } from 'react';
|
||||
import { useCollection } from '../../collection-manager';
|
||||
|
||||
/**
|
||||
* label = 'designer' + name + x-component + [x-designer] + [x-collection-field] + [postfix]
|
||||
* label = 'designer' + name + x-component + [x-designer] + [collectionName] + [x-collection-field] + [postfix]
|
||||
* @returns
|
||||
*/
|
||||
export const useGetAriaLabelOfDesigner = () => {
|
||||
const fieldSchema = useFieldSchema();
|
||||
let { name: collectionName } = useCollection();
|
||||
const component = fieldSchema['x-component'];
|
||||
const designer = fieldSchema['x-designer'] ? `-${fieldSchema['x-designer']}` : '';
|
||||
const collectionField = fieldSchema['x-collection-field'] ? `-${fieldSchema['x-collection-field']}` : '';
|
||||
collectionName = collectionName ? `-${collectionName}` : '';
|
||||
|
||||
const getAriaLabel = useCallback(
|
||||
(name: string, postfix?: string) => {
|
||||
postfix = postfix ? `-${postfix}` : '';
|
||||
|
||||
return `designer-${name}-${component}${designer}${collectionField}${postfix}`;
|
||||
return `designer-${name}-${component}${designer}${collectionName}${collectionField}${postfix}`;
|
||||
},
|
||||
[collectionField, component, designer],
|
||||
[collectionField, collectionName, component, designer],
|
||||
);
|
||||
|
||||
return { getAriaLabel };
|
||||
|
Loading…
Reference in New Issue
Block a user