@flipdish/ui-library 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/components/atoms/Input/index.cjs +3 -1
  2. package/dist/components/atoms/Input/index.cjs.map +1 -1
  3. package/dist/components/atoms/Input/index.d.ts +5 -1
  4. package/dist/components/atoms/Input/index.d.ts.map +1 -1
  5. package/dist/components/atoms/Input/index.js +3 -1
  6. package/dist/components/atoms/Input/index.js.map +1 -1
  7. package/dist/components/molecules/Select/components/combobox.cjs +3 -1
  8. package/dist/components/molecules/Select/components/combobox.cjs.map +1 -1
  9. package/dist/components/molecules/Select/components/combobox.d.ts.map +1 -1
  10. package/dist/components/molecules/Select/components/combobox.js +3 -1
  11. package/dist/components/molecules/Select/components/combobox.js.map +1 -1
  12. package/dist/components/organisms/ApplicationHeader/applicationHeader.types.d.ts +12 -5
  13. package/dist/components/organisms/ApplicationHeader/applicationHeader.types.d.ts.map +1 -1
  14. package/dist/components/organisms/ApplicationHeader/index.cjs +12 -17
  15. package/dist/components/organisms/ApplicationHeader/index.cjs.map +1 -1
  16. package/dist/components/organisms/ApplicationHeader/index.d.ts +9 -5
  17. package/dist/components/organisms/ApplicationHeader/index.d.ts.map +1 -1
  18. package/dist/components/organisms/ApplicationHeader/index.js +12 -18
  19. package/dist/components/organisms/ApplicationHeader/index.js.map +1 -1
  20. package/dist/components/organisms/Calendar/index.cjs +3 -3
  21. package/dist/components/organisms/Calendar/index.cjs.map +1 -1
  22. package/dist/components/organisms/Calendar/index.js +3 -3
  23. package/dist/components/organisms/Calendar/index.js.map +1 -1
  24. package/dist/components/organisms/CommandMenu/commandMenu.utils.cjs +0 -21
  25. package/dist/components/organisms/CommandMenu/commandMenu.utils.cjs.map +1 -1
  26. package/dist/components/organisms/CommandMenu/commandMenu.utils.d.ts +0 -9
  27. package/dist/components/organisms/CommandMenu/commandMenu.utils.d.ts.map +1 -1
  28. package/dist/components/organisms/CommandMenu/commandMenu.utils.js +1 -21
  29. package/dist/components/organisms/CommandMenu/commandMenu.utils.js.map +1 -1
  30. package/dist/components/organisms/CommandMenu/components/command-input.cjs +2 -2
  31. package/dist/components/organisms/CommandMenu/components/command-input.cjs.map +1 -1
  32. package/dist/components/organisms/CommandMenu/components/command-input.d.ts +3 -2
  33. package/dist/components/organisms/CommandMenu/components/command-input.d.ts.map +1 -1
  34. package/dist/components/organisms/CommandMenu/components/command-input.js +2 -2
  35. package/dist/components/organisms/CommandMenu/components/command-input.js.map +1 -1
  36. package/dist/components/organisms/CommandMenu/components/command-menu-item.cjs +15 -2
  37. package/dist/components/organisms/CommandMenu/components/command-menu-item.cjs.map +1 -1
  38. package/dist/components/organisms/CommandMenu/components/command-menu-item.d.ts +9 -1
  39. package/dist/components/organisms/CommandMenu/components/command-menu-item.d.ts.map +1 -1
  40. package/dist/components/organisms/CommandMenu/components/command-menu-item.js +15 -2
  41. package/dist/components/organisms/CommandMenu/components/command-menu-item.js.map +1 -1
  42. package/dist/components/organisms/CommandMenu/components/command-shortcut.cjs +2 -2
  43. package/dist/components/organisms/CommandMenu/components/command-shortcut.cjs.map +1 -1
  44. package/dist/components/organisms/CommandMenu/components/command-shortcut.d.ts +1 -0
  45. package/dist/components/organisms/CommandMenu/components/command-shortcut.d.ts.map +1 -1
  46. package/dist/components/organisms/CommandMenu/components/command-shortcut.js +2 -2
  47. package/dist/components/organisms/CommandMenu/components/command-shortcut.js.map +1 -1
  48. package/dist/components/organisms/CommandMenu/index.cjs +65 -29
  49. package/dist/components/organisms/CommandMenu/index.cjs.map +1 -1
  50. package/dist/components/organisms/CommandMenu/index.d.ts +29 -2
  51. package/dist/components/organisms/CommandMenu/index.d.ts.map +1 -1
  52. package/dist/components/organisms/CommandMenu/index.js +69 -33
  53. package/dist/components/organisms/CommandMenu/index.js.map +1 -1
  54. package/dist/components/organisms/CommandMenu/providers/command-menu-link-context.cjs +9 -0
  55. package/dist/components/organisms/CommandMenu/providers/command-menu-link-context.cjs.map +1 -0
  56. package/dist/components/organisms/CommandMenu/providers/command-menu-link-context.d.ts +3 -0
  57. package/dist/components/organisms/CommandMenu/providers/command-menu-link-context.d.ts.map +1 -0
  58. package/dist/components/organisms/CommandMenu/providers/command-menu-link-context.js +7 -0
  59. package/dist/components/organisms/CommandMenu/providers/command-menu-link-context.js.map +1 -0
  60. package/dist/components/organisms/DatePicker/components/input-date.cjs +3 -1
  61. package/dist/components/organisms/DatePicker/components/input-date.cjs.map +1 -1
  62. package/dist/components/organisms/DatePicker/components/input-date.d.ts +5 -1
  63. package/dist/components/organisms/DatePicker/components/input-date.d.ts.map +1 -1
  64. package/dist/components/organisms/DatePicker/components/input-date.js +3 -1
  65. package/dist/components/organisms/DatePicker/components/input-date.js.map +1 -1
  66. package/dist/components/organisms/HeaderNavigation/components/nav-account-card.cjs +3 -1
  67. package/dist/components/organisms/HeaderNavigation/components/nav-account-card.cjs.map +1 -1
  68. package/dist/components/organisms/HeaderNavigation/components/nav-account-card.d.ts +1 -1
  69. package/dist/components/organisms/HeaderNavigation/components/nav-account-card.d.ts.map +1 -1
  70. package/dist/components/organisms/HeaderNavigation/components/nav-account-card.js +3 -1
  71. package/dist/components/organisms/HeaderNavigation/components/nav-account-card.js.map +1 -1
  72. package/dist/components/organisms/SidebarNavigation/components/nav-account-card.cjs +3 -1
  73. package/dist/components/organisms/SidebarNavigation/components/nav-account-card.cjs.map +1 -1
  74. package/dist/components/organisms/SidebarNavigation/components/nav-account-card.d.ts +1 -1
  75. package/dist/components/organisms/SidebarNavigation/components/nav-account-card.d.ts.map +1 -1
  76. package/dist/components/organisms/SidebarNavigation/components/nav-account-card.js +3 -1
  77. package/dist/components/organisms/SidebarNavigation/components/nav-account-card.js.map +1 -1
  78. package/dist/components/organisms/SidebarNavigation/index.cjs +15 -5
  79. package/dist/components/organisms/SidebarNavigation/index.cjs.map +1 -1
  80. package/dist/components/organisms/SidebarNavigation/index.d.ts +3 -2
  81. package/dist/components/organisms/SidebarNavigation/index.d.ts.map +1 -1
  82. package/dist/components/organisms/SidebarNavigation/index.js +15 -5
  83. package/dist/components/organisms/SidebarNavigation/index.js.map +1 -1
  84. package/dist/components/organisms/TextEditor/components/text-editor-extensions.cjs +9 -4
  85. package/dist/components/organisms/TextEditor/components/text-editor-extensions.cjs.map +1 -1
  86. package/dist/components/organisms/TextEditor/components/text-editor-extensions.d.ts.map +1 -1
  87. package/dist/components/organisms/TextEditor/components/text-editor-extensions.js +10 -5
  88. package/dist/components/organisms/TextEditor/components/text-editor-extensions.js.map +1 -1
  89. package/dist/components/organisms/TextEditor/components/text-editor-toolbar.cjs +8 -2
  90. package/dist/components/organisms/TextEditor/components/text-editor-toolbar.cjs.map +1 -1
  91. package/dist/components/organisms/TextEditor/components/text-editor-toolbar.d.ts.map +1 -1
  92. package/dist/components/organisms/TextEditor/components/text-editor-toolbar.js +8 -2
  93. package/dist/components/organisms/TextEditor/components/text-editor-toolbar.js.map +1 -1
  94. package/dist/components/organisms/TextEditor/textEditor.utils.cjs +3 -0
  95. package/dist/components/organisms/TextEditor/textEditor.utils.cjs.map +1 -1
  96. package/dist/components/organisms/TextEditor/textEditor.utils.d.ts +4 -0
  97. package/dist/components/organisms/TextEditor/textEditor.utils.d.ts.map +1 -1
  98. package/dist/components/organisms/TextEditor/textEditor.utils.js +3 -1
  99. package/dist/components/organisms/TextEditor/textEditor.utils.js.map +1 -1
  100. package/dist/hooks/__internal__/useHotkeyHint/useHotkeyHint.cjs +24 -0
  101. package/dist/hooks/__internal__/useHotkeyHint/useHotkeyHint.cjs.map +1 -0
  102. package/dist/hooks/__internal__/useHotkeyHint/useHotkeyHint.d.ts +22 -0
  103. package/dist/hooks/__internal__/useHotkeyHint/useHotkeyHint.d.ts.map +1 -0
  104. package/dist/hooks/__internal__/useHotkeyHint/useHotkeyHint.js +22 -0
  105. package/dist/hooks/__internal__/useHotkeyHint/useHotkeyHint.js.map +1 -0
  106. package/dist/hooks/__internal__/useKeySequences/useKeySequences.cjs +54 -0
  107. package/dist/hooks/__internal__/useKeySequences/useKeySequences.cjs.map +1 -0
  108. package/dist/hooks/__internal__/useKeySequences/useKeySequences.d.ts +11 -0
  109. package/dist/hooks/__internal__/useKeySequences/useKeySequences.d.ts.map +1 -0
  110. package/dist/hooks/__internal__/useKeySequences/useKeySequences.js +52 -0
  111. package/dist/hooks/__internal__/useKeySequences/useKeySequences.js.map +1 -0
  112. package/dist/hooks/usePlatform/index.cjs +22 -0
  113. package/dist/hooks/usePlatform/index.cjs.map +1 -0
  114. package/dist/hooks/usePlatform/index.d.ts +22 -0
  115. package/dist/hooks/usePlatform/index.d.ts.map +1 -0
  116. package/dist/hooks/usePlatform/index.js +20 -0
  117. package/dist/hooks/usePlatform/index.js.map +1 -0
  118. package/dist/native/hooks/usePlatform/index.d.ts +12 -0
  119. package/dist/utilities/__internal__/hotkeysUtils/hotkeys.utils.cjs +222 -15
  120. package/dist/utilities/__internal__/hotkeysUtils/hotkeys.utils.cjs.map +1 -1
  121. package/dist/utilities/__internal__/hotkeysUtils/hotkeys.utils.d.ts +60 -5
  122. package/dist/utilities/__internal__/hotkeysUtils/hotkeys.utils.d.ts.map +1 -1
  123. package/dist/utilities/__internal__/hotkeysUtils/hotkeys.utils.js +215 -15
  124. package/dist/utilities/__internal__/hotkeysUtils/hotkeys.utils.js.map +1 -1
  125. package/dist/utilities/__internal__/platformUtils/platform.utils.cjs +26 -0
  126. package/dist/utilities/__internal__/platformUtils/platform.utils.cjs.map +1 -0
  127. package/dist/utilities/__internal__/platformUtils/platform.utils.d.ts +10 -0
  128. package/dist/utilities/__internal__/platformUtils/platform.utils.d.ts.map +1 -0
  129. package/dist/utilities/__internal__/platformUtils/platform.utils.js +23 -0
  130. package/dist/utilities/__internal__/platformUtils/platform.utils.js.map +1 -0
  131. package/package.json +1 -1
