@lvl99dotcom/paintcanvas 0.3.1 → 0.5.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 (212) hide show
  1. package/README.md +30 -15
  2. package/dist/lib/brushes/StrokeEngine/index.d.ts +2 -2
  3. package/dist/lib/brushes/StrokeEngine/index.js +26 -28
  4. package/dist/lib/brushes/presets/round/index.d.ts +1 -1
  5. package/dist/lib/brushes/presets/round/index.js +12 -7
  6. package/dist/lib/brushes/presets/square/index.d.ts +1 -1
  7. package/dist/lib/brushes/presets/square/index.js +7 -3
  8. package/dist/lib/brushes/shapeImage/index.d.ts +7 -3
  9. package/dist/lib/brushes/shapeImage/index.js +15 -9
  10. package/dist/lib/brushes/shapes/index.d.ts +18 -0
  11. package/dist/lib/brushes/shapes/index.js +86 -0
  12. package/dist/lib/classes/BrushSettings/index.d.ts +53 -2
  13. package/dist/lib/classes/BrushSettings/index.js +85 -14
  14. package/dist/lib/classes/KeyboardShortcuts/index.d.ts +47 -7
  15. package/dist/lib/classes/KeyboardShortcuts/index.js +145 -20
  16. package/dist/lib/classes/PaintCanvas/index.d.ts +123 -27
  17. package/dist/lib/classes/PaintCanvas/index.js +208 -41
  18. package/dist/lib/classes/PaintCanvas/tool.d.ts +15 -0
  19. package/dist/lib/classes/PaintCanvas/tool.js +18 -0
  20. package/dist/lib/classes/Palette/index.d.ts +58 -0
  21. package/dist/lib/classes/Palette/index.js +92 -0
  22. package/dist/lib/classes/SettingsAutosave/index.d.ts +53 -0
  23. package/dist/lib/classes/SettingsAutosave/index.js +98 -0
  24. package/dist/lib/classes/ShortcutSettings/index.d.ts +63 -0
  25. package/dist/lib/classes/ShortcutSettings/index.js +110 -0
  26. package/dist/lib/classes/UiSettings/index.d.ts +68 -0
  27. package/dist/lib/classes/UiSettings/index.js +82 -0
  28. package/dist/lib/palette/index.d.ts +49 -0
  29. package/dist/lib/palette/index.js +82 -0
  30. package/dist/lib/palette/schema.d.ts +45 -0
  31. package/dist/lib/palette/schema.js +41 -0
  32. package/dist/lib/rendering/cursors/index.d.ts +2 -0
  33. package/dist/lib/rendering/cursors/index.js +3 -1
  34. package/dist/lib/rendering/sample/index.js +3 -2
  35. package/dist/lib/settings/index.d.ts +63 -0
  36. package/dist/lib/settings/index.js +93 -0
  37. package/dist/lib/settings/schema.d.ts +168 -0
  38. package/dist/lib/settings/schema.js +116 -0
  39. package/dist/lib/storage/index.d.ts +36 -5
  40. package/dist/lib/storage/index.js +87 -29
  41. package/dist/lib/utils/colour/index.d.ts +72 -0
  42. package/dist/lib/utils/colour/index.js +154 -0
  43. package/dist/lib/utils/shortcuts/index.d.ts +174 -11
  44. package/dist/lib/utils/shortcuts/index.js +391 -145
  45. package/dist/lib/validation/validators.generated.d.ts +5 -0
  46. package/dist/lib/validation/validators.generated.js +1040 -1
  47. package/dist/locales/en-GB.js +96 -3
  48. package/dist/locales/en-US.js +96 -3
  49. package/dist/locales/fr.js +96 -3
  50. package/dist/locales/ja.js +96 -3
  51. package/dist/locales/ko.js +96 -3
  52. package/dist/locales/zh-Hans.js +96 -3
  53. package/dist/locales/zh-Hant.js +96 -3
  54. package/dist/package.js +1 -1
  55. package/dist/testing/recordingCanvas.js +2 -1
  56. package/dist/ui/base/index.d.ts +2 -2
  57. package/dist/ui/dismiss/index.d.ts +21 -0
  58. package/dist/ui/dismiss/index.js +27 -0
  59. package/dist/ui/drag/index.d.ts +51 -0
  60. package/dist/ui/drag/index.js +81 -0
  61. package/dist/ui/elements/PaintCanvas/index.d.ts +57 -50
  62. package/dist/ui/elements/PaintCanvas/index.js +141 -174
  63. package/dist/ui/elements/PaintCanvas/style.js +1 -1
  64. package/dist/ui/elements/PcAppSettings/index.d.ts +59 -0
  65. package/dist/ui/elements/PcAppSettings/index.js +222 -0
  66. package/dist/ui/elements/PcBrushConfig/index.d.ts +9 -2
  67. package/dist/ui/elements/PcBrushConfig/index.js +47 -7
  68. package/dist/ui/elements/PcBrushConfig/style.js +1 -1
  69. package/dist/ui/elements/PcBrushSize/index.d.ts +53 -0
  70. package/dist/ui/elements/PcBrushSize/index.js +66 -0
  71. package/dist/ui/elements/PcBrushTest/index.d.ts +26 -0
  72. package/dist/ui/elements/PcBrushTest/index.js +73 -5
  73. package/dist/ui/elements/PcBrushTest/style.js +1 -1
  74. package/dist/ui/elements/PcCanvas/index.d.ts +22 -2
  75. package/dist/ui/elements/PcCanvas/index.js +60 -15
  76. package/dist/ui/elements/PcCanvasMap/style.js +1 -1
  77. package/dist/ui/elements/PcClipboardTools/index.d.ts +48 -0
  78. package/dist/ui/elements/PcClipboardTools/index.js +118 -0
  79. package/dist/ui/elements/PcColourPair/index.d.ts +43 -0
  80. package/dist/ui/elements/PcColourPair/index.js +125 -0
  81. package/dist/ui/elements/PcContextMenu/index.d.ts +71 -34
  82. package/dist/ui/elements/PcContextMenu/index.js +128 -97
  83. package/dist/ui/elements/PcInputSettings/index.d.ts +13 -0
  84. package/dist/ui/elements/PcInputSettings/index.js +16 -1
  85. package/dist/ui/elements/PcLayerItem/index.d.ts +13 -34
  86. package/dist/ui/elements/PcLayerItem/index.js +39 -91
  87. package/dist/ui/elements/PcLayerItem/style.js +1 -1
  88. package/dist/ui/elements/PcMenu/index.d.ts +138 -0
  89. package/dist/ui/elements/PcMenu/index.js +296 -0
  90. package/dist/ui/elements/PcNumberSlider/index.d.ts +137 -0
  91. package/dist/ui/elements/PcNumberSlider/index.js +247 -0
  92. package/dist/ui/elements/PcPane/index.d.ts +120 -0
  93. package/dist/ui/elements/PcPane/index.js +394 -0
  94. package/dist/ui/elements/PcPanel/index.d.ts +26 -8
  95. package/dist/ui/elements/PcPanel/index.js +76 -8
  96. package/dist/ui/elements/{PcBrushMenu → PcPanelBrushes}/index.d.ts +22 -21
  97. package/dist/ui/elements/{PcBrushMenu → PcPanelBrushes}/index.js +24 -57
  98. package/dist/ui/elements/PcPanelBrushes/style.js +3 -0
  99. package/dist/ui/elements/PcPanelColours/index.d.ts +171 -0
  100. package/dist/ui/elements/PcPanelColours/index.js +650 -0
  101. package/dist/ui/elements/PcPanelColours/style.js +3 -0
  102. package/dist/ui/elements/{PcLayersMenu → PcPanelLayers}/index.d.ts +17 -4
  103. package/dist/ui/elements/{PcLayersMenu → PcPanelLayers}/index.js +17 -10
  104. package/dist/ui/elements/PcPanelLayers/style.js +3 -0
  105. package/dist/ui/elements/PcPopover/index.d.ts +39 -1
  106. package/dist/ui/elements/PcPopover/index.js +72 -4
  107. package/dist/ui/elements/PcShortcutSettings/index.d.ts +69 -0
  108. package/dist/ui/elements/PcShortcutSettings/index.js +273 -0
  109. package/dist/ui/elements/PcThemePicker/index.d.ts +17 -15
  110. package/dist/ui/elements/PcThemePicker/index.js +22 -21
  111. package/dist/ui/elements/PcToolSettings/index.d.ts +48 -9
  112. package/dist/ui/elements/PcToolSettings/index.js +384 -319
  113. package/dist/ui/elements/PcToolSettings/style.js +1 -1
  114. package/dist/ui/elements/PcToolbar/index.d.ts +62 -12
  115. package/dist/ui/elements/PcToolbar/index.js +119 -57
  116. package/dist/ui/elements/PcToolbar/style.js +1 -1
  117. package/dist/ui/icons/images/icon-brush@2x.js +3 -0
  118. package/dist/ui/icons/images/icon-circle-mask@2x.js +3 -0
  119. package/dist/ui/icons/images/icon-clipboard@2x.js +3 -0
  120. package/dist/ui/icons/images/icon-cog@2x.js +3 -0
  121. package/dist/ui/icons/images/icon-cursor@2x.js +3 -0
  122. package/dist/ui/icons/images/icon-diagonal-tlbr-size@2x.js +3 -0
  123. package/dist/ui/icons/images/icon-diagonal-trbl-size@2x.js +3 -0
  124. package/dist/ui/icons/images/icon-eraser@2x.js +3 -0
  125. package/dist/ui/icons/images/icon-eyedropper@2x.js +3 -0
  126. package/dist/ui/icons/images/icon-flip-horizontal@2x.js +3 -0
  127. package/dist/ui/icons/images/icon-flip-vertical@2x.js +3 -0
  128. package/dist/ui/icons/images/icon-focus-pen@2x.js +3 -0
  129. package/dist/ui/icons/images/icon-freehand-mask@2x.js +3 -0
  130. package/dist/ui/icons/images/icon-hidden@2x.js +3 -0
  131. package/dist/ui/icons/images/icon-horizontal-size@2x.js +3 -0
  132. package/dist/ui/icons/images/icon-layers@2x.js +3 -0
  133. package/dist/ui/icons/images/icon-linked@2x.js +3 -0
  134. package/dist/ui/icons/images/icon-locked@2x.js +3 -0
  135. package/dist/ui/icons/images/icon-moon@2x.js +3 -0
  136. package/dist/ui/icons/images/icon-pan@2x.js +3 -0
  137. package/dist/ui/icons/images/icon-polygon-mask@2x.js +3 -0
  138. package/dist/ui/icons/images/icon-pressure@2x.js +3 -0
  139. package/dist/ui/icons/images/icon-randomise@2x.js +3 -0
  140. package/dist/ui/icons/images/icon-rectangle-mask@2x.js +3 -0
  141. package/dist/ui/icons/images/icon-redo@2x.js +3 -0
  142. package/dist/ui/icons/images/icon-rotate-90-left@2x.js +3 -0
  143. package/dist/ui/icons/images/icon-rotate-90-right@2x.js +3 -0
  144. package/dist/ui/icons/images/icon-rotate@2x.js +3 -0
  145. package/dist/ui/icons/images/icon-smoothing-bezier-cubic@2x.js +3 -0
  146. package/dist/ui/icons/images/icon-smoothing-bezier-quad@2x.js +3 -0
  147. package/dist/ui/icons/images/icon-smoothing-linear@2x.js +3 -0
  148. package/dist/ui/icons/images/icon-star@2x.js +3 -0
  149. package/dist/ui/icons/images/icon-sun@2x.js +3 -0
  150. package/dist/ui/icons/images/icon-tilt@2x.js +3 -0
  151. package/dist/ui/icons/images/icon-undo@2x.js +3 -0
  152. package/dist/ui/icons/images/icon-unlinked@2x.js +3 -0
  153. package/dist/ui/icons/images/icon-unlocked@2x.js +3 -0
  154. package/dist/ui/icons/images/icon-vertical-size@2x.js +3 -0
  155. package/dist/ui/icons/images/icon-visible@2x.js +3 -0
  156. package/dist/ui/icons/images/icon-zoom-in@2x.js +3 -0
  157. package/dist/ui/icons/images/icon-zoom-out@2x.js +3 -0
  158. package/dist/ui/icons/images/icon-zoom@2x.js +3 -0
  159. package/dist/ui/icons/index.d.ts +1 -1
  160. package/dist/ui/icons/index.js +84 -72
  161. package/dist/ui/index.d.ts +13 -2
  162. package/dist/ui/index.js +16 -4
  163. package/dist/ui/layout/index.d.ts +9 -1
  164. package/dist/ui/layout/index.js +11 -2
  165. package/dist/ui/tokens/index.d.ts +5 -4
  166. package/dist/ui/tokens/index.js +15 -8
  167. package/locales/en-GB.json +96 -3
  168. package/locales/en-US.json +96 -3
  169. package/locales/fr.json +96 -3
  170. package/locales/ja.json +96 -3
  171. package/locales/ko.json +96 -3
  172. package/locales/zh-Hans.json +96 -3
  173. package/locales/zh-Hant.json +96 -3
  174. package/package.json +11 -4
  175. package/dist/ui/elements/PcBrushMenu/style.js +0 -3
  176. package/dist/ui/elements/PcLayersMenu/style.js +0 -3
  177. package/dist/ui/icons/images/brush.js +0 -3
  178. package/dist/ui/icons/images/circle-mask.js +0 -3
  179. package/dist/ui/icons/images/clipboard.js +0 -3
  180. package/dist/ui/icons/images/cursor.js +0 -3
  181. package/dist/ui/icons/images/eraser.js +0 -3
  182. package/dist/ui/icons/images/eyedropper.js +0 -3
  183. package/dist/ui/icons/images/flip-horizontal.js +0 -3
  184. package/dist/ui/icons/images/flip-vertical.js +0 -3
  185. package/dist/ui/icons/images/focus-pen.js +0 -3
  186. package/dist/ui/icons/images/freehand-mask.js +0 -3
  187. package/dist/ui/icons/images/hidden.js +0 -3
  188. package/dist/ui/icons/images/layers.js +0 -3
  189. package/dist/ui/icons/images/linked.js +0 -3
  190. package/dist/ui/icons/images/locked.js +0 -3
  191. package/dist/ui/icons/images/moon.js +0 -3
  192. package/dist/ui/icons/images/pan.js +0 -3
  193. package/dist/ui/icons/images/polygon-mask.js +0 -3
  194. package/dist/ui/icons/images/pressure.js +0 -3
  195. package/dist/ui/icons/images/randomise.js +0 -3
  196. package/dist/ui/icons/images/rectangle-mask.js +0 -3
  197. package/dist/ui/icons/images/redo.js +0 -3
  198. package/dist/ui/icons/images/rotate-90-left.js +0 -3
  199. package/dist/ui/icons/images/rotate-90-right.js +0 -3
  200. package/dist/ui/icons/images/smoothing-bezier-cubic.js +0 -3
  201. package/dist/ui/icons/images/smoothing-bezier-quad.js +0 -3
  202. package/dist/ui/icons/images/smoothing-linear.js +0 -3
  203. package/dist/ui/icons/images/star.js +0 -3
  204. package/dist/ui/icons/images/sun.js +0 -3
  205. package/dist/ui/icons/images/tilt.js +0 -3
  206. package/dist/ui/icons/images/undo.js +0 -3
  207. package/dist/ui/icons/images/unlinked.js +0 -3
  208. package/dist/ui/icons/images/unlocked.js +0 -3
  209. package/dist/ui/icons/images/visible.js +0 -3
  210. package/dist/ui/icons/images/zoom-in.js +0 -3
  211. package/dist/ui/icons/images/zoom-out.js +0 -3
  212. package/dist/ui/icons/images/zoom.js +0 -3
