@@ -2,35 +2,9 @@ import {Fragment} from 'react'
22import Text from '../../Text'
33import type { KeybindingHintProps } from '../props'
44import { Key } from './Key'
5- import { accessibleKeyName } from '../key-names'
6- import type { Platform } from '../platform'
75import { clsx } from 'clsx'
86import classes from './Chord.module.css'
9-
10- /**
11- * Consistent sort order for modifier keys. There should never be more than one non-modifier
12- * key in a chord, so we don't need to worry about sorting those - we just put them at
13- * the end.
14- */
15- const keySortPriorities : Partial < Record < string , number > > = {
16- control : 1 ,
17- meta : 2 ,
18- alt : 3 ,
19- option : 4 ,
20- shift : 5 ,
21- function : 6 ,
22- }
23-
24- const keySortPriority = ( priority : string ) => keySortPriorities [ priority ] ?? Infinity
25-
26- const compareLowercaseKeys = ( a : string , b : string ) => keySortPriority ( a ) - keySortPriority ( b )
27-
28- /** Split and sort the chord keys in standard order. */
29- const splitChord = ( chord : string ) =>
30- chord
31- . split ( '+' )
32- . map ( k => k . toLowerCase ( ) )
33- . sort ( compareLowercaseKeys )
7+ import { accessibleChordString , splitChord } from './utils'
348
359export const Chord = ( { keys, format = 'condensed' , variant = 'normal' , size = 'normal' } : KeybindingHintProps ) => (
3610 < Text
@@ -56,8 +30,4 @@ export const Chord = ({keys, format = 'condensed', variant = 'normal', size = 'n
5630 </ Text >
5731)
5832
59- /** Plain string version of `Chord` for use in `aria` string attributes. */
60- export const accessibleChordString = ( chord : string , platform : Platform ) =>
61- splitChord ( chord )
62- . map ( key => accessibleKeyName ( key , platform ) )
63- . join ( ' ' )
33+ export { accessibleChordString }
0 commit comments