@@ -16,15 +16,70 @@ export declare function mapCode(key: string): string;
16
16
  export declare function isHotkeyModifier(key: string): boolean;
17
17
  export declare function parseKeysHookInput(keys: string, delimiter?: string): string[];
18
18
  export declare function parseHotkey(hotkey: string, splitKey?: string, sequenceSplitKey?: string, useKey?: boolean, description?: string): Hotkey;
19
+ /** The character a key name stands for (`slash` is `/`), or the name itself when it is not punctuation. */
20
+ export declare const hotkeyCharacter: (key: string) => string;
19
21
  /**
20
- * Whether `mod` means ⌘ on this device. Mirrors `react-hotkeys-hook`'s own rule exactly (macOS only, not
21
- * iOS/iPadOS) so a hint always names the key that fires the hotkey. Always `false` on the server.
22
+ * Accepts a hotkey in `react-hotkeys-hook` format (`mod+k`) or the symbol shorthand (`⌘K`, `⌘⇧P`,
23
+ * `⌘+Shift+K`) and returns the hook format. `⌘` becomes `mod`, so it also works with Ctrl outside
24
+ * macOS. Within a token, leading symbols are modifiers and whatever follows them is one key.
25
+ * Punctuation becomes the key name the hook matches on (`⌘/` is `mod+slash`).
26
+ *
27
+ * `forDisplay` keeps a shifted symbol as written (`⌘?`). Without it, a shifted symbol in a combination
28
+ * becomes Shift plus its key (`mod+shift+slash`), which is the form that can be registered.
22
29
  */
