chore: make labelConfig items required, update description text

This commit is contained in:
Abbey Yacoe
2025-05-26 12:04:22 +02:00
parent d444d2e948
commit 9641f2a0df
5 changed files with 13 additions and 14 deletions
@@ -144,12 +144,11 @@ export function NodeWrapper<NodeType extends Node>({
event.preventDefault(); event.preventDefault();
store.setState({ store.setState({
ariaLiveMessage: ariaLiveMessage: labelConfig['a11yDescription.ariaLiveMessage'](
labelConfig['a11yDescription.ariaLiveMessage']?.( event.key.replace('Arrow', '').toLowerCase(),
event.key.replace('Arrow', '').toLowerCase(), ~~internals.positionAbsolute.x,
~~internals.positionAbsolute.x, ~~internals.positionAbsolute.y
~~internals.positionAbsolute.y ),
) || '',
}); });
moveSelectedNodes({ moveSelectedNodes({
+3 -3
View File
@@ -668,8 +668,8 @@ export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends E
*/ */
debug?: boolean; debug?: boolean;
/** /**
* Custom accessibility messages for screen readers and a11y features. * Configuration for customizable labels, descriptions, and UI text. Provided keys will override the corresponding defaults.
* Allows localization and customization of ARIA descriptions. * Allows localization, customization of ARIA descriptions, control labels, minimap labels, and other UI strings.
*/ */
labelConfig?: LabelConfig; labelConfig?: Partial<LabelConfig>;
} }
@@ -189,11 +189,11 @@
) { ) {
// prevent default scrolling behavior on arrow key press when node is moved // prevent default scrolling behavior on arrow key press when node is moved
event.preventDefault(); event.preventDefault();
store.ariaLiveMessage = labelConfig['a11yDescription.ariaLiveMessage']?.( store.ariaLiveMessage = labelConfig['a11yDescription.ariaLiveMessage'](
event.key.replace('Arrow', '').toLowerCase(), event.key.replace('Arrow', '').toLowerCase(),
~~node.internals.positionAbsolute.x, ~~node.internals.positionAbsolute.x,
~~node.internals.positionAbsolute.y ~~node.internals.positionAbsolute.y
) || ''; ),
store.moveSelectedNodes(arrowKeyDiffs[event.key], event.shiftKey ? 4 : 1); store.moveSelectedNodes(arrowKeyDiffs[event.key], event.shiftKey ? 4 : 1);
} }
@@ -473,8 +473,8 @@ export type SvelteFlowProps<
/** This event handler gets called when the user finishes dragging a selection box */ /** This event handler gets called when the user finishes dragging a selection box */
onselectionend?: (event: PointerEvent) => void; onselectionend?: (event: PointerEvent) => void;
/** /**
* Custom accessibility messages for screen readers and a11y features. * Configuration for customizable labels, descriptions, and UI text. Provided keys will override the corresponding defaults.
* Allows localization and customization of ARIA descriptions. * Allows localization, customization of ARIA descriptions, control labels, minimap labels, and other UI strings.
*/ */
labelConfig?: LabelConfig; labelConfig?: LabelConfig;
}; };
+1 -1
View File
@@ -58,4 +58,4 @@ export const defaultLabelConfig = {
'minimap.ariaLabel': 'Mini Map', 'minimap.ariaLabel': 'Mini Map',
}; };
export type LabelConfig = Partial<typeof defaultLabelConfig>; export type LabelConfig = Required<typeof defaultLabelConfig>;