mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 06:55:50 +00:00
chore: add aria-label for block menu
This commit is contained in:
parent
964f4f4635
commit
6a840ef816
@ -473,18 +473,21 @@ SchemaInitializer.Item = function Item(props: SchemaInitializerItemProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const item = {
|
const item = {
|
||||||
|
...props,
|
||||||
key: info.key,
|
key: info.key,
|
||||||
label: isString(children) ? compile(children) : children,
|
label: isString(children) ? compile(children) : children,
|
||||||
icon: typeof icon === 'string' ? <Icon type={icon as string} /> : icon,
|
icon: typeof icon === 'string' ? <Icon type={icon as string} /> : icon,
|
||||||
children: renderMenuItem(items, info.key),
|
children: renderMenuItem(items, info.key),
|
||||||
};
|
};
|
||||||
|
|
||||||
collectMenuItem(item);
|
collectMenuItem(item as any);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const label = isString(children) ? compile(children) : children;
|
const label = isString(children) ? compile(children) : children;
|
||||||
const item = {
|
const item = {
|
||||||
|
role: props?.role,
|
||||||
|
'aria-label': props?.['aria-label'],
|
||||||
key: info.key,
|
key: info.key,
|
||||||
label,
|
label,
|
||||||
title: label,
|
title: label,
|
||||||
|
@ -12,48 +12,64 @@ export const BlockInitializers = {
|
|||||||
title: '{{t("Data blocks")}}',
|
title: '{{t("Data blocks")}}',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
role: 'button',
|
||||||
|
'aria-label': 'data-block-table',
|
||||||
key: 'table',
|
key: 'table',
|
||||||
type: 'item',
|
type: 'item',
|
||||||
title: '{{t("Table")}}',
|
title: '{{t("Table")}}',
|
||||||
component: 'TableBlockInitializer',
|
component: 'TableBlockInitializer',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
role: 'button',
|
||||||
|
'aria-label': 'data-block-form',
|
||||||
key: 'form',
|
key: 'form',
|
||||||
type: 'item',
|
type: 'item',
|
||||||
title: '{{t("Form")}}',
|
title: '{{t("Form")}}',
|
||||||
component: 'FormBlockInitializer',
|
component: 'FormBlockInitializer',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
role: 'button',
|
||||||
|
'aria-label': 'data-block-details',
|
||||||
key: 'details',
|
key: 'details',
|
||||||
type: 'item',
|
type: 'item',
|
||||||
title: '{{t("Details")}}',
|
title: '{{t("Details")}}',
|
||||||
component: 'DetailsBlockInitializer',
|
component: 'DetailsBlockInitializer',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
role: 'button',
|
||||||
|
'aria-label': 'data-block-list',
|
||||||
key: 'List',
|
key: 'List',
|
||||||
type: 'item',
|
type: 'item',
|
||||||
title: '{{t("List")}}',
|
title: '{{t("List")}}',
|
||||||
component: 'ListBlockInitializer',
|
component: 'ListBlockInitializer',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
role: 'button',
|
||||||
|
'aria-label': 'data-block-grid-card',
|
||||||
key: 'GridCard',
|
key: 'GridCard',
|
||||||
type: 'item',
|
type: 'item',
|
||||||
title: '{{t("Grid Card")}}',
|
title: '{{t("Grid Card")}}',
|
||||||
component: 'GridCardBlockInitializer',
|
component: 'GridCardBlockInitializer',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
role: 'button',
|
||||||
|
'aria-label': 'data-block-calendar',
|
||||||
key: 'calendar',
|
key: 'calendar',
|
||||||
type: 'item',
|
type: 'item',
|
||||||
title: '{{t("Calendar")}}',
|
title: '{{t("Calendar")}}',
|
||||||
component: 'CalendarBlockInitializer',
|
component: 'CalendarBlockInitializer',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
role: 'button',
|
||||||
|
'aria-label': 'data-block-kanban',
|
||||||
key: 'kanban',
|
key: 'kanban',
|
||||||
type: 'item',
|
type: 'item',
|
||||||
title: '{{t("Kanban")}}',
|
title: '{{t("Kanban")}}',
|
||||||
component: 'KanbanBlockInitializer',
|
component: 'KanbanBlockInitializer',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
role: 'button',
|
||||||
|
'aria-label': 'data-block-gantt',
|
||||||
key: 'Gantt',
|
key: 'Gantt',
|
||||||
type: 'item',
|
type: 'item',
|
||||||
title: '{{t("Gantt")}}',
|
title: '{{t("Gantt")}}',
|
||||||
@ -67,12 +83,16 @@ export const BlockInitializers = {
|
|||||||
title: '{{t("Filter blocks")}}',
|
title: '{{t("Filter blocks")}}',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
role: 'button',
|
||||||
|
'aria-label': 'filter-block-form',
|
||||||
key: 'filterForm',
|
key: 'filterForm',
|
||||||
type: 'item',
|
type: 'item',
|
||||||
title: '{{t("Form")}}',
|
title: '{{t("Form")}}',
|
||||||
component: 'FilterFormBlockInitializer',
|
component: 'FilterFormBlockInitializer',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
role: 'button',
|
||||||
|
'aria-label': 'filter-block-collapse',
|
||||||
key: 'filterCollapse',
|
key: 'filterCollapse',
|
||||||
type: 'item',
|
type: 'item',
|
||||||
title: '{{t("Collapse")}}',
|
title: '{{t("Collapse")}}',
|
||||||
@ -86,12 +106,16 @@ export const BlockInitializers = {
|
|||||||
title: '{{t("Other blocks")}}',
|
title: '{{t("Other blocks")}}',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
role: 'button',
|
||||||
|
'aria-label': 'block-markdown',
|
||||||
key: 'markdown',
|
key: 'markdown',
|
||||||
type: 'item',
|
type: 'item',
|
||||||
title: '{{t("Markdown")}}',
|
title: '{{t("Markdown")}}',
|
||||||
component: 'MarkdownBlockInitializer',
|
component: 'MarkdownBlockInitializer',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
role: 'button',
|
||||||
|
'aria-label': 'block-audit-logs',
|
||||||
key: 'auditLogs',
|
key: 'auditLogs',
|
||||||
type: 'item',
|
type: 'item',
|
||||||
title: '{{t("Audit logs")}}',
|
title: '{{t("Audit logs")}}',
|
||||||
|
@ -63,6 +63,7 @@ interface SchemaInitializerItemComponentProps {
|
|||||||
export interface SchemaInitializerItemProps extends Omit<MenuItemProps, 'onClick'> {
|
export interface SchemaInitializerItemProps extends Omit<MenuItemProps, 'onClick'> {
|
||||||
items?: SchemaInitializerItemOptions[];
|
items?: SchemaInitializerItemOptions[];
|
||||||
onClick?: MenuClickEventHandler;
|
onClick?: MenuClickEventHandler;
|
||||||
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
type MenuClickEventHandler = (info: MenuInfo) => void;
|
type MenuClickEventHandler = (info: MenuInfo) => void;
|
||||||
|
@ -747,7 +747,7 @@ SchemaSettings.SelectItem = function SelectItem(props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<SchemaSettings.Item {...others}>
|
<SchemaSettings.Item {...others}>
|
||||||
<div style={{ alignItems: 'center', display: 'flex', justifyContent: 'space-between' }}>
|
<label aria-label={title} style={{ alignItems: 'center', display: 'flex', justifyContent: 'space-between' }}>
|
||||||
{title}
|
{title}
|
||||||
<Select
|
<Select
|
||||||
data-testid="antd-select"
|
data-testid="antd-select"
|
||||||
@ -760,7 +760,7 @@ SchemaSettings.SelectItem = function SelectItem(props) {
|
|||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
{...moreProps}
|
{...moreProps}
|
||||||
/>
|
/>
|
||||||
</div>
|
</label>
|
||||||
</SchemaSettings.Item>
|
</SchemaSettings.Item>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -50,6 +50,8 @@ const ChartsProvider = React.memo((props) => {
|
|||||||
const hasChartItem = children.some((child) => child?.component === 'ChartBlockInitializer');
|
const hasChartItem = children.some((child) => child?.component === 'ChartBlockInitializer');
|
||||||
if (!hasChartItem) {
|
if (!hasChartItem) {
|
||||||
children.push({
|
children.push({
|
||||||
|
role: 'button',
|
||||||
|
'aria-label': 'data-block-chart',
|
||||||
key: 'chart',
|
key: 'chart',
|
||||||
type: 'item',
|
type: 'item',
|
||||||
icon: 'PieChartOutlined',
|
icon: 'PieChartOutlined',
|
||||||
|
@ -10,6 +10,8 @@ export const DataVisualization: React.FC = (props) => {
|
|||||||
const has = children.some((initializer) => initializer.component === 'ChartV2BlockInitializer');
|
const has = children.some((initializer) => initializer.component === 'ChartV2BlockInitializer');
|
||||||
if (!has) {
|
if (!has) {
|
||||||
children.push({
|
children.push({
|
||||||
|
role: 'button',
|
||||||
|
'aria-label': 'data-block-charts',
|
||||||
key: 'chart-v2',
|
key: 'chart-v2',
|
||||||
type: 'item',
|
type: 'item',
|
||||||
title: t('Charts'),
|
title: t('Charts'),
|
||||||
|
Loading…
Reference in New Issue
Block a user