23
- export declare const isApplePlatform: () => boolean;
30
+ export declare const normalizeHotkey: (hotkey: string, { forDisplay }?: {
31
+ forDisplay?: boolean;
32
+ }) => string;
33
+ /**
34
+ * Turns an item's `shortcutKeys` into hook-format steps. Each entry is one step (`['⌘e']` is a combination,
35
+ * `['g', 'p']` is G then P), except that an entry holding only modifiers joins the entry after it, so the
36
+ * older `['⌘', 'H']` spelling still means ⌘H.
37
+ */
38
+ export declare const toHotkeySteps: (shortcutKeys: string[], options?: {
39
+ forDisplay?: boolean;
40
+ }) => string[];
41
+ export type ItemHotkeyKind = 'combination' | 'guarded' | 'typed' | 'unsupported';
42
+ /**
43
+ * Sorts an item shortcut by how it can be triggered:
44
+ * - `combination`: one step held with ⌘/Ctrl/Alt, safe to fire even while the user is typing.
45
+ * - `guarded`: one step that typing could produce (Shift+A) or a named key (F1), so it is ignored in fields.
46
+ * - `typed`: character keys pressed in turn (`?`, G then P), also ignored in fields.
47
+ * - `unsupported`: several steps with a modifier or named key, which no handler can match.
48
+ */
49
+ export declare const getItemHotkeyKind: (steps: string[]) => ItemHotkeyKind;
50
+ /**
51
+ * Whether a key event happened while the user is typing in a field, including one inside a shadow root.
52
+ * Checks the focused element as well as the event target, because react-aria re-dispatches keys typed
53
+ * in a combobox onto its list.
54
+ */
55
+ export declare const isTypingInField: (event: KeyboardEvent) => boolean;
56
+ /**
57
+ * Feeds one typed key into the keys typed so far and reports whether a sequence is now complete.
58
+ * Returns the index of the matched sequence and an empty buffer, or the buffer to carry forward:
59
+ * the longest run of recent keys that still begins some sequence.
60
+ */
61
+ export declare const advanceKeySequence: (typedKeys: string[], key: string, sequences: string[][]) => {
62
+ buffer: string[];
63
+ matched?: number;
64
+ };
65
+ /**
66
+ * Whether a normalised hotkey is made only of modifiers and real keys. Display props accept any text
67
+ * (`"Ctrl K"`, `"Hold to talk"`), and formatting text that is not a hotkey would mangle it.
68
+ */
69
+ export declare const isRecognisedHotkey: (hotkey: string) => boolean;
24
70
  /**
25
71
  * Formats a hotkey for display: `mod+k` reads `⌘K` on macOS and `Ctrl K` elsewhere.
26
- * When several comma-separated alternatives are given, only the first is shown.
72
+ * `isMac` says whether `mod` is ⌘. For a `react-hotkeys-hook` key that is macOS only (not iOS).
73
+ * Formats one hotkey: of several comma-separated alternatives it draws only the first. `formatHotkeyLabel`
74
+ * is the entry point that draws them all.
75
+ */
76
+ export declare const formatHotkeyHint: (hotkey: string, isMac: boolean) => string;
77
+ /**
78
+ * Labels a shortcut for the platform. Accepts `react-hotkeys-hook` syntax (`mod+k`, `g>p`), the symbol
79
+ * shorthand (`⌘K`) or a shortcut written out (`Ctrl+K`), and draws each distinct comma-separated alternative.
80
+ * Text that is not a hotkey (`Hold to talk`) is returned exactly as written, so a display prop can take
81
+ * any label.
27
82
  */
