simple-keyboard 3.3.27 → 3.4.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,283 +1,283 @@
1
- import "./css/Keyboard.css";
2
- import PhysicalKeyboard from "../services/PhysicalKeyboard";
3
- import { KeyboardOptions, KeyboardInput, KeyboardButtonElements, KeyboardHandlerEvent, KeyboardElement, KeyboardParams } 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(...params: KeyboardParams);
46
- /**
47
- * parseParams
48
- */
49
- handleParams: (params: KeyboardParams) => {
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
- * Handles button mousedown
87
- */
88
- handleButtonMouseDown(button: string, e: KeyboardHandlerEvent): void;
89
- /**
90
- * Handles button mouseup
91
- */
92
- handleButtonMouseUp(button?: string, e?: KeyboardHandlerEvent): void;
93
- /**
94
- * Handles container mousedown
95
- */
96
- handleKeyboardContainerMouseDown(e: KeyboardHandlerEvent): void;
97
- /**
98
- * Handles button hold
99
- */
100
- handleButtonHold(button: string): void;
101
- /**
102
- * Send a command to all simple-keyboard instances (if you have several instances).
103
- */
104
- syncInstanceInputs(): void;
105
- /**
106
- * Clear the keyboard’s input.
107
- * @param {string} [inputName] optional - the internal input to select
108
- */
109
- clearInput(inputName?: string): void;
110
- /**
111
- * Get the keyboard’s input (You can also get it from the onChange prop).
112
- * @param {string} [inputName] optional - the internal input to select
113
- */
114
- getInput(inputName?: string, skipSync?: boolean): string;
115
- /**
116
- * Get all simple-keyboard inputs
117
- */
118
- getAllInputs(): KeyboardInput;
119
- /**
120
- * Set the keyboard’s input.
121
- * @param {string} input the input value
122
- * @param {string} inputName optional - the internal input to select
123
- */
124
- setInput(input: string, inputName?: string, skipSync?: boolean): void;
125
- /**
126
- * Replace the input object (`keyboard.input`)
127
- * @param {object} inputObj The input object
128
- */
129
- replaceInput(inputObj: KeyboardInput): void;
130
- /**
131
- * Set new option or modify existing ones after initialization.
132
- * @param {object} options The options to set
133
- */
134
- setOptions(options?: {}): void;
135
- /**
136
- * Detecting changes to non-function options
137
- * This allows us to ascertain whether a button re-render is needed
138
- */
139
- changedOptions(newOptions: Partial<KeyboardOptions>): string[];
140
- /**
141
- * Executing actions depending on changed options
142
- * @param {object} options The options to set
143
- */
144
- onSetOptions(changedOptions?: string[]): void;
145
- /**
146
- * Remove all keyboard rows and reset keyboard values.
147
- * Used internally between re-renders.
148
- */
149
- resetRows(): void;
150
- /**
151
- * Send a command to all simple-keyboard instances at once (if you have multiple instances).
152
- * @param {function(instance: object, key: string)} callback Function to run on every instance
153
- */
154
- dispatch(callback: (instance: SimpleKeyboard, key?: string) => void): void;
155
- /**
156
- * Adds/Modifies an entry to the `buttonTheme`. Basically a way to add a class to a button.
157
- * @param {string} buttons List of buttons to select (separated by a space).
158
- * @param {string} className Classes to give to the selected buttons (separated by space).
159
- */
160
- addButtonTheme(buttons: string, className: string): void;
161
- /**
162
- * Removes/Amends an entry to the `buttonTheme`. Basically a way to remove a class previously added to a button through buttonTheme or addButtonTheme.
163
- * @param {string} buttons List of buttons to select (separated by a space).
164
- * @param {string} className Classes to give to the selected buttons (separated by space).
165
- */
166
- removeButtonTheme(buttons: string, className: string): void;
167
- /**
168
- * Get the DOM Element of a button. If there are several buttons with the same name, an array of the DOM Elements is returned.
169
- * @param {string} button The button layout name to select
170
- */
171
- getButtonElement(button: string): KeyboardElement | KeyboardElement[] | undefined;
172
- /**
173
- * This handles the "inputPattern" option
174
- * by checking if the provided inputPattern passes
175
- */
176
- inputPatternIsValid(inputVal: string): boolean;
177
- /**
178
- * Handles simple-keyboard event listeners
179
- */
180
- setEventListeners(): void;
181
- /**
182
- * Event Handler: KeyUp
183
- */
184
- handleKeyUp(event: KeyboardHandlerEvent): void;
185
- /**
186
- * Event Handler: KeyDown
187
- */
188
- handleKeyDown(event: KeyboardHandlerEvent): void;
189
- /**
190
- * Event Handler: MouseUp
191
- */
192
- handleMouseUp(event: KeyboardHandlerEvent): void;
193
- /**
194
- * Event Handler: TouchEnd
195
- */
196
- handleTouchEnd(event: KeyboardHandlerEvent): void;
197
- /**
198
- * Event Handler: Select
199
- */
200
- handleSelect(event: KeyboardHandlerEvent): void;
201
- /**
202
- * Event Handler: SelectionChange
203
- */
204
- handleSelectionChange(event: KeyboardHandlerEvent): void;
205
- /**
206
- * Called by {@link setEventListeners} when an event that warrants a cursor position update is triggered
207
- */
208
- caretEventHandler(event: KeyboardHandlerEvent): void;
209
- /**
210
- * Execute an operation on each button
211
- */
212
- recurseButtons(fn: any): void;
213
- /**
214
- * Destroy keyboard listeners and DOM elements
215
- */
216
- destroy(): void;
217
- /**
218
- * Process buttonTheme option
219
- */
220
- getButtonThemeClasses(button: string): string[];
221
- /**
222
- * Process buttonAttributes option
223
- */
224
- setDOMButtonAttributes(button: string, callback: any): void;
225
- onTouchDeviceDetected(): void;
226
- /**
227
- * Disabling contextual window for hg-button
228
- */
229
- disableContextualWindow(): void;
230
- /**
231
- * Process autoTouchEvents option
232
- */
233
- processAutoTouchEvents(): void;
234
- /**
235
- * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).
236
- */
237
- onInit(): void;
238
- /**
239
- * Executes the callback function before a simple-keyboard render.
240
- */
241
- beforeFirstRender(): void;
242
- /**
243
- * Executes the callback function before a simple-keyboard render.
244
- */
245
- beforeRender(): void;
246
- /**
247
- * Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).
248
- */
249
- onRender(): void;
250
- /**
251
- * Executes the callback function once all modules have been loaded
252
- */
253
- onModulesLoaded(): void;
254
- /**
255
- * Register module
256
- */
257
- registerModule: (name: string, initCallback: any) => void;
258
- /**
259
- * Load modules
260
- */
261
- loadModules(): void;
262
- /**
263
- * Get module prop
264
- */
265
- getModuleProp(name: string, prop: string): any;
266
- /**
267
- * getModulesList
268
- */
269
- getModulesList(): string[];
270
- /**
271
- * Parse Row DOM containers
272
- */
273
- parseRowDOMContainers(rowDOM: HTMLDivElement, rowIndex: number, containerStartIndexes: number[], containerEndIndexes: number[]): HTMLDivElement;
274
- /**
275
- * getKeyboardClassString
276
- */
277
- getKeyboardClassString: (...baseDOMClasses: any[]) => string;
278
- /**
279
- * Renders rows and buttons as per options
280
- */
281
- render(): void;
282
- }
283
- export default SimpleKeyboard;
1
+ import "./css/Keyboard.css";
2
+ import PhysicalKeyboard from "../services/PhysicalKeyboard";
3
+ import { KeyboardOptions, KeyboardInput, KeyboardButtonElements, KeyboardHandlerEvent, KeyboardElement, KeyboardParams } 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(...params: KeyboardParams);
46
+ /**
47
+ * parseParams
48
+ */
49
+ handleParams: (params: KeyboardParams) => {
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
+ * Handles button mousedown
87
+ */
88
+ handleButtonMouseDown(button: string, e: KeyboardHandlerEvent): void;
89
+ /**
90
+ * Handles button mouseup
91
+ */
92
+ handleButtonMouseUp(button?: string, e?: KeyboardHandlerEvent): void;
93
+ /**
94
+ * Handles container mousedown
95
+ */
96
+ handleKeyboardContainerMouseDown(e: KeyboardHandlerEvent): void;
97
+ /**
98
+ * Handles button hold
99
+ */
100
+ handleButtonHold(button: string): void;
101
+ /**
102
+ * Send a command to all simple-keyboard instances (if you have several instances).
103
+ */
104
+ syncInstanceInputs(): void;
105
+ /**
106
+ * Clear the keyboard’s input.
107
+ * @param {string} [inputName] optional - the internal input to select
108
+ */
109
+ clearInput(inputName?: string): void;
110
+ /**
111
+ * Get the keyboard’s input (You can also get it from the onChange prop).
112
+ * @param {string} [inputName] optional - the internal input to select
113
+ */
114
+ getInput(inputName?: string, skipSync?: boolean): string;
115
+ /**
116
+ * Get all simple-keyboard inputs
117
+ */
118
+ getAllInputs(): KeyboardInput;
119
+ /**
120
+ * Set the keyboard’s input.
121
+ * @param {string} input the input value
122
+ * @param {string} inputName optional - the internal input to select
123
+ */
124
+ setInput(input: string, inputName?: string, skipSync?: boolean): void;
125
+ /**
126
+ * Replace the input object (`keyboard.input`)
127
+ * @param {object} inputObj The input object
128
+ */
129
+ replaceInput(inputObj: KeyboardInput): void;
130
+ /**
131
+ * Set new option or modify existing ones after initialization.
132
+ * @param {object} options The options to set
133
+ */
134
+ setOptions(options?: {}): void;
135
+ /**
136
+ * Detecting changes to non-function options
137
+ * This allows us to ascertain whether a button re-render is needed
138
+ */
139
+ changedOptions(newOptions: Partial<KeyboardOptions>): string[];
140
+ /**
141
+ * Executing actions depending on changed options
142
+ * @param {object} options The options to set
143
+ */
144
+ onSetOptions(changedOptions?: string[]): void;
145
+ /**
146
+ * Remove all keyboard rows and reset keyboard values.
147
+ * Used internally between re-renders.
148
+ */
149
+ resetRows(): void;
150
+ /**
151
+ * Send a command to all simple-keyboard instances at once (if you have multiple instances).
152
+ * @param {function(instance: object, key: string)} callback Function to run on every instance
153
+ */
154
+ dispatch(callback: (instance: SimpleKeyboard, key?: string) => void): void;
155
+ /**
156
+ * Adds/Modifies an entry to the `buttonTheme`. Basically a way to add a class to a button.
157
+ * @param {string} buttons List of buttons to select (separated by a space).
158
+ * @param {string} className Classes to give to the selected buttons (separated by space).
159
+ */
160
+ addButtonTheme(buttons: string, className: string): void;
161
+ /**
162
+ * Removes/Amends an entry to the `buttonTheme`. Basically a way to remove a class previously added to a button through buttonTheme or addButtonTheme.
163
+ * @param {string} buttons List of buttons to select (separated by a space).
164
+ * @param {string} className Classes to give to the selected buttons (separated by space).
165
+ */
166
+ removeButtonTheme(buttons: string, className: string): void;
167
+ /**
168
+ * Get the DOM Element of a button. If there are several buttons with the same name, an array of the DOM Elements is returned.
169
+ * @param {string} button The button layout name to select
170
+ */
171
+ getButtonElement(button: string): KeyboardElement | KeyboardElement[] | undefined;
172
+ /**
173
+ * This handles the "inputPattern" option
174
+ * by checking if the provided inputPattern passes
175
+ */
176
+ inputPatternIsValid(inputVal: string): boolean;
177
+ /**
178
+ * Handles simple-keyboard event listeners
179
+ */
180
+ setEventListeners(): void;
181
+ /**
182
+ * Event Handler: KeyUp
183
+ */
184
+ handleKeyUp(event: KeyboardHandlerEvent): void;
185
+ /**
186
+ * Event Handler: KeyDown
187
+ */
188
+ handleKeyDown(event: KeyboardHandlerEvent): void;
189
+ /**
190
+ * Event Handler: MouseUp
191
+ */
192
+ handleMouseUp(event: KeyboardHandlerEvent): void;
193
+ /**
194
+ * Event Handler: TouchEnd
195
+ */
196
+ handleTouchEnd(event: KeyboardHandlerEvent): void;
197
+ /**
198
+ * Event Handler: Select
199
+ */
200
+ handleSelect(event: KeyboardHandlerEvent): void;
201
+ /**
202
+ * Event Handler: SelectionChange
203
+ */
204
+ handleSelectionChange(event: KeyboardHandlerEvent): void;
205
+ /**
206
+ * Called by {@link setEventListeners} when an event that warrants a cursor position update is triggered
207
+ */
208
+ caretEventHandler(event: KeyboardHandlerEvent): void;
209
+ /**
210
+ * Execute an operation on each button
211
+ */
212
+ recurseButtons(fn: any): void;
213
+ /**
214
+ * Destroy keyboard listeners and DOM elements
215
+ */
216
+ destroy(): void;
217
+ /**
218
+ * Process buttonTheme option
219
+ */
220
+ getButtonThemeClasses(button: string): string[];
221
+ /**
222
+ * Process buttonAttributes option
223
+ */
224
+ setDOMButtonAttributes(button: string, callback: any): void;
225
+ onTouchDeviceDetected(): void;
226
+ /**
227
+ * Disabling contextual window for hg-button
228
+ */
229
+ disableContextualWindow(): void;
230
+ /**
231
+ * Process autoTouchEvents option
232
+ */
233
+ processAutoTouchEvents(): void;
234
+ /**
235
+ * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).
236
+ */
237
+ onInit(): void;
238
+ /**
239
+ * Executes the callback function before a simple-keyboard render.
240
+ */
241
+ beforeFirstRender(): void;
242
+ /**
243
+ * Executes the callback function before a simple-keyboard render.
244
+ */
245
+ beforeRender(): void;
246
+ /**
247
+ * Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).
248
+ */
249
+ onRender(): void;
250
+ /**
251
+ * Executes the callback function once all modules have been loaded
252
+ */
253
+ onModulesLoaded(): void;
254
+ /**
255
+ * Register module
256
+ */
257
+ registerModule: (name: string, initCallback: any) => void;
258
+ /**
259
+ * Load modules
260
+ */
261
+ loadModules(): void;
262
+ /**
263
+ * Get module prop
264
+ */
265
+ getModuleProp(name: string, prop: string): any;
266
+ /**
267
+ * getModulesList
268
+ */
269
+ getModulesList(): string[];
270
+ /**
271
+ * Parse Row DOM containers
272
+ */
273
+ parseRowDOMContainers(rowDOM: HTMLDivElement, rowIndex: number, containerStartIndexes: number[], containerEndIndexes: number[]): HTMLDivElement;
274
+ /**
275
+ * getKeyboardClassString
276
+ */
277
+ getKeyboardClassString: (...baseDOMClasses: any[]) => string;
278
+ /**
279
+ * Renders rows and buttons as per options
280
+ */
281
+ render(): void;
282
+ }
283
+ export default SimpleKeyboard;
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * simple-keyboard v3.3.27
3
+ * simple-keyboard v3.4.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 "./polyfills";
2
- import SimpleKeyboard from "./components/Keyboard";
3
- export default SimpleKeyboard;
1
+ import "./polyfills";
2
+ import SimpleKeyboard from "./components/Keyboard";
3
+ export default SimpleKeyboard;
package/build/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * simple-keyboard v3.3.27
3
+ * simple-keyboard v3.4.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,2 +1,2 @@
1
- import SimpleKeyboard from "./components/Keyboard";
2
- export default SimpleKeyboard;
1
+ import SimpleKeyboard from "./components/Keyboard";
2
+ export default SimpleKeyboard;
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * simple-keyboard v3.3.27 (index.modern.js - Modern Browsers bundle)
3
+ * simple-keyboard v3.4.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