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