28
- export declare const formatHotkeyHint: (hotkey: string, isApple: boolean) => string;
83
+ export declare const formatHotkeyLabel: (hotkey: string, isMac: boolean) => string;
29
84
  export {};
30
85
  //# sourceMappingURL=hotkeys.utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hotkeys.utils.d.ts","sourceRoot":"","sources":["../../../../src/utilities/__internal__/hotkeysUtils/hotkeys.utils.ts"],"names":[],"mappings":"AAaA,UAAU,iBAAiB;IACzB,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;IACd,GAAG,EAAE,OAAO,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,UAAU,MAAO,SAAQ,iBAAiB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;CACrB;AAuBD,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,WAE3C;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,SAAM,GAAG,MAAM,EAAE,CAE1E;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,SAAM,EAAE,gBAAgB,SAAM,EAAE,MAAM,UAAQ,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAmChI;AAOD;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAO,OACqF,CAAC;AAEzH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,SAAS,OAAO,KAAG,MAUnE,CAAC"}
1
+ {"version":3,"file":"hotkeys.utils.d.ts","sourceRoot":"","sources":["../../../../src/utilities/__internal__/hotkeysUtils/hotkeys.utils.ts"],"names":[],"mappings":"AAcA,UAAU,iBAAiB;IACzB,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,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AAG,OAC6D,CAAC;AAIrH;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,WAAW,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,WAAW,MAAM,EAAE,EAAE,KAAG;IAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAWhI,CAAC;AAuBF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,KAAG,OAMnD,CAAC;AAqBF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,OAAO,OAAO,KAAG,MAQjE,CAAC;AAWF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,EAAE,OAAO,OAAO,KAAG,MAIlE,CAAC"}
@@ -6,7 +6,8 @@
6
6
  * package directly. Keep it in sync with the source rather than editing it:
7
7
  * https://github.com/JohannesKlauss/react-hotkeys-hook/blob/main/packages/react-hotkeys-hook/src/lib/parseHotkeys.ts
8
8
  *
9
- * The display section below it is ours: platform detection and hint formatting built on that parser.
9
+ * The display section below it is ours: normalising and formatting hotkeys for labels, built on that parser.
10
+ * Platform detection lives in `platformUtils/platform.utils.ts`.
10
11
  */
11
12
  const reservedModifierKeywords = ['shift', 'alt', 'meta', 'mod', 'ctrl', 'control'];
