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

View File

@@ -144,12 +144,11 @@ export function NodeWrapper<NodeType extends Node>({
event.preventDefault();
store.setState({
ariaLiveMessage:
labelConfig['a11yDescription.ariaLiveMessage']?.(
event.key.replace('Arrow', '').toLowerCase(),
~~internals.positionAbsolute.x,
~~internals.positionAbsolute.y
) || '',
ariaLiveMessage: labelConfig['a11yDescription.ariaLiveMessage'](
event.key.replace('Arrow', '').toLowerCase(),
~~internals.positionAbsolute.x,
~~internals.positionAbsolute.y
),
});
moveSelectedNodes({

View File

@@ -668,8 +668,8 @@ export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends E
*/
debug?: boolean;
/**
* Custom accessibility messages for screen readers and a11y features.
* Allows localization and customization of ARIA descriptions.
* Configuration for customizable labels, descriptions, and UI text. Provided keys will override the corresponding defaults.
* Allows localization, customization of ARIA descriptions, control labels, minimap labels, and other UI strings.
*/
labelConfig?: LabelConfig;
labelConfig?: Partial<LabelConfig>;
}

View File

@@ -189,11 +189,11 @@
) {
// prevent default scrolling behavior on arrow key press when node is moved
event.preventDefault();
store.ariaLiveMessage = labelConfig['a11yDescription.ariaLiveMessage']?.(
store.ariaLiveMessage = labelConfig['a11yDescription.ariaLiveMessage'](
event.key.replace('Arrow', '').toLowerCase(),
~~node.internals.positionAbsolute.x,
~~node.internals.positionAbsolute.y
) || '';
),
store.moveSelectedNodes(arrowKeyDiffs[event.key], event.shiftKey ? 4 : 1);
}

View File

@@ -473,8 +473,8 @@ export type SvelteFlowProps<
/** This event handler gets called when the user finishes dragging a selection box */
onselectionend?: (event: PointerEvent) => void;
/**
* Custom accessibility messages for screen readers and a11y features.
* Allows localization and customization of ARIA descriptions.
* Configuration for customizable labels, descriptions, and UI text. Provided keys will override the corresponding defaults.
* Allows localization, customization of ARIA descriptions, control labels, minimap labels, and other UI strings.
*/
labelConfig?: LabelConfig;
};

View File

@@ -58,4 +58,4 @@ export const defaultLabelConfig = {
'minimap.ariaLabel': 'Mini Map',
};
export type LabelConfig = Partial<typeof defaultLabelConfig>;
export type LabelConfig = Required<typeof defaultLabelConfig>;