react-simple-keyboard 3.8.0 → 3.8.2

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.
@@ -5,773 +5,773 @@ export interface KeyboardReactInterface extends SimpleKeyboard {
5
5
  keyboardRef?: (r: any) => void;
6
6
  };
7
7
  }
8
- // Generated by dts-bundle v0.7.3
9
- /**
10
- * Root class for simple-keyboard.
11
- * This class:
12
- * - Parses the options
13
- * - Renders the rows and buttons
14
- * - Handles button functionality
15
- */
16
- export interface SimpleKeyboard {
17
- input: KeyboardInput;
18
- options: KeyboardOptions;
19
- utilities: Utilities;
20
- caretPosition: number | null;
21
- caretPositionEnd: number | null;
22
- keyboardDOM: KeyboardElement;
23
- keyboardPluginClasses: string;
24
- keyboardDOMClass: string;
25
- buttonElements: KeyboardButtonElements;
26
- currentInstanceName: string;
27
- allKeyboardInstances: {
28
- [key: string]: SimpleKeyboard;
29
- };
30
- keyboardInstanceNames: string[];
31
- isFirstKeyboardInstance: boolean;
32
- physicalKeyboard: PhysicalKeyboard;
33
- modules: {
34
- [key: string]: any;
35
- };
36
- activeButtonClass: string;
37
- holdInteractionTimeout: number;
38
- holdTimeout: number;
39
- isMouseHold: boolean;
40
- initialized: boolean;
41
- candidateBox: CandidateBox | null;
42
- keyboardRowsDOM: KeyboardElement;
43
- defaultName: string;
44
- activeInputElement: HTMLInputElement | HTMLTextAreaElement | null;
45
- /**
46
- * Creates an instance of SimpleKeyboard
47
- * @param {Array} selectorOrOptions If first parameter is a string, it is considered the container class. The second parameter is then considered the options object. If first parameter is an object, it is considered the options object.
48
- */
49
- constructor: (selectorOrOptions?: string | HTMLDivElement | KeyboardOptions, keyboardOptions?: KeyboardOptions) => any
50
- /**
51
- * parseParams
52
- */
53
- handleParams: (selectorOrOptions?: string | HTMLDivElement | KeyboardOptions, keyboardOptions?: KeyboardOptions) => {
54
- keyboardDOMClass: string;
55
- keyboardDOM: KeyboardElement;
56
- options: Partial<KeyboardOptions | undefined>;
57
- };
58
- /**
59
- * Getters
60
- */
61
- getOptions: () => KeyboardOptions;
62
- getCaretPosition: () => number | null;
63
- getCaretPositionEnd: () => number | null;
64
- /**
65
- * Changes the internal caret position
66
- * @param {number} position The caret's start position
67
- * @param {number} positionEnd The caret's end position
68
- */
69
- setCaretPosition(position: number | null, endPosition?: number | null): void;
70
- /**
71
- * Retrieve the candidates for a given input
72
- * @param input The input string to check
73
- */
74
- getInputCandidates(input: string): {
75
- candidateKey: string;
76
- candidateValue: string;
77
- } | Record<string, never>;
78
- /**
79
- * Shows a suggestion box with a list of candidate words
80
- * @param candidates The chosen candidates string as defined in the layoutCandidates option
81
- * @param targetElement The element next to which the candidates box will be shown
82
- */
83
- showCandidatesBox(candidateKey: string, candidateValue: string, targetElement: KeyboardElement): void;
84
- /**
85
- * Handles clicks made to keyboard buttons
86
- * @param {string} button The button's layout name.
87
- */
88
- handleButtonClicked(button: string, e?: KeyboardHandlerEvent): void;
89
- /**
90
- * Get mouse hold state
91
- */
92
- getMouseHold(): boolean;
93
- /**
94
- * Mark mouse hold state as set
95
- */
96
- setMouseHold(value: boolean): void;
97
- /**
98
- * Handles button mousedown
99
- */
100
- handleButtonMouseDown(button: string, e: KeyboardHandlerEvent): void;
101
- /**
102
- * Handles button mouseup
103
- */
104
- handleButtonMouseUp(button?: string, e?: KeyboardHandlerEvent): void;
105
- /**
106
- * Handles container mousedown
107
- */
108
- handleKeyboardContainerMouseDown(e: KeyboardHandlerEvent): void;
109
- /**
110
- * Handles button hold
111
- */
112
- handleButtonHold(button: string): void;
113
- /**
114
- * Send a command to all simple-keyboard instances (if you have several instances).
115
- */
116
- syncInstanceInputs(): void;
117
- /**
118
- * Clear the keyboard’s input.
119
- * @param {string} [inputName] optional - the internal input to select
120
- */
121
- clearInput(inputName?: string): void;
122
- /**
123
- * Get the keyboard’s input (You can also get it from the onChange prop).
124
- * @param {string} [inputName] optional - the internal input to select
125
- */
126
- getInput(inputName?: string, skipSync?: boolean): string;
127
- /**
128
- * Get all simple-keyboard inputs
129
- */
130
- getAllInputs(): KeyboardInput;
131
- /**
132
- * Set the keyboard’s input.
133
- * @param {string} input the input value
134
- * @param {string} inputName optional - the internal input to select
135
- */
136
- setInput(input: string, inputName?: string, skipSync?: boolean): void;
137
- /**
138
- * Replace the input object (`keyboard.input`)
139
- * @param {object} inputObj The input object
140
- */
141
- replaceInput(inputObj: KeyboardInput): void;
142
- /**
143
- * Set new option or modify existing ones after initialization.
144
- * @param {object} options The options to set
145
- */
146
- setOptions(options?: {}): void;
147
- /**
148
- * Detecting changes to non-function options
149
- * This allows us to ascertain whether a button re-render is needed
150
- */
151
- changedOptions(newOptions: Partial<KeyboardOptions>): string[];
152
- /**
153
- * Executing actions depending on changed options
154
- * @param {object} options The options to set
155
- */
156
- onSetOptions(changedOptions?: string[]): void;
157
- /**
158
- * Remove all keyboard rows and reset keyboard values.
159
- * Used internally between re-renders.
160
- */
161
- resetRows(): void;
162
- /**
163
- * Send a command to all simple-keyboard instances at once (if you have multiple instances).
164
- * @param {function(instance: object, key: string)} callback Function to run on every instance
165
- */
166
- dispatch(callback: (instance: SimpleKeyboard, key?: string) => void): void;
167
- /**
168
- * Adds/Modifies an entry to the `buttonTheme`. Basically a way to add a class to a button.
169
- * @param {string} buttons List of buttons to select (separated by a space).
170
- * @param {string} className Classes to give to the selected buttons (separated by space).
171
- */
172
- addButtonTheme(buttons: string, className: string): void;
173
- /**
174
- * Removes/Amends an entry to the `buttonTheme`. Basically a way to remove a class previously added to a button through buttonTheme or addButtonTheme.
175
- * @param {string} buttons List of buttons to select (separated by a space).
176
- * @param {string} className Classes to give to the selected buttons (separated by space).
177
- */
178
- removeButtonTheme(buttons: string, className: string): void;
179
- /**
180
- * Get the DOM Element of a button. If there are several buttons with the same name, an array of the DOM Elements is returned.
181
- * @param {string} button The button layout name to select
182
- */
183
- getButtonElement(button: string): KeyboardElement | KeyboardElement[] | undefined;
184
- /**
185
- * This handles the "inputPattern" option
186
- * by checking if the provided inputPattern passes
187
- */
188
- inputPatternIsValid(inputVal: string): boolean;
189
- /**
190
- * Handles simple-keyboard event listeners
191
- */
192
- setEventListeners(): void;
193
- /**
194
- * Event Handler: KeyUp
195
- */
196
- handleKeyUp(event: KeyboardHandlerEvent): void;
197
- /**
198
- * Event Handler: KeyDown
199
- */
200
- handleKeyDown(event: KeyboardHandlerEvent): void;
201
- /**
202
- * Event Handler: MouseUp
203
- */
204
- handleMouseUp(event: KeyboardHandlerEvent): void;
205
- /**
206
- * Event Handler: TouchEnd
207
- */
208
- handleTouchEnd(event: KeyboardHandlerEvent): void;
209
- /**
210
- * Event Handler: Select
211
- */
212
- handleSelect(event: KeyboardHandlerEvent): void;
213
- /**
214
- * Event Handler: SelectionChange
215
- */
216
- handleSelectionChange(event: KeyboardHandlerEvent): void;
217
- /**
218
- * Called by {@link setEventListeners} when an event that warrants a cursor position update is triggered
219
- */
220
- caretEventHandler(event: KeyboardHandlerEvent): void;
221
- /**
222
- * Execute an operation on each button
223
- */
224
- recurseButtons(fn: any): void;
225
- /**
226
- * Destroy keyboard listeners and DOM elements
227
- */
228
- destroy(): void;
229
- /**
230
- * Process buttonTheme option
231
- */
232
- getButtonThemeClasses(button: string): string[];
233
- /**
234
- * Process buttonAttributes option
235
- */
236
- setDOMButtonAttributes(button: string, callback: any): void;
237
- onTouchDeviceDetected(): void;
238
- /**
239
- * Disabling contextual window for hg-button
240
- */
241
- disableContextualWindow(): void;
242
- /**
243
- * Process autoTouchEvents option
244
- */
245
- processAutoTouchEvents(): void;
246
- /**
247
- * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).
248
- */
249
- onInit(): void;
250
- /**
251
- * Executes the callback function before a simple-keyboard render.
252
- */
253
- beforeFirstRender(): void;
254
- /**
255
- * Executes the callback function before a simple-keyboard render.
256
- */
257
- beforeRender(): void;
258
- /**
259
- * Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).
260
- */
261
- onRender(): void;
262
- /**
263
- * Executes the callback function once all modules have been loaded
264
- */
265
- onModulesLoaded(): void;
266
- /**
267
- * Register module
268
- */
269
- registerModule: (name: string, initCallback: any) => void;
270
- /**
271
- * Load modules
272
- */
273
- loadModules(): void;
274
- /**
275
- * Get module prop
276
- */
277
- getModuleProp(name: string, prop: string): any;
278
- /**
279
- * getModulesList
280
- */
281
- getModulesList(): string[];
282
- /**
283
- * Parse Row DOM containers
284
- */
285
- parseRowDOMContainers(rowDOM: HTMLDivElement, rowIndex: number, containerStartIndexes: number[], containerEndIndexes: number[]): HTMLDivElement;
286
- /**
287
- * getKeyboardClassString
288
- */
289
- getKeyboardClassString: (...baseDOMClasses: any[]) => string;
290
- /**
291
- * Renders rows and buttons as per options
292
- */
293
- render(): void;
294
- }
295
- export interface SKWindow extends Window {
296
- SimpleKeyboardInstances?: any;
297
- }
298
- export interface KeyboardLayoutObject {
299
- [key: string]: string[];
300
- }
301
- export type KeyboardButtonTheme = {
302
- class: string;
303
- buttons: string;
304
- } | null;
305
- export interface KeyboardButtonAttributes {
306
- attribute: string;
307
- value: string;
308
- buttons: string;
309
- }
310
- export interface KeyboardInput {
311
- [key: string]: string;
312
- }
313
- export type CandidateBoxParams = {
314
- utilities: Utilities;
315
- options: KeyboardOptions;
316
- };
317
- export type CandidateBoxShowParams = {
318
- candidateValue: string;
319
- targetElement: KeyboardElement;
320
- onSelect: (selectedCandidate: string, e: MouseEvent) => void;
321
- };
322
- export type CandidateBoxRenderParams = {
323
- candidateListPages: string[][];
324
- targetElement: KeyboardElement;
325
- pageIndex: number;
326
- nbPages: number;
327
- onItemSelected: (selectedCandidate: string, e: MouseEvent) => void;
328
- };
329
- export type KeyboardElement = HTMLDivElement | HTMLButtonElement;
330
- export type KeyboardHandlerEvent = any;
331
- export interface KeyboardButtonElements {
332
- [key: string]: KeyboardElement[];
333
- }
334
- export interface UtilitiesParams {
335
- getOptions: () => KeyboardOptions;
336
- getCaretPosition: () => number | null;
337
- getCaretPositionEnd: () => number | null;
338
- dispatch: any;
339
- }
340
- export interface PhysicalKeyboardParams {
341
- getOptions: () => KeyboardOptions;
342
- dispatch: any;
343
- }
344
- export interface KeyboardOptions {
345
- /**
346
- * Modify the keyboard layout.
347
- */
348
- layout?: KeyboardLayoutObject;
349
- /**
350
- * Specifies which layout should be used.
351
- */
352
- layoutName?: string;
353
- /**
354
- * Replaces variable buttons (such as `{bksp}`) with a human-friendly name (e.g.: `backspace`).
355
- */
356
- display?: {
357
- [button: string]: string;
358
- };
359
- /**
360
- * By default, when you set the display property, you replace the default one. This setting merges them instead.
361
- */
362
- mergeDisplay?: boolean;
363
- /**
364
- * A prop to add your own css classes to the keyboard wrapper. You can add multiple classes separated by a space.
365
- */
366
- theme?: string;
367
- /**
368
- * A prop to add your own css classes to one or several buttons.
369
- */
370
- buttonTheme?: KeyboardButtonTheme[];
371
- /**
372
- * A prop to add your own attributes to one or several buttons.
373
- */
374
- buttonAttributes?: KeyboardButtonAttributes[];
375
- /**
376
- * Runs a `console.log` every time a key is pressed. Displays the buttons pressed and the current input.
377
- */
378
- debug?: boolean;
379
- /**
380
- * Specifies whether clicking the "ENTER" button will input a newline (`\n`) or not.
381
- */
382
- newLineOnEnter?: boolean;
383
- /**
384
- * Specifies whether clicking the "TAB" button will input a tab character (`\t`) or not.
385
- */
386
- tabCharOnTab?: boolean;
387
- /**
388
- * Allows you to use a single simple-keyboard instance for several inputs.
389
- */
390
- inputName?: string;
391
- /**
392
- * `number`: Restrains all of simple-keyboard inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.
393
- *
394
- * `{ [inputName: string]: number }`: Restrains simple-keyboard’s individual inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.
395
- */
396
- maxLength?: any;
397
- /**
398
- * When set to true, this option synchronizes the internal input of every simple-keyboard instance.
399
- */
400
- syncInstanceInputs?: boolean;
401
- /**
402
- * Enable highlighting of keys pressed on physical keyboard.
403
- */
404
- physicalKeyboardHighlight?: boolean;
405
- /**
406
- * Calls handler for a button highlighted by physicalKeyboardHighlight
407
- * In other words, this calls keyboard.handleButtonClicked(buttonName) on the highlighted button
408
- */
409
- physicalKeyboardHighlightPress?: boolean;
410
- /**
411
- * Trigger click on a button's element when using physicalKeyboardHighlightPress
412
- * In other words, this calls button.click() on the highlighted button
413
- */
414
- physicalKeyboardHighlightPressUseClick?: boolean;
415
- /**
416
- * Whether physicalKeyboardHighlightPress should use pointer events to trigger buttons.
417
- */
418
- physicalKeyboardHighlightPressUsePointerEvents?: boolean;
419
- /**
420
- * Define the text color that the physical keyboard highlighted key should have.
421
- */
422
- physicalKeyboardHighlightTextColor?: string;
423
- /**
424
- * Define the background color that the physical keyboard highlighted key should have.
425
- */
426
- physicalKeyboardHighlightBgColor?: string;
427
- /**
428
- * Whether physicalKeyboardHighlight should use preventDefault to disable default browser actions.
429
- */
430
- physicalKeyboardHighlightPreventDefault?: boolean;
431
- /**
432
- * Calling preventDefault for the mousedown events keeps the focus on the input.
433
- */
434
- preventMouseDownDefault?: boolean;
435
- /**
436
- * Calling preventDefault for the mouseup events.
437
- */
438
- preventMouseUpDefault?: boolean;
439
- /**
440
- * Stops pointer down events on simple-keyboard buttons from bubbling to parent elements.
441
- */
442
- stopMouseDownPropagation?: boolean;
443
- /**
444
- * Stops pointer up events on simple-keyboard buttons from bubbling to parent elements.
445
- */
446
- stopMouseUpPropagation?: boolean;
447
- /**
448
- * Render buttons as a button element instead of a div element.
449
- */
450
- useButtonTag?: boolean;
451
- /**
452
- * A prop to ensure characters are always be added/removed at the end of the string.
453
- */
454
- disableCaretPositioning?: boolean;
455
- /**
456
- * Restrains input(s) change to the defined regular expression pattern.
457
- */
458
- inputPattern?: any;
459
- /**
460
- * Instructs simple-keyboard to use touch events instead of click events.
461
- */
462
- useTouchEvents?: boolean;
463
- /**
464
- * Enable useTouchEvents automatically when touch device is detected.
465
- */
466
- autoUseTouchEvents?: boolean;
467
- /**
468
- * Opt out of PointerEvents handling, falling back to the prior mouse event logic.
469
- */
470
- useMouseEvents?: boolean;
471
- /**
472
- * Disable button hold action.
473
- */
474
- disableButtonHold?: boolean;
475
- /**
476
- * Adds unicode right-to-left control characters to input return values.
477
- */
478
- rtl?: boolean;
479
- /**
480
- * Enable input method editor candidate list support.
481
- */
482
- enableLayoutCandidates?: boolean;
483
- /**
484
- * Character suggestions to be shown on certain key presses
485
- */
486
- layoutCandidates?: {
487
- [key: string]: string;
488
- };
489
- /**
490
- * Exclude buttons from layout
491
- */
492
- excludeFromLayout?: {
493
- [key: string]: string[];
494
- };
495
- /**
496
- * Determines size of layout candidate list
497
- */
498
- layoutCandidatesPageSize?: number;
499
- /**
500
- * Determines whether layout candidate match should be case sensitive.
501
- */
502
- layoutCandidatesCaseSensitiveMatch?: boolean;
503
- /**
504
- * Disables the automatic normalization for selected layout candidates
505
- */
506
- disableCandidateNormalization?: boolean;
507
- /**
508
- * Enables onKeyPress triggering for layoutCandidate items
509
- */
510
- enableLayoutCandidatesKeyPress?: boolean;
511
- /**
512
- * Updates caret when selectionchange event is fired
513
- */
514
- updateCaretOnSelectionChange?: boolean;
515
- /**
516
- * Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).
517
- */
518
- onRender?: (instance: SimpleKeyboard) => void;
519
- /**
520
- * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).
521
- */
522
- onInit?: (instance: SimpleKeyboard) => void;
523
- /**
524
- * Retrieves the current input
525
- */
526
- onChange?: (input: string, e?: MouseEvent) => any;
527
- /**
528
- * Retrieves all inputs
529
- */
530
- onChangeAll?: (inputObj: KeyboardInput, e?: MouseEvent) => any;
531
- /**
532
- * Retrieves the pressed key
533
- */
534
- onKeyPress?: (button: string, e?: MouseEvent) => any;
535
- /**
536
- * Retrieves the released key
537
- */
538
- onKeyReleased?: (button: string, e?: MouseEvent) => any;
539
- /**
540
- * Executes the callback function before an input is about to be updated
541
- */
542
- beforeInputUpdate?: (instance: SimpleKeyboard) => void;
543
- /**
544
- * Module options can have any format
545
- */
546
- [name: string]: any;
547
- }
548
- /**
549
- * Physical Keyboard Service
550
- */
551
- export interface PhysicalKeyboard {
552
- getOptions: () => KeyboardOptions;
553
- dispatch: any;
554
- /**
555
- * Creates an instance of the PhysicalKeyboard service
556
- */
557
- constructor: ({ dispatch, getOptions }: PhysicalKeyboardParams) => any
558
- handleHighlightKeyDown(e: KeyboardEvent): void;
559
- handleHighlightKeyUp(e: KeyboardEvent): void;
560
- /**
561
- * Transforms a KeyboardEvent's "key.code" string into a simple-keyboard layout format
562
- * @param {object} e The KeyboardEvent
563
- */
564
- getSimpleKeyboardLayoutKey(e: KeyboardEvent): string;
565
- /**
566
- * Retrieve key from keyCode
567
- */
568
- keyCodeToKey(keyCode: number): string;
569
- isModifierKey: (e: KeyboardEvent) => boolean;
570
- }
571
- /**
572
- * Utility Service
573
- */
574
- export interface Utilities {
575
- getOptions: () => KeyboardOptions;
576
- getCaretPosition: () => number | null;
577
- getCaretPositionEnd: () => number | null;
578
- dispatch: any;
579
- maxLengthReached: boolean;
580
- /**
581
- * Creates an instance of the Utility service
582
- */
583
- constructor: ({ getOptions, getCaretPosition, getCaretPositionEnd, dispatch, }: UtilitiesParams) => any
584
- /**
585
- * Retrieve button type
586
- *
587
- * @param {string} button The button's layout name
588
- * @return {string} The button type
589
- */
590
- getButtonType(button: string): string;
591
- /**
592
- * Adds default classes to a given button
593
- *
594
- * @param {string} button The button's layout name
595
- * @return {string} The classes to be added to the button
596
- */
597
- getButtonClass(button: string): string;
598
- /**
599
- * Default button display labels
600
- */
601
- getDefaultDiplay(): {
602
- "{bksp}": string;
603
- "{backspace}": string;
604
- "{enter}": string;
605
- "{shift}": string;
606
- "{shiftleft}": string;
607
- "{shiftright}": string;
608
- "{alt}": string;
609
- "{s}": string;
610
- "{tab}": string;
611
- "{lock}": string;
612
- "{capslock}": string;
613
- "{accept}": string;
614
- "{space}": string;
615
- "{//}": string;
616
- "{esc}": string;
617
- "{escape}": string;
618
- "{f1}": string;
619
- "{f2}": string;
620
- "{f3}": string;
621
- "{f4}": string;
622
- "{f5}": string;
623
- "{f6}": string;
624
- "{f7}": string;
625
- "{f8}": string;
626
- "{f9}": string;
627
- "{f10}": string;
628
- "{f11}": string;
629
- "{f12}": string;
630
- "{numpaddivide}": string;
631
- "{numlock}": string;
632
- "{arrowup}": string;
633
- "{arrowleft}": string;
634
- "{arrowdown}": string;
635
- "{arrowright}": string;
636
- "{prtscr}": string;
637
- "{scrolllock}": string;
638
- "{pause}": string;
639
- "{insert}": string;
640
- "{home}": string;
641
- "{pageup}": string;
642
- "{delete}": string;
643
- "{forwarddelete}": string;
644
- "{end}": string;
645
- "{pagedown}": string;
646
- "{numpadmultiply}": string;
647
- "{numpadsubtract}": string;
648
- "{numpadadd}": string;
649
- "{numpadenter}": string;
650
- "{period}": string;
651
- "{numpaddecimal}": string;
652
- "{numpad0}": string;
653
- "{numpad1}": string;
654
- "{numpad2}": string;
655
- "{numpad3}": string;
656
- "{numpad4}": string;
657
- "{numpad5}": string;
658
- "{numpad6}": string;
659
- "{numpad7}": string;
660
- "{numpad8}": string;
661
- "{numpad9}": string;
662
- };
663
- /**
664
- * Returns the display (label) name for a given button
665
- *
666
- * @param {string} button The button's layout name
667
- * @param {object} display The provided display option
668
- * @param {boolean} mergeDisplay Whether the provided param value should be merged with the default one.
669
- */
670
- getButtonDisplayName(button: string, display: KeyboardOptions["display"], mergeDisplay?: boolean): string;
671
- /**
672
- * Returns the updated input resulting from clicking a given button
673
- *
674
- * @param {string} button The button's layout name
675
- * @param {string} input The input string
676
- * @param {number} caretPos The cursor's current position
677
- * @param {number} caretPosEnd The cursor's current end position
678
- * @param {boolean} moveCaret Whether to update simple-keyboard's cursor
679
- */
680
- getUpdatedInput(button: string, input: string, caretPos: any, caretPosEnd?: any, moveCaret?: boolean): string;
681
- /**
682
- * Moves the cursor position by a given amount
683
- *
684
- * @param {number} length Represents by how many characters the input should be moved
685
- * @param {boolean} minus Whether the cursor should be moved to the left or not.
686
- */
687
- updateCaretPos(length: number, minus?: boolean): void;
688
- /**
689
- * Action method of updateCaretPos
690
- *
691
- * @param {number} length Represents by how many characters the input should be moved
692
- * @param {boolean} minus Whether the cursor should be moved to the left or not.
693
- */
694
- updateCaretPosAction(length: number, minus?: boolean): number | null;
695
- /**
696
- * Adds a string to the input at a given position
697
- *
698
- * @param {string} source The source input
699
- * @param {string} str The string to add
700
- * @param {number} position The (cursor) position where the string should be added
701
- * @param {boolean} moveCaret Whether to update simple-keyboard's cursor
702
- */
703
- addStringAt(source: string, str: string, position?: number, positionEnd?: number, moveCaret?: boolean): string;
704
- /**
705
- * Check whether the button is a standard button
706
- */
707
- isStandardButton: (button: string) => boolean | "";
708
- /**
709
- * Removes an amount of characters before a given position
710
- *
711
- * @param {string} source The source input
712
- * @param {number} position The (cursor) position from where the characters should be removed
713
- * @param {boolean} moveCaret Whether to update simple-keyboard's cursor
714
- */
715
- removeAt(source: string, position?: number, positionEnd?: number, moveCaret?: boolean): string;
716
- /**
717
- * Removes an amount of characters after a given position
718
- *
719
- * @param {string} source The source input
720
- * @param {number} position The (cursor) position from where the characters should be removed
721
- */
722
- removeForwardsAt(source: string, position?: number, positionEnd?: number, moveCaret?: boolean): string;
723
- /**
724
- * Determines whether the maxLength has been reached. This function is called when the maxLength option it set.
725
- *
726
- * @param {object} inputObj
727
- * @param {string} updatedInput
728
- */
729
- handleMaxLength(inputObj: KeyboardInput, updatedInput: string): boolean | undefined;
730
- /**
731
- * Gets the current value of maxLengthReached
732
- */
733
- isMaxLengthReached(): boolean;
734
- /**
735
- * Determines whether a touch device is being used
736
- */
737
- isTouchDevice(): number | true;
738
- /**
739
- * Determines whether pointer events are supported
740
- */
741
- pointerEventsSupported(): boolean;
742
- /**
743
- * Bind all methods in a given class
744
- */
745
- /**
746
- * Transforms an arbitrary string to camelCase
747
- *
748
- * @param {string} str The string to transform.
749
- */
750
- camelCase(str: string): string;
751
- /**
752
- * Split array into chunks
753
- */
754
- chunkArray<T>(arr: T[], size: number): T[][];
755
- /**
756
- * Escape regex input
757
- */
758
- escapeRegex(str: string): string;
759
- /**
760
- * Calculate caret position offset when using rtl option
761
- */
762
- getRtlOffset(index: number, input: string): number;
763
- /**
764
- * Reusable empty function
765
- */
766
- }
767
- export interface CandidateBox {
768
- utilities: Utilities;
769
- options: KeyboardOptions;
770
- candidateBoxElement: HTMLDivElement;
771
- pageIndex: number;
772
- pageSize: number;
773
- constructor: ({ utilities, options }: CandidateBoxParams) => any
774
- destroy(): void;
775
- show({ candidateValue, targetElement, onSelect, }: CandidateBoxShowParams): void;
776
- renderPage({ candidateListPages, targetElement, pageIndex, nbPages, onItemSelected, }: CandidateBoxRenderParams): void;
777
- }
8
+ // Generated by dts-bundle v0.7.3
9
+ /**
10
+ * Root class for simple-keyboard.
11
+ * This class:
12
+ * - Parses the options
13
+ * - Renders the rows and buttons
14
+ * - Handles button functionality
15
+ */
16
+ export interface SimpleKeyboard {
17
+ input: KeyboardInput;
18
+ options: KeyboardOptions;
19
+ utilities: Utilities;
20
+ caretPosition: number | null;
21
+ caretPositionEnd: number | null;
22
+ keyboardDOM: KeyboardElement;
23
+ keyboardPluginClasses: string;
24
+ keyboardDOMClass: string;
25
+ buttonElements: KeyboardButtonElements;
26
+ currentInstanceName: string;
27
+ allKeyboardInstances: {
28
+ [key: string]: SimpleKeyboard;
29
+ };
30
+ keyboardInstanceNames: string[];
31
+ isFirstKeyboardInstance: boolean;
32
+ physicalKeyboard: PhysicalKeyboard;
33
+ modules: {
34
+ [key: string]: any;
35
+ };
36
+ activeButtonClass: string;
37
+ holdInteractionTimeout: number;
38
+ holdTimeout: number;
39
+ isMouseHold: boolean;
40
+ initialized: boolean;
41
+ candidateBox: CandidateBox | null;
42
+ keyboardRowsDOM: KeyboardElement;
43
+ defaultName: string;
44
+ activeInputElement: HTMLInputElement | HTMLTextAreaElement | null;
45
+ /**
46
+ * Creates an instance of SimpleKeyboard
47
+ * @param {Array} selectorOrOptions If first parameter is a string, it is considered the container class. The second parameter is then considered the options object. If first parameter is an object, it is considered the options object.
48
+ */
49
+ constructor: (selectorOrOptions?: string | HTMLDivElement | KeyboardOptions, keyboardOptions?: KeyboardOptions) => any
50
+ /**
51
+ * parseParams
52
+ */
53
+ handleParams: (selectorOrOptions?: string | HTMLDivElement | KeyboardOptions, keyboardOptions?: KeyboardOptions) => {
54
+ keyboardDOMClass: string;
55
+ keyboardDOM: KeyboardElement;
56
+ options: Partial<KeyboardOptions | undefined>;
57
+ };
58
+ /**
59
+ * Getters
60
+ */
61
+ getOptions: () => KeyboardOptions;
62
+ getCaretPosition: () => number | null;
63
+ getCaretPositionEnd: () => number | null;
64
+ /**
65
+ * Changes the internal caret position
66
+ * @param {number} position The caret's start position
67
+ * @param {number} positionEnd The caret's end position
68
+ */
69
+ setCaretPosition(position: number | null, endPosition?: number | null): void;
70
+ /**
71
+ * Retrieve the candidates for a given input
72
+ * @param input The input string to check
73
+ */
74
+ getInputCandidates(input: string): {
75
+ candidateKey: string;
76
+ candidateValue: string;
77
+ } | Record<string, never>;
78
+ /**
79
+ * Shows a suggestion box with a list of candidate words
80
+ * @param candidates The chosen candidates string as defined in the layoutCandidates option
81
+ * @param targetElement The element next to which the candidates box will be shown
82
+ */
83
+ showCandidatesBox(candidateKey: string, candidateValue: string, targetElement: KeyboardElement): void;
84
+ /**
85
+ * Handles clicks made to keyboard buttons
86
+ * @param {string} button The button's layout name.
87
+ */
88
+ handleButtonClicked(button: string, e?: KeyboardHandlerEvent): void;
89
+ /**
90
+ * Get mouse hold state
91
+ */
92
+ getMouseHold(): boolean;
93
+ /**
94
+ * Mark mouse hold state as set
95
+ */
96
+ setMouseHold(value: boolean): void;
97
+ /**
98
+ * Handles button mousedown
99
+ */
100
+ handleButtonMouseDown(button: string, e: KeyboardHandlerEvent): void;
101
+ /**
102
+ * Handles button mouseup
103
+ */
104
+ handleButtonMouseUp(button?: string, e?: KeyboardHandlerEvent): void;
105
+ /**
106
+ * Handles container mousedown
107
+ */
108
+ handleKeyboardContainerMouseDown(e: KeyboardHandlerEvent): void;
109
+ /**
110
+ * Handles button hold
111
+ */
112
+ handleButtonHold(button: string): void;
113
+ /**
114
+ * Send a command to all simple-keyboard instances (if you have several instances).
115
+ */
116
+ syncInstanceInputs(): void;
117
+ /**
118
+ * Clear the keyboard’s input.
119
+ * @param {string} [inputName] optional - the internal input to select
120
+ */
121
+ clearInput(inputName?: string): void;
122
+ /**
123
+ * Get the keyboard’s input (You can also get it from the onChange prop).
124
+ * @param {string} [inputName] optional - the internal input to select
125
+ */
126
+ getInput(inputName?: string, skipSync?: boolean): string;
127
+ /**
128
+ * Get all simple-keyboard inputs
129
+ */
130
+ getAllInputs(): KeyboardInput;
131
+ /**
132
+ * Set the keyboard’s input.
133
+ * @param {string} input the input value
134
+ * @param {string} inputName optional - the internal input to select
135
+ */
136
+ setInput(input: string, inputName?: string, skipSync?: boolean): void;
137
+ /**
138
+ * Replace the input object (`keyboard.input`)
139
+ * @param {object} inputObj The input object
140
+ */
141
+ replaceInput(inputObj: KeyboardInput): void;
142
+ /**
143
+ * Set new option or modify existing ones after initialization.
144
+ * @param {object} options The options to set
145
+ */
146
+ setOptions(options?: {}): void;
147
+ /**
148
+ * Detecting changes to non-function options
149
+ * This allows us to ascertain whether a button re-render is needed
150
+ */
151
+ changedOptions(newOptions: Partial<KeyboardOptions>): string[];
152
+ /**
153
+ * Executing actions depending on changed options
154
+ * @param {object} options The options to set
155
+ */
156
+ onSetOptions(changedOptions?: string[]): void;
157
+ /**
158
+ * Remove all keyboard rows and reset keyboard values.
159
+ * Used internally between re-renders.
160
+ */
161
+ resetRows(): void;
162
+ /**
163
+ * Send a command to all simple-keyboard instances at once (if you have multiple instances).
164
+ * @param {function(instance: object, key: string)} callback Function to run on every instance
165
+ */
166
+ dispatch(callback: (instance: SimpleKeyboard, key?: string) => void): void;
167
+ /**
168
+ * Adds/Modifies an entry to the `buttonTheme`. Basically a way to add a class to a button.
169
+ * @param {string} buttons List of buttons to select (separated by a space).
170
+ * @param {string} className Classes to give to the selected buttons (separated by space).
171
+ */
172
+ addButtonTheme(buttons: string, className: string): void;
173
+ /**
174
+ * Removes/Amends an entry to the `buttonTheme`. Basically a way to remove a class previously added to a button through buttonTheme or addButtonTheme.
175
+ * @param {string} buttons List of buttons to select (separated by a space).
176
+ * @param {string} className Classes to give to the selected buttons (separated by space).
177
+ */
178
+ removeButtonTheme(buttons: string, className: string): void;
179
+ /**
180
+ * Get the DOM Element of a button. If there are several buttons with the same name, an array of the DOM Elements is returned.
181
+ * @param {string} button The button layout name to select
182
+ */
183
+ getButtonElement(button: string): KeyboardElement | KeyboardElement[] | undefined;
184
+ /**
185
+ * This handles the "inputPattern" option
186
+ * by checking if the provided inputPattern passes
187
+ */
188
+ inputPatternIsValid(inputVal: string): boolean;
189
+ /**
190
+ * Handles simple-keyboard event listeners
191
+ */
192
+ setEventListeners(): void;
193
+ /**
194
+ * Event Handler: KeyUp
195
+ */
196
+ handleKeyUp(event: KeyboardHandlerEvent): void;
197
+ /**
198
+ * Event Handler: KeyDown
199
+ */
200
+ handleKeyDown(event: KeyboardHandlerEvent): void;
201
+ /**
202
+ * Event Handler: MouseUp
203
+ */
204
+ handleMouseUp(event: KeyboardHandlerEvent): void;
205
+ /**
206
+ * Event Handler: TouchEnd
207
+ */
208
+ handleTouchEnd(event: KeyboardHandlerEvent): void;
209
+ /**
210
+ * Event Handler: Select
211
+ */
212
+ handleSelect(event: KeyboardHandlerEvent): void;
213
+ /**
214
+ * Event Handler: SelectionChange
215
+ */
216
+ handleSelectionChange(event: KeyboardHandlerEvent): void;
217
+ /**
218
+ * Called by {@link setEventListeners} when an event that warrants a cursor position update is triggered
219
+ */
220
+ caretEventHandler(event: KeyboardHandlerEvent): void;
221
+ /**
222
+ * Execute an operation on each button
223
+ */
224
+ recurseButtons(fn: any): void;
225
+ /**
226
+ * Destroy keyboard listeners and DOM elements
227
+ */
228
+ destroy(): void;
229
+ /**
230
+ * Process buttonTheme option
231
+ */
232
+ getButtonThemeClasses(button: string): string[];
233
+ /**
234
+ * Process buttonAttributes option
235
+ */
236
+ setDOMButtonAttributes(button: string, callback: any): void;
237
+ onTouchDeviceDetected(): void;
238
+ /**
239
+ * Disabling contextual window for hg-button
240
+ */
241
+ disableContextualWindow(): void;
242
+ /**
243
+ * Process autoTouchEvents option
244
+ */
245
+ processAutoTouchEvents(): void;
246
+ /**
247
+ * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).
248
+ */
249
+ onInit(): void;
250
+ /**
251
+ * Executes the callback function before a simple-keyboard render.
252
+ */
253
+ beforeFirstRender(): void;
254
+ /**
255
+ * Executes the callback function before a simple-keyboard render.
256
+ */
257
+ beforeRender(): void;
258
+ /**
259
+ * Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).
260
+ */
261
+ onRender(): void;
262
+ /**
263
+ * Executes the callback function once all modules have been loaded
264
+ */
265
+ onModulesLoaded(): void;
266
+ /**
267
+ * Register module
268
+ */
269
+ registerModule: (name: string, initCallback: any) => void;
270
+ /**
271
+ * Load modules
272
+ */
273
+ loadModules(): void;
274
+ /**
275
+ * Get module prop
276
+ */
277
+ getModuleProp(name: string, prop: string): any;
278
+ /**
279
+ * getModulesList
280
+ */
281
+ getModulesList(): string[];
282
+ /**
283
+ * Parse Row DOM containers
284
+ */
285
+ parseRowDOMContainers(rowDOM: HTMLDivElement, rowIndex: number, containerStartIndexes: number[], containerEndIndexes: number[]): HTMLDivElement;
286
+ /**
287
+ * getKeyboardClassString
288
+ */
289
+ getKeyboardClassString: (...baseDOMClasses: any[]) => string;
290
+ /**
291
+ * Renders rows and buttons as per options
292
+ */
293
+ render(): void;
294
+ }
295
+ export interface SKWindow extends Window {
296
+ SimpleKeyboardInstances?: any;
297
+ }
298
+ export interface KeyboardLayoutObject {
299
+ [key: string]: string[];
300
+ }
301
+ export type KeyboardButtonTheme = {
302
+ class: string;
303
+ buttons: string;
304
+ } | null;
305
+ export interface KeyboardButtonAttributes {
306
+ attribute: string;
307
+ value: string;
308
+ buttons: string;
309
+ }
310
+ export interface KeyboardInput {
311
+ [key: string]: string;
312
+ }
313
+ export type CandidateBoxParams = {
314
+ utilities: Utilities;
315
+ options: KeyboardOptions;
316
+ };
317
+ export type CandidateBoxShowParams = {
318
+ candidateValue: string;
319
+ targetElement: KeyboardElement;
320
+ onSelect: (selectedCandidate: string, e: MouseEvent) => void;
321
+ };
322
+ export type CandidateBoxRenderParams = {
323
+ candidateListPages: string[][];
324
+ targetElement: KeyboardElement;
325
+ pageIndex: number;
326
+ nbPages: number;
327
+ onItemSelected: (selectedCandidate: string, e: MouseEvent) => void;
328
+ };
329
+ export type KeyboardElement = HTMLDivElement | HTMLButtonElement;
330
+ export type KeyboardHandlerEvent = any;
331
+ export interface KeyboardButtonElements {
332
+ [key: string]: KeyboardElement[];
333
+ }
334
+ export interface UtilitiesParams {
335
+ getOptions: () => KeyboardOptions;
336
+ getCaretPosition: () => number | null;
337
+ getCaretPositionEnd: () => number | null;
338
+ dispatch: any;
339
+ }
340
+ export interface PhysicalKeyboardParams {
341
+ getOptions: () => KeyboardOptions;
342
+ dispatch: any;
343
+ }
344
+ export interface KeyboardOptions {
345
+ /**
346
+ * Modify the keyboard layout.
347
+ */
348
+ layout?: KeyboardLayoutObject;
349
+ /**
350
+ * Specifies which layout should be used.
351
+ */
352
+ layoutName?: string;
353
+ /**
354
+ * Replaces variable buttons (such as `{bksp}`) with a human-friendly name (e.g.: `backspace`).
355
+ */
356
+ display?: {
357
+ [button: string]: string;
358
+ };
359
+ /**
360
+ * By default, when you set the display property, you replace the default one. This setting merges them instead.
361
+ */
362
+ mergeDisplay?: boolean;
363
+ /**
364
+ * A prop to add your own css classes to the keyboard wrapper. You can add multiple classes separated by a space.
365
+ */
366
+ theme?: string;
367
+ /**
368
+ * A prop to add your own css classes to one or several buttons.
369
+ */
370
+ buttonTheme?: KeyboardButtonTheme[];
371
+ /**
372
+ * A prop to add your own attributes to one or several buttons.
373
+ */
374
+ buttonAttributes?: KeyboardButtonAttributes[];
375
+ /**
376
+ * Runs a `console.log` every time a key is pressed. Displays the buttons pressed and the current input.
377
+ */
378
+ debug?: boolean;
379
+ /**
380
+ * Specifies whether clicking the "ENTER" button will input a newline (`\n`) or not.
381
+ */
382
+ newLineOnEnter?: boolean;
383
+ /**
384
+ * Specifies whether clicking the "TAB" button will input a tab character (`\t`) or not.
385
+ */
386
+ tabCharOnTab?: boolean;
387
+ /**
388
+ * Allows you to use a single simple-keyboard instance for several inputs.
389
+ */
390
+ inputName?: string;
391
+ /**
392
+ * `number`: Restrains all of simple-keyboard inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.
393
+ *
394
+ * `{ [inputName: string]: number }`: Restrains simple-keyboard’s individual inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.
395
+ */
396
+ maxLength?: any;
397
+ /**
398
+ * When set to true, this option synchronizes the internal input of every simple-keyboard instance.
399
+ */
400
+ syncInstanceInputs?: boolean;
401
+ /**
402
+ * Enable highlighting of keys pressed on physical keyboard.
403
+ */
404
+ physicalKeyboardHighlight?: boolean;
405
+ /**
406
+ * Calls handler for a button highlighted by physicalKeyboardHighlight
407
+ * In other words, this calls keyboard.handleButtonClicked(buttonName) on the highlighted button
408
+ */
409
+ physicalKeyboardHighlightPress?: boolean;
410
+ /**
411
+ * Trigger click on a button's element when using physicalKeyboardHighlightPress
412
+ * In other words, this calls button.click() on the highlighted button
413
+ */
414
+ physicalKeyboardHighlightPressUseClick?: boolean;
415
+ /**
416
+ * Whether physicalKeyboardHighlightPress should use pointer events to trigger buttons.
417
+ */
418
+ physicalKeyboardHighlightPressUsePointerEvents?: boolean;
419
+ /**
420
+ * Define the text color that the physical keyboard highlighted key should have.
421
+ */
422
+ physicalKeyboardHighlightTextColor?: string;
423
+ /**
424
+ * Define the background color that the physical keyboard highlighted key should have.
425
+ */
426
+ physicalKeyboardHighlightBgColor?: string;
427
+ /**
428
+ * Whether physicalKeyboardHighlight should use preventDefault to disable default browser actions.
429
+ */
430
+ physicalKeyboardHighlightPreventDefault?: boolean;
431
+ /**
432
+ * Calling preventDefault for the mousedown events keeps the focus on the input.
433
+ */
434
+ preventMouseDownDefault?: boolean;
435
+ /**
436
+ * Calling preventDefault for the mouseup events.
437
+ */
438
+ preventMouseUpDefault?: boolean;
439
+ /**
440
+ * Stops pointer down events on simple-keyboard buttons from bubbling to parent elements.
441
+ */
442
+ stopMouseDownPropagation?: boolean;
443
+ /**
444
+ * Stops pointer up events on simple-keyboard buttons from bubbling to parent elements.
445
+ */
446
+ stopMouseUpPropagation?: boolean;
447
+ /**
448
+ * Render buttons as a button element instead of a div element.
449
+ */
450
+ useButtonTag?: boolean;
451
+ /**
452
+ * A prop to ensure characters are always be added/removed at the end of the string.
453
+ */
454
+ disableCaretPositioning?: boolean;
455
+ /**
456
+ * Restrains input(s) change to the defined regular expression pattern.
457
+ */
458
+ inputPattern?: any;
459
+ /**
460
+ * Instructs simple-keyboard to use touch events instead of click events.
461
+ */
462
+ useTouchEvents?: boolean;
463
+ /**
464
+ * Enable useTouchEvents automatically when touch device is detected.
465
+ */
466
+ autoUseTouchEvents?: boolean;
467
+ /**
468
+ * Opt out of PointerEvents handling, falling back to the prior mouse event logic.
469
+ */
470
+ useMouseEvents?: boolean;
471
+ /**
472
+ * Disable button hold action.
473
+ */
474
+ disableButtonHold?: boolean;
475
+ /**
476
+ * Adds unicode right-to-left control characters to input return values.
477
+ */
478
+ rtl?: boolean;
479
+ /**
480
+ * Enable input method editor candidate list support.
481
+ */
482
+ enableLayoutCandidates?: boolean;
483
+ /**
484
+ * Character suggestions to be shown on certain key presses
485
+ */
486
+ layoutCandidates?: {
487
+ [key: string]: string;
488
+ };
489
+ /**
490
+ * Exclude buttons from layout
491
+ */
492
+ excludeFromLayout?: {
493
+ [key: string]: string[];
494
+ };
495
+ /**
496
+ * Determines size of layout candidate list
497
+ */
498
+ layoutCandidatesPageSize?: number;
499
+ /**
500
+ * Determines whether layout candidate match should be case sensitive.
501
+ */
502
+ layoutCandidatesCaseSensitiveMatch?: boolean;
503
+ /**
504
+ * Disables the automatic normalization for selected layout candidates
505
+ */
506
+ disableCandidateNormalization?: boolean;
507
+ /**
508
+ * Enables onKeyPress triggering for layoutCandidate items
509
+ */
510
+ enableLayoutCandidatesKeyPress?: boolean;
511
+ /**
512
+ * Updates caret when selectionchange event is fired
513
+ */
514
+ updateCaretOnSelectionChange?: boolean;
515
+ /**
516
+ * Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).
517
+ */
518
+ onRender?: (instance: SimpleKeyboard) => void;
519
+ /**
520
+ * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).
521
+ */
522
+ onInit?: (instance: SimpleKeyboard) => void;
523
+ /**
524
+ * Retrieves the current input
525
+ */
526
+ onChange?: (input: string, e?: MouseEvent) => any;
527
+ /**
528
+ * Retrieves all inputs
529
+ */
530
+ onChangeAll?: (inputObj: KeyboardInput, e?: MouseEvent) => any;
531
+ /**
532
+ * Retrieves the pressed key
533
+ */
534
+ onKeyPress?: (button: string, e?: MouseEvent) => any;
535
+ /**
536
+ * Retrieves the released key
537
+ */
538
+ onKeyReleased?: (button: string, e?: MouseEvent) => any;
539
+ /**
540
+ * Executes the callback function before an input is about to be updated
541
+ */
542
+ beforeInputUpdate?: (instance: SimpleKeyboard) => void;
543
+ /**
544
+ * Module options can have any format
545
+ */
546
+ [name: string]: any;
547
+ }
548
+ /**
549
+ * Physical Keyboard Service
550
+ */
551
+ export interface PhysicalKeyboard {
552
+ getOptions: () => KeyboardOptions;
553
+ dispatch: any;
554
+ /**
555
+ * Creates an instance of the PhysicalKeyboard service
556
+ */
557
+ constructor: ({ dispatch, getOptions }: PhysicalKeyboardParams) => any
558
+ handleHighlightKeyDown(e: KeyboardEvent): void;
559
+ handleHighlightKeyUp(e: KeyboardEvent): void;
560
+ /**
561
+ * Transforms a KeyboardEvent's "key.code" string into a simple-keyboard layout format
562
+ * @param {object} e The KeyboardEvent
563
+ */
564
+ getSimpleKeyboardLayoutKey(e: KeyboardEvent): string;
565
+ /**
566
+ * Retrieve key from keyCode
567
+ */
568
+ keyCodeToKey(keyCode: number): string;
569
+ isModifierKey: (e: KeyboardEvent) => boolean;
570
+ }
571
+ /**
572
+ * Utility Service
573
+ */
574
+ export interface Utilities {
575
+ getOptions: () => KeyboardOptions;
576
+ getCaretPosition: () => number | null;
577
+ getCaretPositionEnd: () => number | null;
578
+ dispatch: any;
579
+ maxLengthReached: boolean;
580
+ /**
581
+ * Creates an instance of the Utility service
582
+ */
583
+ constructor: ({ getOptions, getCaretPosition, getCaretPositionEnd, dispatch, }: UtilitiesParams) => any
584
+ /**
585
+ * Retrieve button type
586
+ *
587
+ * @param {string} button The button's layout name
588
+ * @return {string} The button type
589
+ */
590
+ getButtonType(button: string): string;
591
+ /**
592
+ * Adds default classes to a given button
593
+ *
594
+ * @param {string} button The button's layout name
595
+ * @return {string} The classes to be added to the button
596
+ */
597
+ getButtonClass(button: string): string;
598
+ /**
599
+ * Default button display labels
600
+ */
601
+ getDefaultDiplay(): {
602
+ "{bksp}": string;
603
+ "{backspace}": string;
604
+ "{enter}": string;
605
+ "{shift}": string;
606
+ "{shiftleft}": string;
607
+ "{shiftright}": string;
608
+ "{alt}": string;
609
+ "{s}": string;
610
+ "{tab}": string;
611
+ "{lock}": string;
612
+ "{capslock}": string;
613
+ "{accept}": string;
614
+ "{space}": string;
615
+ "{//}": string;
616
+ "{esc}": string;
617
+ "{escape}": string;
618
+ "{f1}": string;
619
+ "{f2}": string;
620
+ "{f3}": string;
621
+ "{f4}": string;
622
+ "{f5}": string;
623
+ "{f6}": string;
624
+ "{f7}": string;
625
+ "{f8}": string;
626
+ "{f9}": string;
627
+ "{f10}": string;
628
+ "{f11}": string;
629
+ "{f12}": string;
630
+ "{numpaddivide}": string;
631
+ "{numlock}": string;
632
+ "{arrowup}": string;
633
+ "{arrowleft}": string;
634
+ "{arrowdown}": string;
635
+ "{arrowright}": string;
636
+ "{prtscr}": string;
637
+ "{scrolllock}": string;
638
+ "{pause}": string;
639
+ "{insert}": string;
640
+ "{home}": string;
641
+ "{pageup}": string;
642
+ "{delete}": string;
643
+ "{forwarddelete}": string;
644
+ "{end}": string;
645
+ "{pagedown}": string;
646
+ "{numpadmultiply}": string;
647
+ "{numpadsubtract}": string;
648
+ "{numpadadd}": string;
649
+ "{numpadenter}": string;
650
+ "{period}": string;
651
+ "{numpaddecimal}": string;
652
+ "{numpad0}": string;
653
+ "{numpad1}": string;
654
+ "{numpad2}": string;
655
+ "{numpad3}": string;
656
+ "{numpad4}": string;
657
+ "{numpad5}": string;
658
+ "{numpad6}": string;
659
+ "{numpad7}": string;
660
+ "{numpad8}": string;
661
+ "{numpad9}": string;
662
+ };
663
+ /**
664
+ * Returns the display (label) name for a given button
665
+ *
666
+ * @param {string} button The button's layout name
667
+ * @param {object} display The provided display option
668
+ * @param {boolean} mergeDisplay Whether the provided param value should be merged with the default one.
669
+ */
670
+ getButtonDisplayName(button: string, display: KeyboardOptions["display"], mergeDisplay?: boolean): string;
671
+ /**
672
+ * Returns the updated input resulting from clicking a given button
673
+ *
674
+ * @param {string} button The button's layout name
675
+ * @param {string} input The input string
676
+ * @param {number} caretPos The cursor's current position
677
+ * @param {number} caretPosEnd The cursor's current end position
678
+ * @param {boolean} moveCaret Whether to update simple-keyboard's cursor
679
+ */
680
+ getUpdatedInput(button: string, input: string, caretPos: any, caretPosEnd?: any, moveCaret?: boolean): string;
681
+ /**
682
+ * Moves the cursor position by a given amount
683
+ *
684
+ * @param {number} length Represents by how many characters the input should be moved
685
+ * @param {boolean} minus Whether the cursor should be moved to the left or not.
686
+ */
687
+ updateCaretPos(length: number, minus?: boolean): void;
688
+ /**
689
+ * Action method of updateCaretPos
690
+ *
691
+ * @param {number} length Represents by how many characters the input should be moved
692
+ * @param {boolean} minus Whether the cursor should be moved to the left or not.
693
+ */
694
+ updateCaretPosAction(length: number, minus?: boolean): number | null;
695
+ /**
696
+ * Adds a string to the input at a given position
697
+ *
698
+ * @param {string} source The source input
699
+ * @param {string} str The string to add
700
+ * @param {number} position The (cursor) position where the string should be added
701
+ * @param {boolean} moveCaret Whether to update simple-keyboard's cursor
702
+ */
703
+ addStringAt(source: string, str: string, position?: number, positionEnd?: number, moveCaret?: boolean): string;
704
+ /**
705
+ * Check whether the button is a standard button
706
+ */
707
+ isStandardButton: (button: string) => boolean | "";
708
+ /**
709
+ * Removes an amount of characters before a given position
710
+ *
711
+ * @param {string} source The source input
712
+ * @param {number} position The (cursor) position from where the characters should be removed
713
+ * @param {boolean} moveCaret Whether to update simple-keyboard's cursor
714
+ */
715
+ removeAt(source: string, position?: number, positionEnd?: number, moveCaret?: boolean): string;
716
+ /**
717
+ * Removes an amount of characters after a given position
718
+ *
719
+ * @param {string} source The source input
720
+ * @param {number} position The (cursor) position from where the characters should be removed
721
+ */
722
+ removeForwardsAt(source: string, position?: number, positionEnd?: number, moveCaret?: boolean): string;
723
+ /**
724
+ * Determines whether the maxLength has been reached. This function is called when the maxLength option it set.
725
+ *
726
+ * @param {object} inputObj
727
+ * @param {string} updatedInput
728
+ */
729
+ handleMaxLength(inputObj: KeyboardInput, updatedInput: string): boolean | undefined;
730
+ /**
731
+ * Gets the current value of maxLengthReached
732
+ */
733
+ isMaxLengthReached(): boolean;
734
+ /**
735
+ * Determines whether a touch device is being used
736
+ */
737
+ isTouchDevice(): number | true;
738
+ /**
739
+ * Determines whether pointer events are supported
740
+ */
741
+ pointerEventsSupported(): boolean;
742
+ /**
743
+ * Bind all methods in a given class
744
+ */
745
+ /**
746
+ * Transforms an arbitrary string to camelCase
747
+ *
748
+ * @param {string} str The string to transform.
749
+ */
750
+ camelCase(str: string): string;
751
+ /**
752
+ * Split array into chunks
753
+ */
754
+ chunkArray<T>(arr: T[], size: number): T[][];
755
+ /**
756
+ * Escape regex input
757
+ */
758
+ escapeRegex(str: string): string;
759
+ /**
760
+ * Calculate caret position offset when using rtl option
761
+ */
762
+ getRtlOffset(index: number, input: string): number;
763
+ /**
764
+ * Reusable empty function
765
+ */
766
+ }
767
+ export interface CandidateBox {
768
+ utilities: Utilities;
769
+ options: KeyboardOptions;
770
+ candidateBoxElement: HTMLDivElement;
771
+ pageIndex: number;
772
+ pageSize: number;
773
+ constructor: ({ utilities, options }: CandidateBoxParams) => any
774
+ destroy(): void;
775
+ show({ candidateValue, targetElement, onSelect, }: CandidateBoxShowParams): void;
776
+ renderPage({ candidateListPages, targetElement, pageIndex, nbPages, onItemSelected, }: CandidateBoxRenderParams): void;
777
+ }