12
13
  const mappedKeys = {
@@ -71,28 +72,227 @@ function parseHotkey(hotkey, splitKey = '+', sequenceSplitKey = '>', useKey = fa
71
72
  }
72
73
  // #endregion
73
74
  // #region Display
74
- const APPLE_MODIFIERS = { mod: '⌘', meta: '⌘', ctrl: '⌃', control: '⌃', alt: '⌥', shift: '⇧' };
75
+ const MAC_MODIFIERS = { mod: '⌘', meta: '⌘', ctrl: '⌃', control: '⌃', alt: '⌥', shift: '⇧' };
75
76
  const OTHER_MODIFIERS = { mod: 'Ctrl', meta: 'Win', ctrl: 'Ctrl', control: 'Ctrl', alt: 'Alt', shift: 'Shift' };
77
+ const LEGACY_SYMBOLS = { '⌘': 'mod', '⌃': 'ctrl', '⌥': 'alt', '⇧': 'shift' };
78
+ // `react-hotkeys-hook` matches the physical key, so it knows punctuation by name (`slash`), never by character (`/`).
79
+ const PUNCTUATION_KEY_NAMES = {
80
+ '/': 'slash',
81
+ ',': 'comma',
82
+ '.': 'period',
83
+ ';': 'semicolon',
84
+ "'": 'quote',
85
+ '[': 'bracketleft',
86
+ ']': 'bracketright',
87
+ '\\': 'backslash',
88
+ '-': 'minus',
89
+ '=': 'equal',
90
+ '`': 'backquote',
91
+ };
92
+ const KEY_NAME_CHARACTERS = Object.fromEntries(Object.entries(PUNCTUATION_KEY_NAMES).map(([character, name]) => [name, character]));
93
+ // Characters typed with Shift on a US layout, and the key they sit on.
94
+ const SHIFTED_KEYS = {
95
+ '?': 'slash',
96
+ '<': 'comma',
97
+ '>': 'period',
98
+ ':': 'semicolon',
99
+ '"': 'quote',
100
+ '{': 'bracketleft',
101
+ '}': 'bracketright',
102
+ '|': 'backslash',
103
+ _: 'minus',
104
+ '~': 'backquote',
105
+ '!': '1',
106
+ '@': '2',
107
+ '#': '3',
108
+ $: '4',
109
+ '%': '5',
110
+ '^': '6',
111
+ '&': '7',
112
+ '*': '8',
113
+ '(': '9',
114
+ ')': '0',
115
+ };
116
+ /** The character a key name stands for (`slash` is `/`), or the name itself when it is not punctuation. */
117
+ const hotkeyCharacter = (key) => KEY_NAME_CHARACTERS[key] ?? key;
118
+ /**
119
+ * Accepts a hotkey in `react-hotkeys-hook` format (`mod+k`) or the symbol shorthand (`⌘K`, `⌘⇧P`,
120
+ * `⌘+Shift+K`) and returns the hook format. `⌘` becomes `mod`, so it also works with Ctrl outside
121
+ * macOS. Within a token, leading symbols are modifiers and whatever follows them is one key.
122
+ * Punctuation becomes the key name the hook matches on (`⌘/` is `mod+slash`).
123
+ *
124
+ * `forDisplay` keeps a shifted symbol as written (`⌘?`). Without it, a shifted symbol in a combination
125
+ * becomes Shift plus its key (`mod+shift+slash`), which is the form that can be registered.
126
+ */
127
+ const normalizeHotkey = (hotkey, { forDisplay = false } = {}) => {
128
+ const keys = hotkey
129
+ .split('+')
130
+ .flatMap((token) => {
131
+ const characters = [...token.trim()];
132
+ const symbolCount = characters.findIndex((character) => !(character in LEGACY_SYMBOLS));
133
+ const symbols = symbolCount === -1 ? characters : characters.slice(0, symbolCount);
134
+ const key = symbolCount === -1 ? '' : characters.slice(symbolCount).join('');
135
+ return [...symbols.map((symbol) => LEGACY_SYMBOLS[symbol]), PUNCTUATION_KEY_NAMES[key] ?? key.toLowerCase()];
136
+ })
137
+ .filter(Boolean);
138
+ // On its own a shifted symbol stays a character, so it is matched as typed on any keyboard layout.
139
+ const expandShifted = !forDisplay && keys.some(isHotkeyModifier);
140
+ return [...new Set(keys.flatMap((key) => (expandShifted && key in SHIFTED_KEYS ? ['shift', SHIFTED_KEYS[key]] : [key])))].join('+');
141
+ };
142
+ /**
143
+ * Turns an item's `shortcutKeys` into hook-format steps. Each entry is one step (`['⌘e']` is a combination,
144
+ * `['g', 'p']` is G then P), except that an entry holding only modifiers joins the entry after it, so the
145
+ * older `['⌘', 'H']` spelling still means ⌘H.
146
+ */
147
+ const toHotkeySteps = (shortcutKeys, options) => {
148
+ const steps = [];
149
+ let pendingModifiers = [];
150
+ for (const entry of shortcutKeys) {
151
+ const normalized = normalizeHotkey(entry, options);
152
+ if (!normalized)
153
+ continue;
154
+ if (normalized.split('+').every(isHotkeyModifier)) {
155
+ pendingModifiers.push(normalized);
156
+ continue;
157
+ }
158
+ steps.push([...pendingModifiers, normalized].join('+'));
159
+ pendingModifiers = [];
160
+ }
161
+ return pendingModifiers.length ? [...steps, pendingModifiers.join('+')] : steps;
162
+ };
163
+ /**
164
+ * Sorts an item shortcut by how it can be triggered:
165
+ * - `combination`: one step held with ⌘/Ctrl/Alt, safe to fire even while the user is typing.
166
+ * - `guarded`: one step that typing could produce (Shift+A) or a named key (F1), so it is ignored in fields.
167
+ * - `typed`: character keys pressed in turn (`?`, G then P), also ignored in fields.
168
+ * - `unsupported`: several steps with a modifier or named key, which no handler can match.
169
+ */
170
+ const getItemHotkeyKind = (steps) => {
171
+ const stepKeys = steps.map((step) => step.split('+'));
172
+ const keys = stepKeys.flat();
173
+ const modifiers = keys.filter(isHotkeyModifier);
174
+ // A step with no key of its own would fire on every press of the modifier.
175
+ if (stepKeys.some((step) => step.every(isHotkeyModifier)))
176
+ return 'unsupported';
177
+ if (modifiers.length === 0 && keys.every((key) => hotkeyCharacter(key).length === 1))
178
+ return 'typed';
179
+ if (steps.length !== 1)
180
+ return 'unsupported';
181
+ return modifiers.some((modifier) => modifier !== 'shift') ? 'combination' : 'guarded';
182
+ };
183
+ const EDITABLE_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'];
184
+ const EDITABLE_ROLES = ['textbox', 'searchbox', 'combobox', 'spinbutton'];
185
+ const isEditable = (target) => target instanceof HTMLElement &&
186
+ (target.isContentEditable || EDITABLE_TAGS.includes(target.tagName) || EDITABLE_ROLES.includes(target.getAttribute('role') ?? ''));
187
+ const deepActiveElement = () => {
188
+ let element = document.activeElement;
189
+ while (element?.shadowRoot?.activeElement)
190
+ element = element.shadowRoot.activeElement;
191
+ return element;
192
+ };
76
193
  /**
77
- * Whether `mod` means ⌘ on this device. Mirrors `react-hotkeys-hook`'s own rule exactly (macOS only, not
78
- * iOS/iPadOS) so a hint always names the key that fires the hotkey. Always `false` on the server.
194
+ * Whether a key event happened while the user is typing in a field, including one inside a shadow root.
195
+ * Checks the focused element as well as the event target, because react-aria re-dispatches keys typed
196
+ * in a combobox onto its list.
79
197
  */
80
- const isApplePlatform = () => typeof navigator !== 'undefined' && /mac/i.test(navigator.userAgent) && !/iphone|ipad|ipod/i.test(navigator.userAgent);
198
+ const isTypingInField = (event) => isEditable(event.composedPath()[0] ?? event.target) || isEditable(event.target) || isEditable(deepActiveElement());
199
+ const startsWith = (sequence, prefix) => prefix.every((key, index) => sequence[index] === key);
200
+ /**
201
+ * Feeds one typed key into the keys typed so far and reports whether a sequence is now complete.
202
+ * Returns the index of the matched sequence and an empty buffer, or the buffer to carry forward:
203
+ * the longest run of recent keys that still begins some sequence.
204
+ */
205
+ const advanceKeySequence = (typedKeys, key, sequences) => {
206
+ const typed = [...typedKeys, key];
207
+ for (let start = 0; start < typed.length; start++) {
208
+ const candidate = typed.slice(start);
209
+ const matched = sequences.findIndex((sequence) => sequence.length === candidate.length && startsWith(sequence, candidate));
210
+ if (matched !== -1)
211
+ return { buffer: [], matched };
212
+ if (sequences.some((sequence) => startsWith(sequence, candidate)))
213
+ return { buffer: candidate };
214
+ }
215
+ return { buffer: [] };
216
+ };
217
+ const NAMED_KEYS = new Set([
218
+ 'enter',
219
+ 'escape',
220
+ 'tab',
221
+ 'space',
222
+ 'backspace',
223
+ 'delete',
224
+ 'insert',
225
+ 'home',
226
+ 'end',
227
+ 'pageup',
228
+ 'pagedown',
229
+ 'arrowup',
230
+ 'arrowdown',
231
+ 'arrowleft',
232
+ 'arrowright',
233
+ ...Object.values(PUNCTUATION_KEY_NAMES),
234
+ ]);
235
+ const FUNCTION_KEY = /^f([1-9]|1\d|2[0-4])$/;
236
+ /**
237
+ * Whether a normalised hotkey is made only of modifiers and real keys. Display props accept any text
238
+ * (`"Ctrl K"`, `"Hold to talk"`), and formatting text that is not a hotkey would mangle it.
239
+ */
240
+ const isRecognisedHotkey = (hotkey) => {
241
+ const keys = hotkey.split('+').map(mapCode).filter(Boolean);
242
+ const isKey = (key) => [...key].length === 1 || FUNCTION_KEY.test(key) || NAMED_KEYS.has(key);
243
+ // A hotkey with no key of its own is usually one whose `+` key was lost in parsing (`⌘+`), so leave it alone.
244
+ return keys.some(isKey) && keys.every((key) => isHotkeyModifier(key) || isKey(key));
245
+ };
246
+ const KEY_LABELS = {
247
+ escape: 'Esc',
248
+ arrowup: '↑',
249
+ arrowdown: '↓',
250
+ arrowleft: '←',
251
+ arrowright: '→',
252
+ pageup: 'Page Up',
253
+ pagedown: 'Page Down',
254
+ };
255
+ const keyLabel = (key) => {
256
+ const character = hotkeyCharacter(key);
257
+ if (character.length === 1 || FUNCTION_KEY.test(key))
258
+ return character.toUpperCase();
259
+ return KEY_LABELS[key] ?? `${key[0].toUpperCase()}${key.slice(1)}`;
260
+ };
261
+ // Outside macOS, modifiers are conventionally written Win, Ctrl, Alt, Shift whatever order the author used.
262
+ const MODIFIER_ORDER = ['meta', 'mod', 'ctrl', 'control', 'alt', 'shift'];
81
263
  /**
82
264
  * Formats a hotkey for display: `mod+k` reads `⌘K` on macOS and `Ctrl K` elsewhere.
83
- * When several comma-separated alternatives are given, only the first is shown.
265
+ * `isMac` says whether `mod` is ⌘. For a `react-hotkeys-hook` key that is macOS only (not iOS).
266
+ * Formats one hotkey: of several comma-separated alternatives it draws only the first. `formatHotkeyLabel`
267
+ * is the entry point that draws them all.
84
268
  */
85
- const formatHotkeyHint = (hotkey, isApple) => {
86
- const modifiers = isApple ? APPLE_MODIFIERS : OTHER_MODIFIERS;
269
+ const formatHotkeyHint = (hotkey, isMac) => {
270
+ const modifiers = isMac ? MAC_MODIFIERS : OTHER_MODIFIERS;
87
271
  const [firstHotkey = ''] = parseKeysHookInput(hotkey);
88
- return firstHotkey
89
- .split('+')
90
- .map(mapCode)
91
- .filter(Boolean)
92
- .map((key) => (isHotkeyModifier(key) ? modifiers[key] : key.toUpperCase()))
93
- .join(isApple ? '' : ' ');
272
+ const keys = firstHotkey.split('+').map(mapCode).filter(Boolean);
273
+ const heldKeys = keys.filter(isHotkeyModifier);
274
+ const orderedModifiers = isMac ? heldKeys : [...heldKeys].sort((first, second) => MODIFIER_ORDER.indexOf(first) - MODIFIER_ORDER.indexOf(second));
275
+ return [...orderedModifiers.map((key) => modifiers[key]), ...keys.filter((key) => !isHotkeyModifier(key)).map(keyLabel)].join(isMac ? '' : ' ');
276
+ };
277
+ // `>` or `->` separates the steps of a sequence, unless `>` is itself the key (`mod+>`).
278
+ const SEQUENCE_SEPARATOR = /(?<=[^+\s])\s*(?:->|>)\s*(?=\S)/;
279
+ const ALTERNATIVE_SEPARATOR = /,(?=\s*\S)/;
280
+ const formatSteps = (hotkey, isMac) => {
281
+ const steps = hotkey.split(SEQUENCE_SEPARATOR).map((step) => normalizeHotkey(step, { forDisplay: true }));
282
+ return steps.every(isRecognisedHotkey) ? steps.map((step) => formatHotkeyHint(step, isMac)).join(' → ') : undefined;
283
+ };
284
+ /**
285
+ * Labels a shortcut for the platform. Accepts `react-hotkeys-hook` syntax (`mod+k`, `g>p`), the symbol
286
+ * shorthand (`⌘K`) or a shortcut written out (`Ctrl+K`), and draws each distinct comma-separated alternative.
287
+ * Text that is not a hotkey (`Hold to talk`) is returned exactly as written, so a display prop can take
288
+ * any label.
289
+ */
290
+ const formatHotkeyLabel = (hotkey, isMac) => {
291
+ const alternatives = hotkey.split(ALTERNATIVE_SEPARATOR).map((alternative) => formatSteps(alternative, isMac));
292
+ // `mod+k, ctrl+k` is two keys on a Mac but one label elsewhere, so repeats are dropped.
293
+ return alternatives.every((alternative) => alternative !== undefined) ? [...new Set(alternatives)].join(', ') : hotkey;
94
294
  };
95
295
  // #endregion
96
296
 
97
- export { formatHotkeyHint, isApplePlatform, isHotkeyModifier, mapCode, parseHotkey, parseKeysHookInput };
297
+ export { advanceKeySequence, formatHotkeyHint, formatHotkeyLabel, getItemHotkeyKind, hotkeyCharacter, isHotkeyModifier, isRecognisedHotkey, isTypingInField, mapCode, normalizeHotkey, parseHotkey, parseKeysHookInput, toHotkeySteps };
98
298
  //# sourceMappingURL=hotkeys.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hotkeys.utils.js","sources":["../../../../src/utilities/__internal__/hotkeysUtils/hotkeys.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;AASG;AAoBH,MAAM,wBAAwB,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC;AAEnF,MAAM,UAAU,GAA2B;AACzC,IAAA,GAAG,EAAE,QAAQ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AAE,KAAK,CAAC,CAAC;;AAE9G,IAAA,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,WAAW,KAAK,WAAW,KAAK,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM;AACxH;AACA;;;;"}
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Works out the operating system from a user-agent string. Best effort: an iPad in desktop mode
5
+ * reports itself as a Mac, and ChromeOS reads as Linux. The iOS and Mac tests mirror the rule
6
+ * `react-hotkeys-hook` uses for `mod`, so `macos` is exactly where ⌘ fires a `mod` hotkey.
7
+ */
8
+ const detectPlatformOs = (userAgent) => {
9
+ if (/iphone|ipad|ipod/i.test(userAgent))
10
+ return 'ios';
11
+ if (/mac/i.test(userAgent))
12
+ return 'macos';
13
+ if (/android/i.test(userAgent))
14
+ return 'android';
15
+ if (/windows|win32|win64/i.test(userAgent))
16
+ return 'windows';
17
+ if (/linux|x11|\bcros\b/i.test(userAgent))
18
+ return 'linux';
19
+ return 'unknown';
20
+ };
21
+ /** The operating system of the current device; `unknown` when there is no browser user agent, as on the server. */
22
+ const getPlatformOs = () => (typeof navigator === 'undefined' ? 'unknown' : detectPlatformOs(navigator.userAgent ?? ''));
23
+
24
+ exports.detectPlatformOs = detectPlatformOs;
25
+ exports.getPlatformOs = getPlatformOs;
26
+ //# sourceMappingURL=platform.utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.utils.cjs","sources":["../../../../src/utilities/__internal__/platformUtils/platform.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;AAIG;AACI,MAAM,gBAAgB,GAAG,CAAC,SAAiB,KAAgB;AAChE,IAAA,IAAI,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC;AAAE,QAAA,OAAO,KAAK;AACrD,IAAA,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;AAAE,QAAA,OAAO,OAAO;AAC1C,IAAA,IAAI,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC;AAAE,QAAA,OAAO,SAAS;AAChD,IAAA,IAAI,sBAAsB,CAAC,IAAI,CAAC,SAAS,CAAC;AAAE,QAAA,OAAO,SAAS;AAC5D,IAAA,IAAI,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC;AAAE,QAAA,OAAO,OAAO;AACzD,IAAA,OAAO,SAAS;AAClB;AAEA;AACO,MAAM,aAAa,GAAG,OAAmB,OAAO,SAAS,KAAK,WAAW,GAAG,SAAS,GAAG,gBAAgB,CAAC,SAAS,CAAC,SAAS,IAAI,EAAE,CAAC;;;;;"}
@@ -0,0 +1,10 @@
1
+ export type PlatformOs = 'macos' | 'ios' | 'windows' | 'android' | 'linux' | 'unknown';
2
+ /**
3
+ * Works out the operating system from a user-agent string. Best effort: an iPad in desktop mode
4
+ * reports itself as a Mac, and ChromeOS reads as Linux. The iOS and Mac tests mirror the rule
5
+ * `react-hotkeys-hook` uses for `mod`, so `macos` is exactly where ⌘ fires a `mod` hotkey.
6
+ */
7
+ export declare const detectPlatformOs: (userAgent: string) => PlatformOs;
8
+ /** The operating system of the current device; `unknown` when there is no browser user agent, as on the server. */
9
+ export declare const getPlatformOs: () => PlatformOs;
10
+ //# sourceMappingURL=platform.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.utils.d.ts","sourceRoot":"","sources":["../../../../src/utilities/__internal__/platformUtils/platform.utils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,KAAK,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAEvF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,WAAW,MAAM,KAAG,UAOpD,CAAC;AAEF,mHAAmH;AACnH,eAAO,MAAM,aAAa,QAAO,UAA0G,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Works out the operating system from a user-agent string. Best effort: an iPad in desktop mode
3
+ * reports itself as a Mac, and ChromeOS reads as Linux. The iOS and Mac tests mirror the rule
4
+ * `react-hotkeys-hook` uses for `mod`, so `macos` is exactly where ⌘ fires a `mod` hotkey.
5
+ */
6
+ const detectPlatformOs = (userAgent) => {
7
+ if (/iphone|ipad|ipod/i.test(userAgent))
8
+ return 'ios';
9
+ if (/mac/i.test(userAgent))
10
+ return 'macos';
11
+ if (/android/i.test(userAgent))
12
+ return 'android';
13
+ if (/windows|win32|win64/i.test(userAgent))
14
+ return 'windows';
15
+ if (/linux|x11|\bcros\b/i.test(userAgent))
16
+ return 'linux';
17
+ return 'unknown';
18
+ };
19
+ /** The operating system of the current device; `unknown` when there is no browser user agent, as on the server. */
20
+ const getPlatformOs = () => (typeof navigator === 'undefined' ? 'unknown' : detectPlatformOs(navigator.userAgent ?? ''));
21
+
22
+ export { detectPlatformOs, getPlatformOs };
23
+ //# sourceMappingURL=platform.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.utils.js","sources":["../../../../src/utilities/__internal__/platformUtils/platform.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA;;;;AAIG;AACI,MAAM,gBAAgB,GAAG,CAAC,SAAiB,KAAgB;AAChE,IAAA,IAAI,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC;AAAE,QAAA,OAAO,KAAK;AACrD,IAAA,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;AAAE,QAAA,OAAO,OAAO;AAC1C,IAAA,IAAI,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC;AAAE,QAAA,OAAO,SAAS;AAChD,IAAA,IAAI,sBAAsB,CAAC,IAAI,CAAC,SAAS,CAAC;AAAE,QAAA,OAAO,SAAS;AAC5D,IAAA,IAAI,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC;AAAE,QAAA,OAAO,OAAO;AACzD,IAAA,OAAO,SAAS;AAClB;AAEA;AACO,MAAM,aAAa,GAAG,OAAmB,OAAO,SAAS,KAAK,WAAW,GAAG,SAAS,GAAG,gBAAgB,CAAC,SAAS,CAAC,SAAS,IAAI,EAAE,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flipdish/ui-library",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "description": "Flipdish Design System — atomic-design component library (Tailwind v4 + UntitledUI + React Aria).",
5
5
  "type": "module",
6
6
  "imports": {