simple-keyboard 3.4.209 → 3.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.
@@ -1,291 +1,291 @@
1
- import "./css/Keyboard.css";
2
- import PhysicalKeyboard from "../services/PhysicalKeyboard";
3
- import { KeyboardOptions, KeyboardInput, KeyboardButtonElements, KeyboardHandlerEvent, KeyboardElement } from "../interfaces";
4
- import CandidateBox from "./CandidateBox";
5
- /**
6
- * Root class for simple-keyboard.
7
- * This class:
8
- * - Parses the options
9
- * - Renders the rows and buttons
10
- * - Handles button functionality
11
- */
12
- declare class SimpleKeyboard {
13
- input: KeyboardInput;
14
- options: KeyboardOptions;
15
- utilities: any;
16
- caretPosition: number | null;
17
- caretPositionEnd: number | null;
18
- keyboardDOM: KeyboardElement;
19
- keyboardPluginClasses: string;
20
- keyboardDOMClass: string;
21
- buttonElements: KeyboardButtonElements;
22
- currentInstanceName: string;
23
- allKeyboardInstances: {
24
- [key: string]: SimpleKeyboard;
25
- };
26
- keyboardInstanceNames: string[];
27
- isFirstKeyboardInstance: boolean;
28
- physicalKeyboard: PhysicalKeyboard;
29
- modules: {
30
- [key: string]: any;
31
- };
32
- activeButtonClass: string;
33
- holdInteractionTimeout: number;
34
- holdTimeout: number;
35
- isMouseHold: boolean;
36
- initialized: boolean;
37
- candidateBox: CandidateBox | null;
38
- keyboardRowsDOM: KeyboardElement;
39
- defaultName: string;
40
- activeInputElement: HTMLInputElement | HTMLTextAreaElement | null;
41
- /**
42
- * Creates an instance of SimpleKeyboard
43
- * @param {Array} params 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.
44
- */
45
- constructor(selectorOrOptions?: string | HTMLDivElement | KeyboardOptions, keyboardOptions?: KeyboardOptions);
46
- /**
47
- * parseParams
48
- */
49
- handleParams: (selectorOrOptions?: string | HTMLDivElement | KeyboardOptions, keyboardOptions?: KeyboardOptions) => {
50
- keyboardDOMClass: string;
51
- keyboardDOM: KeyboardElement;
52
- options: Partial<KeyboardOptions | undefined>;
53
- };
54
- /**
55
- * Getters
56
- */
57
- getOptions: () => KeyboardOptions;
58
- getCaretPosition: () => number | null;
59
- getCaretPositionEnd: () => number | null;
60
- /**
61
- * Changes the internal caret position
62
- * @param {number} position The caret's start position
63
- * @param {number} positionEnd The caret's end position
64
- */
65
- setCaretPosition(position: number | null, endPosition?: number | null): void;
66
- /**
67
- * Retrieve the candidates for a given input
68
- * @param input The input string to check
69
- */
70
- getInputCandidates(input: string): {
71
- candidateKey: string;
72
- candidateValue: string;
73
- } | Record<string, never>;
74
- /**
75
- * Shows a suggestion box with a list of candidate words
76
- * @param candidates The chosen candidates string as defined in the layoutCandidates option
77
- * @param targetElement The element next to which the candidates box will be shown
78
- */
79
- showCandidatesBox(candidateKey: string, candidateValue: string, targetElement: KeyboardElement): void;
80
- /**
81
- * Handles clicks made to keyboard buttons
82
- * @param {string} button The button's layout name.
83
- */
84
- handleButtonClicked(button: string, e?: KeyboardHandlerEvent): void;
85
- /**
86
- * Get mouse hold state
87
- */
88
- getMouseHold(): boolean;
89
- /**
90
- * Mark mouse hold state as set
91
- */
92
- setMouseHold(value: boolean): void;
93
- /**
94
- * Handles button mousedown
95
- */
96
- handleButtonMouseDown(button: string, e: KeyboardHandlerEvent): void;
97
- /**
98
- * Handles button mouseup
99
- */
100
- handleButtonMouseUp(button?: string, e?: KeyboardHandlerEvent): void;
101
- /**
102
- * Handles container mousedown
103
- */
104
- handleKeyboardContainerMouseDown(e: KeyboardHandlerEvent): void;
105
- /**
106
- * Handles button hold
107
- */
108
- handleButtonHold(button: string): void;
109
- /**
110
- * Send a command to all simple-keyboard instances (if you have several instances).
111
- */
112
- syncInstanceInputs(): void;
113
- /**
114
- * Clear the keyboard’s input.
115
- * @param {string} [inputName] optional - the internal input to select
116
- */
117
- clearInput(inputName?: string): void;
118
- /**
119
- * Get the keyboard’s input (You can also get it from the onChange prop).
120
- * @param {string} [inputName] optional - the internal input to select
121
- */
122
- getInput(inputName?: string, skipSync?: boolean): string;
123
- /**
124
- * Get all simple-keyboard inputs
125
- */
126
- getAllInputs(): KeyboardInput;
127
- /**
128
- * Set the keyboard’s input.
129
- * @param {string} input the input value
130
- * @param {string} inputName optional - the internal input to select
131
- */
132
- setInput(input: string, inputName?: string, skipSync?: boolean): void;
133
- /**
134
- * Replace the input object (`keyboard.input`)
135
- * @param {object} inputObj The input object
136
- */
137
- replaceInput(inputObj: KeyboardInput): void;
138
- /**
139
- * Set new option or modify existing ones after initialization.
140
- * @param {object} options The options to set
141
- */
142
- setOptions(options?: {}): void;
143
- /**
144
- * Detecting changes to non-function options
145
- * This allows us to ascertain whether a button re-render is needed
146
- */
147
- changedOptions(newOptions: Partial<KeyboardOptions>): string[];
148
- /**
149
- * Executing actions depending on changed options
150
- * @param {object} options The options to set
151
- */
152
- onSetOptions(changedOptions?: string[]): void;
153
- /**
154
- * Remove all keyboard rows and reset keyboard values.
155
- * Used internally between re-renders.
156
- */
157
- resetRows(): void;
158
- /**
159
- * Send a command to all simple-keyboard instances at once (if you have multiple instances).
160
- * @param {function(instance: object, key: string)} callback Function to run on every instance
161
- */
162
- dispatch(callback: (instance: SimpleKeyboard, key?: string) => void): void;
163
- /**
164
- * Adds/Modifies an entry to the `buttonTheme`. Basically a way to add a class to a button.
165
- * @param {string} buttons List of buttons to select (separated by a space).
166
- * @param {string} className Classes to give to the selected buttons (separated by space).
167
- */
168
- addButtonTheme(buttons: string, className: string): void;
169
- /**
170
- * Removes/Amends an entry to the `buttonTheme`. Basically a way to remove a class previously added to a button through buttonTheme or addButtonTheme.
171
- * @param {string} buttons List of buttons to select (separated by a space).
172
- * @param {string} className Classes to give to the selected buttons (separated by space).
173
- */
174
- removeButtonTheme(buttons: string, className: string): void;
175
- /**
176
- * Get the DOM Element of a button. If there are several buttons with the same name, an array of the DOM Elements is returned.
177
- * @param {string} button The button layout name to select
178
- */
179
- getButtonElement(button: string): KeyboardElement | KeyboardElement[] | undefined;
180
- /**
181
- * This handles the "inputPattern" option
182
- * by checking if the provided inputPattern passes
183
- */
184
- inputPatternIsValid(inputVal: string): boolean;
185
- /**
186
- * Handles simple-keyboard event listeners
187
- */
188
- setEventListeners(): void;
189
- /**
190
- * Event Handler: KeyUp
191
- */
192
- handleKeyUp(event: KeyboardHandlerEvent): void;
193
- /**
194
- * Event Handler: KeyDown
195
- */
196
- handleKeyDown(event: KeyboardHandlerEvent): void;
197
- /**
198
- * Event Handler: MouseUp
199
- */
200
- handleMouseUp(event: KeyboardHandlerEvent): void;
201
- /**
202
- * Event Handler: TouchEnd
203
- */
204
- handleTouchEnd(event: KeyboardHandlerEvent): void;
205
- /**
206
- * Event Handler: Select
207
- */
208
- handleSelect(event: KeyboardHandlerEvent): void;
209
- /**
210
- * Event Handler: SelectionChange
211
- */
212
- handleSelectionChange(event: KeyboardHandlerEvent): void;
213
- /**
214
- * Called by {@link setEventListeners} when an event that warrants a cursor position update is triggered
215
- */
216
- caretEventHandler(event: KeyboardHandlerEvent): void;
217
- /**
218
- * Execute an operation on each button
219
- */
220
- recurseButtons(fn: any): void;
221
- /**
222
- * Destroy keyboard listeners and DOM elements
223
- */
224
- destroy(): void;
225
- /**
226
- * Process buttonTheme option
227
- */
228
- getButtonThemeClasses(button: string): string[];
229
- /**
230
- * Process buttonAttributes option
231
- */
232
- setDOMButtonAttributes(button: string, callback: any): void;
233
- onTouchDeviceDetected(): void;
234
- /**
235
- * Disabling contextual window for hg-button
236
- */
237
- disableContextualWindow(): void;
238
- /**
239
- * Process autoTouchEvents option
240
- */
241
- processAutoTouchEvents(): void;
242
- /**
243
- * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).
244
- */
245
- onInit(): void;
246
- /**
247
- * Executes the callback function before a simple-keyboard render.
248
- */
249
- beforeFirstRender(): void;
250
- /**
251
- * Executes the callback function before a simple-keyboard render.
252
- */
253
- beforeRender(): void;
254
- /**
255
- * Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).
256
- */
257
- onRender(): void;
258
- /**
259
- * Executes the callback function once all modules have been loaded
260
- */
261
- onModulesLoaded(): void;
262
- /**
263
- * Register module
264
- */
265
- registerModule: (name: string, initCallback: any) => void;
266
- /**
267
- * Load modules
268
- */
269
- loadModules(): void;
270
- /**
271
- * Get module prop
272
- */
273
- getModuleProp(name: string, prop: string): any;
274
- /**
275
- * getModulesList
276
- */
277
- getModulesList(): string[];
278
- /**
279
- * Parse Row DOM containers
280
- */
281
- parseRowDOMContainers(rowDOM: HTMLDivElement, rowIndex: number, containerStartIndexes: number[], containerEndIndexes: number[]): HTMLDivElement;
282
- /**
283
- * getKeyboardClassString
284
- */
285
- getKeyboardClassString: (...baseDOMClasses: any[]) => string;
286
- /**
287
- * Renders rows and buttons as per options
288
- */
289
- render(): void;
290
- }
291
- export default SimpleKeyboard;
1
+ import "./css/Keyboard.css";
2
+ import PhysicalKeyboard from "../services/PhysicalKeyboard";
3
+ import { KeyboardOptions, KeyboardInput, KeyboardButtonElements, KeyboardHandlerEvent, KeyboardElement } from "../interfaces";
4
+ import CandidateBox from "./CandidateBox";
5
+ /**
6
+ * Root class for simple-keyboard.
7
+ * This class:
8
+ * - Parses the options
9
+ * - Renders the rows and buttons
10
+ * - Handles button functionality
11
+ */
12
+ declare class SimpleKeyboard {
13
+ input: KeyboardInput;
14
+ options: KeyboardOptions;
15
+ utilities: any;
16
+ caretPosition: number | null;
17
+ caretPositionEnd: number | null;
18
+ keyboardDOM: KeyboardElement;
19
+ keyboardPluginClasses: string;
20
+ keyboardDOMClass: string;
21
+ buttonElements: KeyboardButtonElements;
22
+ currentInstanceName: string;
23
+ allKeyboardInstances: {
24
+ [key: string]: SimpleKeyboard;
25
+ };
26
+ keyboardInstanceNames: string[];
27
+ isFirstKeyboardInstance: boolean;
28
+ physicalKeyboard: PhysicalKeyboard;
29
+ modules: {
30
+ [key: string]: any;
31
+ };
32
+ activeButtonClass: string;
33
+ holdInteractionTimeout: number;
34
+ holdTimeout: number;
35
+ isMouseHold: boolean;
36
+ initialized: boolean;
37
+ candidateBox: CandidateBox | null;
38
+ keyboardRowsDOM: KeyboardElement;
39
+ defaultName: string;
40
+ activeInputElement: HTMLInputElement | HTMLTextAreaElement | null;
41
+ /**
42
+ * Creates an instance of SimpleKeyboard
43
+ * @param {Array} params 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.
44
+ */
45
+ constructor(selectorOrOptions?: string | HTMLDivElement | KeyboardOptions, keyboardOptions?: KeyboardOptions);
46
+ /**
47
+ * parseParams
48
+ */
49
+ handleParams: (selectorOrOptions?: string | HTMLDivElement | KeyboardOptions, keyboardOptions?: KeyboardOptions) => {
50
+ keyboardDOMClass: string;
51
+ keyboardDOM: KeyboardElement;
52
+ options: Partial<KeyboardOptions | undefined>;
53
+ };
54
+ /**
55
+ * Getters
56
+ */
57
+ getOptions: () => KeyboardOptions;
58
+ getCaretPosition: () => number | null;
59
+ getCaretPositionEnd: () => number | null;
60
+ /**
61
+ * Changes the internal caret position
62
+ * @param {number} position The caret's start position
63
+ * @param {number} positionEnd The caret's end position
64
+ */
65
+ setCaretPosition(position: number | null, endPosition?: number | null): void;
66
+ /**
67
+ * Retrieve the candidates for a given input
68
+ * @param input The input string to check
69
+ */
70
+ getInputCandidates(input: string): {
71
+ candidateKey: string;
72
+ candidateValue: string;
73
+ } | Record<string, never>;
74
+ /**
75
+ * Shows a suggestion box with a list of candidate words
76
+ * @param candidates The chosen candidates string as defined in the layoutCandidates option
77
+ * @param targetElement The element next to which the candidates box will be shown
78
+ */
79
+ showCandidatesBox(candidateKey: string, candidateValue: string, targetElement: KeyboardElement): void;
80
+ /**
81
+ * Handles clicks made to keyboard buttons
82
+ * @param {string} button The button's layout name.
83
+ */
84
+ handleButtonClicked(button: string, e?: KeyboardHandlerEvent): void;
85
+ /**
86
+ * Get mouse hold state
87
+ */
88
+ getMouseHold(): boolean;
89
+ /**
90
+ * Mark mouse hold state as set
91
+ */
92
+ setMouseHold(value: boolean): void;
93
+ /**
94
+ * Handles button mousedown
95
+ */
96
+ handleButtonMouseDown(button: string, e: KeyboardHandlerEvent): void;
97
+ /**
98
+ * Handles button mouseup
99
+ */
100
+ handleButtonMouseUp(button?: string, e?: KeyboardHandlerEvent): void;
101
+ /**
102
+ * Handles container mousedown
103
+ */
104
+ handleKeyboardContainerMouseDown(e: KeyboardHandlerEvent): void;
105
+ /**
106
+ * Handles button hold
107
+ */
108
+ handleButtonHold(button: string): void;
109
+ /**
110
+ * Send a command to all simple-keyboard instances (if you have several instances).
111
+ */
112
+ syncInstanceInputs(): void;
113
+ /**
114
+ * Clear the keyboard’s input.
115
+ * @param {string} [inputName] optional - the internal input to select
116
+ */
117
+ clearInput(inputName?: string): void;
118
+ /**
119
+ * Get the keyboard’s input (You can also get it from the onChange prop).
120
+ * @param {string} [inputName] optional - the internal input to select
121
+ */
122
+ getInput(inputName?: string, skipSync?: boolean): string;
123
+ /**
124
+ * Get all simple-keyboard inputs
125
+ */
126
+ getAllInputs(): KeyboardInput;
127
+ /**
128
+ * Set the keyboard’s input.
129
+ * @param {string} input the input value
130
+ * @param {string} inputName optional - the internal input to select
131
+ */
132
+ setInput(input: string, inputName?: string, skipSync?: boolean): void;
133
+ /**
134
+ * Replace the input object (`keyboard.input`)
135
+ * @param {object} inputObj The input object
136
+ */
137
+ replaceInput(inputObj: KeyboardInput): void;
138
+ /**
139
+ * Set new option or modify existing ones after initialization.
140
+ * @param {object} options The options to set
141
+ */
142
+ setOptions(options?: {}): void;
143
+ /**
144
+ * Detecting changes to non-function options
145
+ * This allows us to ascertain whether a button re-render is needed
146
+ */
147
+ changedOptions(newOptions: Partial<KeyboardOptions>): string[];
148
+ /**
149
+ * Executing actions depending on changed options
150
+ * @param {object} options The options to set
151
+ */
152
+ onSetOptions(changedOptions?: string[]): void;
153
+ /**
154
+ * Remove all keyboard rows and reset keyboard values.
155
+ * Used internally between re-renders.
156
+ */
157
+ resetRows(): void;
158
+ /**
159
+ * Send a command to all simple-keyboard instances at once (if you have multiple instances).
160
+ * @param {function(instance: object, key: string)} callback Function to run on every instance
161
+ */
162
+ dispatch(callback: (instance: SimpleKeyboard, key?: string) => void): void;
163
+ /**
164
+ * Adds/Modifies an entry to the `buttonTheme`. Basically a way to add a class to a button.
165
+ * @param {string} buttons List of buttons to select (separated by a space).
166
+ * @param {string} className Classes to give to the selected buttons (separated by space).
167
+ */
168
+ addButtonTheme(buttons: string, className: string): void;
169
+ /**
170
+ * Removes/Amends an entry to the `buttonTheme`. Basically a way to remove a class previously added to a button through buttonTheme or addButtonTheme.
171
+ * @param {string} buttons List of buttons to select (separated by a space).
172
+ * @param {string} className Classes to give to the selected buttons (separated by space).
173
+ */
174
+ removeButtonTheme(buttons: string, className: string): void;
175
+ /**
176
+ * Get the DOM Element of a button. If there are several buttons with the same name, an array of the DOM Elements is returned.
177
+ * @param {string} button The button layout name to select
178
+ */
179
+ getButtonElement(button: string): KeyboardElement | KeyboardElement[] | undefined;
180
+ /**
181
+ * This handles the "inputPattern" option
182
+ * by checking if the provided inputPattern passes
183
+ */
184
+ inputPatternIsValid(inputVal: string): boolean;
185
+ /**
186
+ * Handles simple-keyboard event listeners
187
+ */
188
+ setEventListeners(): void;
189
+ /**
190
+ * Event Handler: KeyUp
191
+ */
192
+ handleKeyUp(event: KeyboardHandlerEvent): void;
193
+ /**
194
+ * Event Handler: KeyDown
195
+ */
196
+ handleKeyDown(event: KeyboardHandlerEvent): void;
197
+ /**
198
+ * Event Handler: MouseUp
199
+ */
200
+ handleMouseUp(event: KeyboardHandlerEvent): void;
201
+ /**
202
+ * Event Handler: TouchEnd
203
+ */
204
+ handleTouchEnd(event: KeyboardHandlerEvent): void;
205
+ /**
206
+ * Event Handler: Select
207
+ */
208
+ handleSelect(event: KeyboardHandlerEvent): void;
209
+ /**
210
+ * Event Handler: SelectionChange
211
+ */
212
+ handleSelectionChange(event: KeyboardHandlerEvent): void;
213
+ /**
214
+ * Called by {@link setEventListeners} when an event that warrants a cursor position update is triggered
215
+ */
216
+ caretEventHandler(event: KeyboardHandlerEvent): void;
217
+ /**
218
+ * Execute an operation on each button
219
+ */
220
+ recurseButtons(fn: any): void;
221
+ /**
222
+ * Destroy keyboard listeners and DOM elements
223
+ */
224
+ destroy(): void;
225
+ /**
226
+ * Process buttonTheme option
227
+ */
228
+ getButtonThemeClasses(button: string): string[];
229
+ /**
230
+ * Process buttonAttributes option
231
+ */
232
+ setDOMButtonAttributes(button: string, callback: any): void;
233
+ onTouchDeviceDetected(): void;
234
+ /**
235
+ * Disabling contextual window for hg-button
236
+ */
237
+ disableContextualWindow(): void;
238
+ /**
239
+ * Process autoTouchEvents option
240
+ */
241
+ processAutoTouchEvents(): void;
242
+ /**
243
+ * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).
244
+ */
245
+ onInit(): void;
246
+ /**
247
+ * Executes the callback function before a simple-keyboard render.
248
+ */
249
+ beforeFirstRender(): void;
250
+ /**
251
+ * Executes the callback function before a simple-keyboard render.
252
+ */
253
+ beforeRender(): void;
254
+ /**
255
+ * Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).
256
+ */
257
+ onRender(): void;
258
+ /**
259
+ * Executes the callback function once all modules have been loaded
260
+ */
261
+ onModulesLoaded(): void;
262
+ /**
263
+ * Register module
264
+ */
265
+ registerModule: (name: string, initCallback: any) => void;
266
+ /**
267
+ * Load modules
268
+ */
269
+ loadModules(): void;
270
+ /**
271
+ * Get module prop
272
+ */
273
+ getModuleProp(name: string, prop: string): any;
274
+ /**
275
+ * getModulesList
276
+ */
277
+ getModulesList(): string[];
278
+ /**
279
+ * Parse Row DOM containers
280
+ */
281
+ parseRowDOMContainers(rowDOM: HTMLDivElement, rowIndex: number, containerStartIndexes: number[], containerEndIndexes: number[]): HTMLDivElement;
282
+ /**
283
+ * getKeyboardClassString
284
+ */
285
+ getKeyboardClassString: (...baseDOMClasses: any[]) => string;
286
+ /**
287
+ * Renders rows and buttons as per options
288
+ */
289
+ render(): void;
290
+ }
291
+ export default SimpleKeyboard;
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * simple-keyboard v3.4.209
3
+ * simple-keyboard v3.5.0
4
4
  * https://github.com/hodgef/simple-keyboard
5
5
  *
6
6
  * Copyright (c) Francisco Hodge (https://github.com/hodgef) and project contributors.
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import "./polyfills";
2
- import SimpleKeyboard from "./components/Keyboard";
3
- export { SimpleKeyboard };
4
- export default SimpleKeyboard;
1
+ import "./polyfills";
2
+ import SimpleKeyboard from "./components/Keyboard";
3
+ export { SimpleKeyboard };
4
+ export default SimpleKeyboard;