@@ -1,16 +1,24 @@
1
- import { Tool } from "../../classes/PaintCanvas";
1
+ import { Tool } from "../../classes/PaintCanvas/tool";
2
2
  /** Actions that keyboard shortcuts trigger */
3
3
  export type ShortcutAction = {
4
4
  type: "tool";
5
5
  tool: Tool;
6
+ } | {
7
+ type: "pan";
6
8
  } | {
7
9
  type: "brush-smaller";
8
10
  } | {
9
11
  type: "brush-bigger";
12
+ } | {
13
+ type: "brush-less-opaque";
14
+ } | {
15
+ type: "brush-more-opaque";
10
16
  } | {
11
17
  type: "toggle-interface";
12
18
  } | {
13
19
  type: "select-all";
20
+ } | {
21
+ type: "invert-selection";
14
22
  } | {
15
23
  type: "deselect";
16
24
  } | {
@@ -31,21 +39,124 @@ export type ShortcutAction = {
31
39
  type: "cancel";
32
40
  } | {
33
41
  type: "commit";
42
+ } | {
43
+ type: "fill-foreground";
44
+ } | {
45
+ type: "fill-background";
46
+ } | {
47
+ type: "swap-colours";
48
+ } | {
49
+ type: "zoom-in";
50
+ } | {
51
+ type: "zoom-out";
52
+ } | {
53
+ type: "reset-zoom";
54
+ } | {
55
+ type: "layer-opacity";
56
+ opacity: number;
34
57
  };
35
- /** A key combination. `cmd` matches the Command key on macOS and Ctrl on Windows/Linux. */
58
+ /**
59
+ * A key combination. `cmd` is the Command key on Apple devices and Ctrl elsewhere; `ctrl` is the Control key on Apple
60
+ * devices only (elsewhere Ctrl is `cmd`).
61
+ */
36
62
  export interface KeyCombo {
37
- /** Lowercase `KeyboardEvent.key` value */
63
+ /** Lowercase `KeyboardEvent.key` value, e.g. `a`, `[`, `backspace` or ` ` (Space) */
38
64
  key: string;
39
65
  cmd?: boolean;
66
+ ctrl?: boolean;
40
67
  shift?: boolean;
41
68
  alt?: boolean;
42
69
  }
70
+ /** A key combination and the action it runs */
43
71
  export interface Shortcut extends KeyCombo {
44
72
  action: ShortcutAction;
45
73
  }
46
- /** All keyboard shortcuts */
74
+ /** Groups shortcuts are listed in, e.g. in the keyboard shortcuts settings */
75
+ export type ShortcutGroup = "tools" | "brushes" | "masking" | "fills" | "viewport" | "layers" | "clipboard" | "history" | "general";
76
+ /** A keyboard shortcut action and its default key combinations */
77
+ export interface ShortcutDefinition {
78
+ /** Names the action, e.g. to save its key combination and to translate its name (`paintCanvas.shortcuts.<id>`) */
79
+ id: string;
80
+ group: ShortcutGroup;
81
+ action: ShortcutAction;
82
+ /** Default key combinations (a configurable action has one) */
83
+ combos: readonly KeyCombo[];
84
+ /** Whether users can change or remove its key combination */
85
+ configurable: boolean;
86
+ }
87
+ /** ID of the action run while its key is held: pan, returning to the last tool when released */
88
+ export declare const HOLD_TO_PAN = "pan";
89
+ /** Every keyboard shortcut action, in the order they are listed */
90
+ export declare const SHORTCUT_DEFINITIONS: readonly ShortcutDefinition[];
91
+ /** The actions users can change the key combinations of */
92
+ export declare const CONFIGURABLE_SHORTCUTS: readonly ShortcutDefinition[];
93
+ /** The actions whose key combinations can't be changed */
94
+ export declare const FIXED_SHORTCUTS: readonly ShortcutDefinition[];
95
+ /** The key combination of each configurable action, by ID (null when it has none) */
96
+ export type ShortcutBindings = Record<string, KeyCombo | null>;
97
+ /**
98
+ * A key combination with only the modifiers that are on, e.g. to compare or save it.
99
+ *
100
+ * @example
101
+ * normaliseCombo({ key: "s", cmd: true, shift: false }); // { key: "s", cmd: true }
102
+ */
103
+ export declare const normaliseCombo: ({ key, cmd, ctrl, shift, alt, }: KeyCombo) => KeyCombo;
104
+ /**
105
+ * Whether two key combinations are the same.
106
+ *
107
+ * @example
108
+ * sameCombo({ key: "s", cmd: true }, { key: "s", cmd: true, shift: false }); // true
109
+ */
110
+ export declare const sameCombo: (a: KeyCombo, b: KeyCombo) => boolean;
111
+ /**
112
+ * Keep a valid key combination from an untrusted value (e.g. stored or imported). Undefined if it isn't one.
113
+ *
114
+ * @example
115
+ * sanitiseCombo({ key: "s", cmd: true, extra: 1 }); // { key: "s", cmd: true }
116
+ * sanitiseCombo({ key: "" }); // undefined
117
+ */
118
+ export declare const sanitiseCombo: (input: unknown) => KeyCombo | undefined;
119
+ /**
120
+ * The default key combination of each configurable action.
121
+ *
122
+ * @example
123
+ * defaultShortcutBindings()["tool-brush"]; // { key: "b" }
124
+ */
125
+ export declare const defaultShortcutBindings: () => ShortcutBindings;
126
+ /**
127
+ * The fixed action that uses a key combination, if any.
128
+ *
129
+ * @example
130
+ * fixedShortcutFor({ key: "z", cmd: true })?.id; // "undo"
131
+ */
132
+ export declare const fixedShortcutFor: (combo: KeyCombo) => ShortcutDefinition | undefined;
133
+ /**
134
+ * Keep valid key combinations from an untrusted value (e.g. stored or imported), using `defaults` for actions that are
135
+ * missing or invalid. `null` removes an action's key combination. A key combination a fixed action uses, or that an
136
+ * earlier action (in `SHORTCUT_DEFINITIONS` order) already has, is removed. Unknown actions are left out.
137
+ *
138
+ * @example
139
+ * sanitiseShortcutBindings({ "tool-brush": { key: "p" }, cut: null }, defaultShortcutBindings());
140
+ */
141
+ export declare const sanitiseShortcutBindings: (input: unknown, defaults: ShortcutBindings) => ShortcutBindings;
142
+ /**
143
+ * The shortcuts to match key presses against: the configurable actions' key combinations (except the hold-to-pan key,
144
+ * which acts while held) and the fixed ones.
145
+ *
146
+ * @example
147
+ * shortcutsFor(defaultShortcutBindings()).find((s) => s.key === "b")?.action; // { type: "tool", tool: Tool.Brush }
148
+ */
149
+ export declare const shortcutsFor: (bindings: ShortcutBindings) => Shortcut[];
150
+ /** All keyboard shortcuts with their default key combinations */
47
151
  export declare const SHORTCUTS: readonly Shortcut[];
48
- /** Key held to pan temporarily (handled separately because it acts while held, not on press) */
152
+ /**
153
+ * Whether a platform (`navigator.platform` by default) is an Apple device, where "cmd" is the Command key.
154
+ *
155
+ * @example
156
+ * isApplePlatform("MacIntel"); // true
157
+ * isApplePlatform("Win32"); // false
158
+ */
159
+ export declare const isApplePlatform: (platform?: string) => boolean;
49
160
  /**
50
161
  * The symbol for the "cmd" key in shortcut labels: ⌘ on Apple devices, ^ (Control) elsewhere.
51
162
  *
@@ -54,17 +165,69 @@ export declare const SHORTCUTS: readonly Shortcut[];
54
165
  * cmdSymbol("Win32"); // "^"
55
166
  */
56
167
  export declare const cmdSymbol: (platform?: string) => string;
57
- export declare const HOLD_TO_PAN_KEY = " ";
58
- /** The parts of a keyboard event used to match shortcuts */
59
- export type KeyEventLike = Pick<KeyboardEvent, "key" | "metaKey" | "ctrlKey" | "shiftKey" | "altKey">;
60
168
  /**
61
- * Find the action for a key press. Modifier keys must match exactly.
169
+ * A short label for a key combination, e.g. for menus: modifier symbols (^ Control, ⌥ Alt, ⇧ Shift, then ⌘ for "cmd" on
170
+ * Apple devices or ^ elsewhere), then the key as a symbol or in uppercase.
171
+ *
172
+ * @example
173
+ * shortcutLabel({ key: "z", cmd: true, shift: true }, "MacIntel"); // "⇧⌘Z"
174
+ * shortcutLabel({ key: "backspace", alt: true }, "Win32"); // "⌥⌫"
175
+ */
176
+ export declare const shortcutLabel: (combo: KeyCombo, platform?: string) => string;
177
+ /**
178
+ * A key combination as an `aria-keyshortcuts` value, so screen readers can announce it.
62
179
  *
63
180
  * @example
64
- * matchShortcut({ key: "Z", metaKey: true, ctrlKey: false, shiftKey: true, altKey: false });
181
+ * ariaKeyShortcut({ key: "s", cmd: true }, "MacIntel"); // "Meta+S"
182
+ * ariaKeyShortcut({ key: "backspace", alt: true }, "Win32"); // "Alt+Backspace"
183
+ */
184
+ export declare const ariaKeyShortcut: (combo: KeyCombo, platform?: string) => string;
185
+ /** The parts of a keyboard event used to read key combinations */
186
+ export type KeyEventLike = Pick<KeyboardEvent, "key" | "metaKey" | "ctrlKey" | "shiftKey" | "altKey"> & Partial<Pick<KeyboardEvent, "code" | "isComposing" | "getModifierState">>;
187
+ /**
188
+ * The key combination of a key press, matching keyboards with different layouts:
189
+ * - Keys are matched by the character they type, so letters follow the key's label (e.g. `a` on a French keyboard).
190
+ * - Digits and symbols ignore Shift and AltGr/Option, which are often needed to type them (e.g. `<` and `[` on a
191
+ * German keyboard).
192
+ * - When a key types a character that isn't basic Latin (another alphabet, or Option on macOS), or is a dead key, the
193
+ * physical key is used instead (e.g. `a` for `ф`, and `alt g` for Option+G typing `©`).
194
+ * - `=` counts as `+`, so `cmd +` works with or without Shift.
195
+ *
196
+ * `cmd` is Command on Apple devices and Ctrl elsewhere; `ctrl` is Control on Apple devices. Undefined while composing
197
+ * text (e.g. with an input method), for modifier keys alone, and for the Windows key elsewhere.
198
+ *
199
+ * @example
200
+ * comboFromEvent({ key: "Z", metaKey: true, ctrlKey: false, shiftKey: true, altKey: false }, "MacIntel");
201
+ * // { key: "z", cmd: true, shift: true }
202
+ */
203
+ export declare const comboFromEvent: (event: KeyEventLike, platform?: string) => KeyCombo | undefined;
204
+ /**
205
+ * Find the action for a key press (see `comboFromEvent`). Modifier keys must match exactly.
206
+ *
207
+ * @example
208
+ * matchShortcut({ key: "Z", metaKey: true, ctrlKey: false, shiftKey: true, altKey: false }, SHORTCUTS, "MacIntel");
65
209
  * // { type: "redo" }
66
210
  */
67
- export declare const matchShortcut: (event: KeyEventLike, shortcuts?: readonly Shortcut[]) => ShortcutAction | undefined;
211
+ export declare const matchShortcut: (event: KeyEventLike, shortcuts?: readonly Shortcut[], platform?: string) => ShortcutAction | undefined;
212
+ /**
213
+ * The modifier keys held during a key press, as a key combination without a key (e.g. to show them while recording a
214
+ * key combination). Read like `comboFromEvent`: `cmd` is Command on Apple devices and Ctrl elsewhere.
215
+ *
216
+ * @example
217
+ * heldModifiers({ key: "Shift", metaKey: true, ctrlKey: false, shiftKey: true, altKey: false }, "MacIntel");
218
+ * // { key: "", cmd: true, shift: true }
219
+ */
220
+ export declare const heldModifiers: (event: KeyEventLike, platform?: string) => KeyCombo;
221
+ /**
222
+ * A key combination as words, e.g. for a text field: modifiers in the order shift, alt, cmd, ctrl, then the key
223
+ * (Space as `space`). "cmd" is written `ctrl` except on Apple devices.
224
+ *
225
+ * @example
226
+ * comboText({ key: "g", shift: true, alt: true, cmd: true, ctrl: true }, "MacIntel"); // "shift alt cmd ctrl g"
227
+ * comboText({ key: "s", cmd: true }, "Win32"); // "ctrl s"
228
+ * comboText({ key: "", shift: true }, "MacIntel"); // "shift" (modifiers only)
229
+ */
230
+ export declare const comboText: (combo: KeyCombo, platform?: string) => string;
68
231
  /**
69
232
  * Check if a key press happened while typing in a text field, where shortcuts must not apply.
70
233
  *