simple-keyboard 3.5.64 → 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,244 +1,244 @@
1
- import SimpleKeyboard from "./components/Keyboard";
2
- import Utilities from "./services/Utilities";
3
- export interface KeyboardLayoutObject {
4
- [key: string]: string[];
5
- }
6
- export type KeyboardButtonTheme = {
7
- class: string;
8
- buttons: string;
9
- } | null;
10
- export interface KeyboardButtonAttributes {
11
- attribute: string;
12
- value: string;
13
- buttons: string;
14
- }
15
- export interface KeyboardInput {
16
- [key: string]: string;
17
- }
18
- export type CandidateBoxParams = {
19
- utilities: Utilities;
20
- options: KeyboardOptions;
21
- };
22
- export type CandidateBoxShowParams = {
23
- candidateValue: string;
24
- targetElement: KeyboardElement;
25
- onSelect: (selectedCandidate: string, e: MouseEvent) => void;
26
- };
27
- export type CandidateBoxRenderParams = {
28
- candidateListPages: string[][];
29
- targetElement: KeyboardElement;
30
- pageIndex: number;
31
- nbPages: number;
32
- onItemSelected: (selectedCandidate: string, e: MouseEvent) => void;
33
- };
34
- export type KeyboardElement = HTMLDivElement | HTMLButtonElement;
35
- export type KeyboardHandlerEvent = any;
36
- export interface KeyboardButtonElements {
37
- [key: string]: KeyboardElement[];
38
- }
39
- export interface UtilitiesParams {
40
- getOptions: () => KeyboardOptions;
41
- getCaretPosition: () => number | null;
42
- getCaretPositionEnd: () => number | null;
43
- dispatch: any;
44
- }
45
- export interface PhysicalKeyboardParams {
46
- getOptions: () => KeyboardOptions;
47
- dispatch: any;
48
- }
49
- export interface KeyboardOptions {
50
- /**
51
- * Modify the keyboard layout.
52
- */
53
- layout?: KeyboardLayoutObject;
54
- /**
55
- * Specifies which layout should be used.
56
- */
57
- layoutName?: string;
58
- /**
59
- * Replaces variable buttons (such as `{bksp}`) with a human-friendly name (e.g.: `backspace`).
60
- */
61
- display?: {
62
- [button: string]: string;
63
- };
64
- /**
65
- * By default, when you set the display property, you replace the default one. This setting merges them instead.
66
- */
67
- mergeDisplay?: boolean;
68
- /**
69
- * A prop to add your own css classes to the keyboard wrapper. You can add multiple classes separated by a space.
70
- */
71
- theme?: string;
72
- /**
73
- * A prop to add your own css classes to one or several buttons.
74
- */
75
- buttonTheme?: KeyboardButtonTheme[];
76
- /**
77
- * A prop to add your own attributes to one or several buttons.
78
- */
79
- buttonAttributes?: KeyboardButtonAttributes[];
80
- /**
81
- * Runs a `console.log` every time a key is pressed. Displays the buttons pressed and the current input.
82
- */
83
- debug?: boolean;
84
- /**
85
- * Specifies whether clicking the "ENTER" button will input a newline (`\n`) or not.
86
- */
87
- newLineOnEnter?: boolean;
88
- /**
89
- * Specifies whether clicking the "TAB" button will input a tab character (`\t`) or not.
90
- */
91
- tabCharOnTab?: boolean;
92
- /**
93
- * Allows you to use a single simple-keyboard instance for several inputs.
94
- */
95
- inputName?: string;
96
- /**
97
- * `number`: Restrains all of simple-keyboard inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.
98
- *
99
- * `{ [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.
100
- */
101
- maxLength?: any;
102
- /**
103
- * When set to true, this option synchronizes the internal input of every simple-keyboard instance.
104
- */
105
- syncInstanceInputs?: boolean;
106
- /**
107
- * Enable highlighting of keys pressed on physical keyboard.
108
- */
109
- physicalKeyboardHighlight?: boolean;
110
- /**
111
- * Calls handler for a button highlighted by physicalKeyboardHighlight
112
- * In other words, this calls keyboard.handleButtonClicked(buttonName) on the highlighted button
113
- */
114
- physicalKeyboardHighlightPress?: boolean;
115
- /**
116
- * Trigger click on a button's element when using physicalKeyboardHighlightPress
117
- * In other words, this calls button.click() on the highlighted button
118
- */
119
- physicalKeyboardHighlightPressUseClick?: boolean;
120
- /**
121
- * Whether physicalKeyboardHighlightPress should use pointer events to trigger buttons.
122
- */
123
- physicalKeyboardHighlightPressUsePointerEvents?: boolean;
124
- /**
125
- * Define the text color that the physical keyboard highlighted key should have.
126
- */
127
- physicalKeyboardHighlightTextColor?: string;
128
- /**
129
- * Define the background color that the physical keyboard highlighted key should have.
130
- */
131
- physicalKeyboardHighlightBgColor?: string;
132
- /**
133
- * Whether physicalKeyboardHighlight should use preventDefault to disable default browser actions.
134
- */
135
- physicalKeyboardHighlightPreventDefault?: boolean;
136
- /**
137
- * Calling preventDefault for the mousedown events keeps the focus on the input.
138
- */
139
- preventMouseDownDefault?: boolean;
140
- /**
141
- * Calling preventDefault for the mouseup events.
142
- */
143
- preventMouseUpDefault?: boolean;
144
- /**
145
- * Stops pointer down events on simple-keyboard buttons from bubbling to parent elements.
146
- */
147
- stopMouseDownPropagation?: boolean;
148
- /**
149
- * Stops pointer up events on simple-keyboard buttons from bubbling to parent elements.
150
- */
151
- stopMouseUpPropagation?: boolean;
152
- /**
153
- * Render buttons as a button element instead of a div element.
154
- */
155
- useButtonTag?: boolean;
156
- /**
157
- * A prop to ensure characters are always be added/removed at the end of the string.
158
- */
159
- disableCaretPositioning?: boolean;
160
- /**
161
- * Restrains input(s) change to the defined regular expression pattern.
162
- */
163
- inputPattern?: any;
164
- /**
165
- * Instructs simple-keyboard to use touch events instead of click events.
166
- */
167
- useTouchEvents?: boolean;
168
- /**
169
- * Enable useTouchEvents automatically when touch device is detected.
170
- */
171
- autoUseTouchEvents?: boolean;
172
- /**
173
- * Opt out of PointerEvents handling, falling back to the prior mouse event logic.
174
- */
175
- useMouseEvents?: boolean;
176
- /**
177
- * Disable button hold action.
178
- */
179
- disableButtonHold?: boolean;
180
- /**
181
- * Adds unicode right-to-left control characters to input return values.
182
- */
183
- rtl?: boolean;
184
- /**
185
- * Enable input method editor candidate list support.
186
- */
187
- enableLayoutCandidates?: boolean;
188
- /**
189
- * Character suggestions to be shown on certain key presses
190
- */
191
- layoutCandidates?: {
192
- [key: string]: string;
193
- };
194
- /**
195
- * Exclude buttons from layout
196
- */
197
- excludeFromLayout?: {
198
- [key: string]: string[];
199
- };
200
- /**
201
- * Determines size of layout candidate list
202
- */
203
- layoutCandidatesPageSize?: number;
204
- /**
205
- * Determines whether layout candidate match should be case sensitive.
206
- */
207
- layoutCandidatesCaseSensitiveMatch?: boolean;
208
- /**
209
- * Disables the automatic normalization for selected layout candidates
210
- */
211
- disableCandidateNormalization?: boolean;
212
- /**
213
- * Enables onKeyPress triggering for layoutCandidate items
214
- */
215
- enableLayoutCandidatesKeyPress?: boolean;
216
- /**
217
- * Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).
218
- */
219
- onRender?: (instance?: SimpleKeyboard) => void;
220
- /**
221
- * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).
222
- */
223
- onInit?: (instance?: SimpleKeyboard) => void;
224
- /**
225
- * Retrieves the current input
226
- */
227
- onChange?: (input: string, e?: MouseEvent) => any;
228
- /**
229
- * Retrieves all inputs
230
- */
231
- onChangeAll?: (inputObj: KeyboardInput, e?: MouseEvent) => any;
232
- /**
233
- * Retrieves the pressed key
234
- */
235
- onKeyPress?: (button: string, e?: MouseEvent) => any;
236
- /**
237
- * Retrieves the released key
238
- */
239
- onKeyReleased?: (button: string, e?: MouseEvent) => any;
240
- /**
241
- * Module options can have any format
242
- */
243
- [name: string]: any;
244
- }
1
+ import SimpleKeyboard from "./components/Keyboard";
2
+ import Utilities from "./services/Utilities";
3
+ export interface KeyboardLayoutObject {
4
+ [key: string]: string[];
5
+ }
6
+ export type KeyboardButtonTheme = {
7
+ class: string;
8
+ buttons: string;
9
+ } | null;
10
+ export interface KeyboardButtonAttributes {
11
+ attribute: string;
12
+ value: string;
13
+ buttons: string;
14
+ }
15
+ export interface KeyboardInput {
16
+ [key: string]: string;
17
+ }
18
+ export type CandidateBoxParams = {
19
+ utilities: Utilities;
20
+ options: KeyboardOptions;
21
+ };
22
+ export type CandidateBoxShowParams = {
23
+ candidateValue: string;
24
+ targetElement: KeyboardElement;
25
+ onSelect: (selectedCandidate: string, e: MouseEvent) => void;
26
+ };
27
+ export type CandidateBoxRenderParams = {
28
+ candidateListPages: string[][];
29
+ targetElement: KeyboardElement;
30
+ pageIndex: number;
31
+ nbPages: number;
32
+ onItemSelected: (selectedCandidate: string, e: MouseEvent) => void;
33
+ };
34
+ export type KeyboardElement = HTMLDivElement | HTMLButtonElement;
35
+ export type KeyboardHandlerEvent = any;
36
+ export interface KeyboardButtonElements {
37
+ [key: string]: KeyboardElement[];
38
+ }
39
+ export interface UtilitiesParams {
40
+ getOptions: () => KeyboardOptions;
41
+ getCaretPosition: () => number | null;
42
+ getCaretPositionEnd: () => number | null;
43
+ dispatch: any;
44
+ }
45
+ export interface PhysicalKeyboardParams {
46
+ getOptions: () => KeyboardOptions;
47
+ dispatch: any;
48
+ }
49
+ export interface KeyboardOptions {
50
+ /**
51
+ * Modify the keyboard layout.
52
+ */
53
+ layout?: KeyboardLayoutObject;
54
+ /**
55
+ * Specifies which layout should be used.
56
+ */
57
+ layoutName?: string;
58
+ /**
59
+ * Replaces variable buttons (such as `{bksp}`) with a human-friendly name (e.g.: `backspace`).
60
+ */
61
+ display?: {
62
+ [button: string]: string;
63
+ };
64
+ /**
65
+ * By default, when you set the display property, you replace the default one. This setting merges them instead.
66
+ */
67
+ mergeDisplay?: boolean;
68
+ /**
69
+ * A prop to add your own css classes to the keyboard wrapper. You can add multiple classes separated by a space.
70
+ */
71
+ theme?: string;
72
+ /**
73
+ * A prop to add your own css classes to one or several buttons.
74
+ */
75
+ buttonTheme?: KeyboardButtonTheme[];
76
+ /**
77
+ * A prop to add your own attributes to one or several buttons.
78
+ */
79
+ buttonAttributes?: KeyboardButtonAttributes[];
80
+ /**
81
+ * Runs a `console.log` every time a key is pressed. Displays the buttons pressed and the current input.
82
+ */
83
+ debug?: boolean;
84
+ /**
85
+ * Specifies whether clicking the "ENTER" button will input a newline (`\n`) or not.
86
+ */
87
+ newLineOnEnter?: boolean;
88
+ /**
89
+ * Specifies whether clicking the "TAB" button will input a tab character (`\t`) or not.
90
+ */
91
+ tabCharOnTab?: boolean;
92
+ /**
93
+ * Allows you to use a single simple-keyboard instance for several inputs.
94
+ */
95
+ inputName?: string;
96
+ /**
97
+ * `number`: Restrains all of simple-keyboard inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.
98
+ *
99
+ * `{ [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.
100
+ */
101
+ maxLength?: any;
102
+ /**
103
+ * When set to true, this option synchronizes the internal input of every simple-keyboard instance.
104
+ */
105
+ syncInstanceInputs?: boolean;
106
+ /**
107
+ * Enable highlighting of keys pressed on physical keyboard.
108
+ */
109
+ physicalKeyboardHighlight?: boolean;
110
+ /**
111
+ * Calls handler for a button highlighted by physicalKeyboardHighlight
112
+ * In other words, this calls keyboard.handleButtonClicked(buttonName) on the highlighted button
113
+ */
114
+ physicalKeyboardHighlightPress?: boolean;
115
+ /**
116
+ * Trigger click on a button's element when using physicalKeyboardHighlightPress
117
+ * In other words, this calls button.click() on the highlighted button
118
+ */
119
+ physicalKeyboardHighlightPressUseClick?: boolean;
120
+ /**
121
+ * Whether physicalKeyboardHighlightPress should use pointer events to trigger buttons.
122
+ */
123
+ physicalKeyboardHighlightPressUsePointerEvents?: boolean;
124
+ /**
125
+ * Define the text color that the physical keyboard highlighted key should have.
126
+ */
127
+ physicalKeyboardHighlightTextColor?: string;
128
+ /**
129
+ * Define the background color that the physical keyboard highlighted key should have.
130
+ */
131
+ physicalKeyboardHighlightBgColor?: string;
132
+ /**
133
+ * Whether physicalKeyboardHighlight should use preventDefault to disable default browser actions.
134
+ */
135
+ physicalKeyboardHighlightPreventDefault?: boolean;
136
+ /**
137
+ * Calling preventDefault for the mousedown events keeps the focus on the input.
138
+ */
139
+ preventMouseDownDefault?: boolean;
140
+ /**
141
+ * Calling preventDefault for the mouseup events.
142
+ */
143
+ preventMouseUpDefault?: boolean;
144
+ /**
145
+ * Stops pointer down events on simple-keyboard buttons from bubbling to parent elements.
146
+ */
147
+ stopMouseDownPropagation?: boolean;
148
+ /**
149
+ * Stops pointer up events on simple-keyboard buttons from bubbling to parent elements.
150
+ */
151
+ stopMouseUpPropagation?: boolean;
152
+ /**
153
+ * Render buttons as a button element instead of a div element.
154
+ */
155
+ useButtonTag?: boolean;
156
+ /**
157
+ * A prop to ensure characters are always be added/removed at the end of the string.
158
+ */
159
+ disableCaretPositioning?: boolean;
160
+ /**
161
+ * Restrains input(s) change to the defined regular expression pattern.
162
+ */
163
+ inputPattern?: any;
164
+ /**
165
+ * Instructs simple-keyboard to use touch events instead of click events.
166
+ */
167
+ useTouchEvents?: boolean;
168
+ /**
169
+ * Enable useTouchEvents automatically when touch device is detected.
170
+ */
171
+ autoUseTouchEvents?: boolean;
172
+ /**
173
+ * Opt out of PointerEvents handling, falling back to the prior mouse event logic.
174
+ */
175
+ useMouseEvents?: boolean;
176
+ /**
177
+ * Disable button hold action.
178
+ */
179
+ disableButtonHold?: boolean;
180
+ /**
181
+ * Adds unicode right-to-left control characters to input return values.
182
+ */
183
+ rtl?: boolean;
184
+ /**
185
+ * Enable input method editor candidate list support.
186
+ */
187
+ enableLayoutCandidates?: boolean;
188
+ /**
189
+ * Character suggestions to be shown on certain key presses
190
+ */
191
+ layoutCandidates?: {
192
+ [key: string]: string;
193
+ };
194
+ /**
195
+ * Exclude buttons from layout
196
+ */
197
+ excludeFromLayout?: {
198
+ [key: string]: string[];
199
+ };
200
+ /**
201
+ * Determines size of layout candidate list
202
+ */
203
+ layoutCandidatesPageSize?: number;
204
+ /**
205
+ * Determines whether layout candidate match should be case sensitive.
206
+ */
207
+ layoutCandidatesCaseSensitiveMatch?: boolean;
208
+ /**
209
+ * Disables the automatic normalization for selected layout candidates
210
+ */
211
+ disableCandidateNormalization?: boolean;
212
+ /**
213
+ * Enables onKeyPress triggering for layoutCandidate items
214
+ */
215
+ enableLayoutCandidatesKeyPress?: boolean;
216
+ /**
217
+ * Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).
218
+ */
219
+ onRender?: (instance?: SimpleKeyboard) => void;
220
+ /**
221
+ * Executes the callback function once simple-keyboard is rendered for the first time (on initialization).
222
+ */
223
+ onInit?: (instance?: SimpleKeyboard) => void;
224
+ /**
225
+ * Retrieves the current input
226
+ */
227
+ onChange?: (input: string, e?: MouseEvent) => any;
228
+ /**
229
+ * Retrieves all inputs
230
+ */
231
+ onChangeAll?: (inputObj: KeyboardInput, e?: MouseEvent) => any;
232
+ /**
233
+ * Retrieves the pressed key
234
+ */
235
+ onKeyPress?: (button: string, e?: MouseEvent) => any;
236
+ /**
237
+ * Retrieves the released key
238
+ */
239
+ onKeyReleased?: (button: string, e?: MouseEvent) => any;
240
+ /**
241
+ * Module options can have any format
242
+ */
243
+ [name: string]: any;
244
+ }
@@ -1,4 +1,4 @@
1
- export declare const getDefaultLayout: () => {
2
- default: string[];
3
- shift: string[];
4
- };
1
+ export declare const getDefaultLayout: () => {
2
+ default: string[];
3
+ shift: string[];
4
+ };
@@ -1,25 +1,25 @@
1
- import { KeyboardOptions, PhysicalKeyboardParams } from "../interfaces";
2
- /**
3
- * Physical Keyboard Service
4
- */
5
- declare class PhysicalKeyboard {
6
- getOptions: () => KeyboardOptions;
7
- dispatch: any;
8
- /**
9
- * Creates an instance of the PhysicalKeyboard service
10
- */
11
- constructor({ dispatch, getOptions }: PhysicalKeyboardParams);
12
- handleHighlightKeyDown(e: KeyboardEvent): void;
13
- handleHighlightKeyUp(e: KeyboardEvent): void;
14
- /**
15
- * Transforms a KeyboardEvent's "key.code" string into a simple-keyboard layout format
16
- * @param {object} e The KeyboardEvent
17
- */
18
- getSimpleKeyboardLayoutKey(e: KeyboardEvent): string;
19
- /**
20
- * Retrieve key from keyCode
21
- */
22
- keyCodeToKey(keyCode: number): string;
23
- isMofifierKey: (e: KeyboardEvent) => boolean;
24
- }
25
- export default PhysicalKeyboard;
1
+ import { KeyboardOptions, PhysicalKeyboardParams } from "../interfaces";
2
+ /**
3
+ * Physical Keyboard Service
4
+ */
5
+ declare class PhysicalKeyboard {
6
+ getOptions: () => KeyboardOptions;
7
+ dispatch: any;
8
+ /**
9
+ * Creates an instance of the PhysicalKeyboard service
10
+ */
11
+ constructor({ dispatch, getOptions }: PhysicalKeyboardParams);
12
+ handleHighlightKeyDown(e: KeyboardEvent): void;
13
+ handleHighlightKeyUp(e: KeyboardEvent): void;
14
+ /**
15
+ * Transforms a KeyboardEvent's "key.code" string into a simple-keyboard layout format
16
+ * @param {object} e The KeyboardEvent
17
+ */
18
+ getSimpleKeyboardLayoutKey(e: KeyboardEvent): string;
19
+ /**
20
+ * Retrieve key from keyCode
21
+ */
22
+ keyCodeToKey(keyCode: number): string;
23
+ isMofifierKey: (e: KeyboardEvent) => boolean;
24
+ }
25
+ export default PhysicalKeyboard;