chore: rename LabelConfig -> AriaLabelConfig, update dict names
This commit is contained in:
@@ -21,7 +21,7 @@ export const ARIA_EDGE_DESC_KEY = 'react-flow__edge-desc';
|
||||
export const ARIA_LIVE_MESSAGE = 'react-flow__aria-live';
|
||||
|
||||
const ariaLiveSelector = (s: ReactFlowState) => s.ariaLiveMessage;
|
||||
const labelConfigSelector = (s: ReactFlowState) => s.labelConfig;
|
||||
const ariaLabelConfigSelector = (s: ReactFlowState) => s.ariaLabelConfig;
|
||||
|
||||
function AriaLiveMessage({ rfId }: { rfId: string }) {
|
||||
const ariaLiveMessage = useStore(ariaLiveSelector);
|
||||
@@ -34,17 +34,17 @@ function AriaLiveMessage({ rfId }: { rfId: string }) {
|
||||
}
|
||||
|
||||
export function A11yDescriptions({ rfId, disableKeyboardA11y }: { rfId: string; disableKeyboardA11y: boolean }) {
|
||||
const labelConfig = useStore(labelConfigSelector);
|
||||
const ariaLabelConfig = useStore(ariaLabelConfigSelector);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div id={`${ARIA_NODE_DESC_KEY}-${rfId}`} style={style}>
|
||||
{disableKeyboardA11y
|
||||
? labelConfig['a11yDescription.node.default']
|
||||
: labelConfig['a11yDescription.node.keyboardDisabled']}
|
||||
? ariaLabelConfig['node.a11yDescription.default']
|
||||
: ariaLabelConfig['node.a11yDescription.keyboardDisabled']}
|
||||
</div>
|
||||
<div id={`${ARIA_EDGE_DESC_KEY}-${rfId}`} style={style}>
|
||||
{labelConfig['a11yDescription.edge.default']}
|
||||
{ariaLabelConfig['edge.a11yDescription.default']}
|
||||
</div>
|
||||
{!disableKeyboardA11y && <AriaLiveMessage rfId={rfId} />}
|
||||
</>
|
||||
|
||||
@@ -142,10 +142,10 @@ export function NodeWrapper<NodeType extends Node>({
|
||||
// prevent default scrolling behavior on arrow key press when node is moved
|
||||
event.preventDefault();
|
||||
|
||||
const { labelConfig } = store.getState();
|
||||
const { ariaLabelConfig } = store.getState();
|
||||
|
||||
store.setState({
|
||||
ariaLiveMessage: labelConfig['a11yDescription.ariaLiveMessage']({
|
||||
ariaLiveMessage: ariaLabelConfig['a11yDescription.ariaLiveMessage']({
|
||||
direction: event.key.replace('Arrow', '').toLowerCase(),
|
||||
x: ~~internals.positionAbsolute.x,
|
||||
y: ~~internals.positionAbsolute.y,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { shallow } from 'zustand/shallow';
|
||||
import { infiniteExtent, type CoordinateExtent, mergeLabelConfig, LabelConfig } from '@xyflow/system';
|
||||
import { infiniteExtent, type CoordinateExtent, mergeAriaLabelConfig, AriaLabelConfig } from '@xyflow/system';
|
||||
|
||||
import { useStore, useStoreApi } from '../../hooks/useStore';
|
||||
import type { Node, Edge, ReactFlowState, ReactFlowProps, FitViewOptions } from '../../types';
|
||||
@@ -68,7 +68,7 @@ const reactFlowFieldsToTrack = [
|
||||
'debug',
|
||||
'autoPanSpeed',
|
||||
'paneClickDistance',
|
||||
'labelConfig',
|
||||
'ariaLabelConfig',
|
||||
] as const;
|
||||
|
||||
type ReactFlowFieldsToTrack = (typeof reactFlowFieldsToTrack)[number];
|
||||
@@ -158,8 +158,8 @@ export function StoreUpdater<NodeType extends Node = Node, EdgeType extends Edge
|
||||
else if (fieldName === 'fitView') store.setState({ fitViewQueued: fieldValue as boolean });
|
||||
else if (fieldName === 'fitViewOptions') store.setState({ fitViewOptions: fieldValue as FitViewOptions });
|
||||
|
||||
if (fieldName === 'labelConfig') {
|
||||
store.setState({ labelConfig: mergeLabelConfig(fieldValue as LabelConfig) });
|
||||
if (fieldName === 'ariaLabelConfig') {
|
||||
store.setState({ ariaLabelConfig: mergeAriaLabelConfig(fieldValue as AriaLabelConfig) });
|
||||
}
|
||||
// General case
|
||||
else store.setState({ [fieldName]: fieldValue });
|
||||
|
||||
Reference in New Issue
Block a user