@etsoo/shared 1.1.4 → 1.1.8

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.
package/README.md CHANGED
@@ -18,6 +18,16 @@ $ yarn add @etsoo/shared
18
18
  ## storage
19
19
  Storage interface and browser storage implementation
20
20
 
21
+ ## Keyboard
22
+ Keyboard keys and codes
23
+
24
+ |Name|Description|
25
+ |---:|---|
26
+ |Keys|KeyboardEvent.key constants|
27
+ |Codes|KeyboardEvent.code constants|
28
+
29
+ |isTypingContent|Is typing content or press command key|
30
+
21
31
  ## DataTypes
22
32
  Data type definitions and type safe functions
23
33
 
@@ -142,6 +152,7 @@ String and other related utilities
142
152
  |Name|Description|
143
153
  |---:|---|
144
154
  |charsToNumber|Base64 chars to number|
155
+ |correctTypes|Correct object's property value type|
145
156
  |equals|Two values equal|
146
157
  |formatInitial|Format inital character to lower case or upper case|
147
158
  |formatString|Format string with parameters|
@@ -0,0 +1,8 @@
1
+ import { Keyboard } from '../src/Keyboard';
2
+
3
+ test('Tests for isTypingContent', () => {
4
+ expect(Keyboard.isTypingContent(Keyboard.Keys.A)).toBeTruthy();
5
+ expect(Keyboard.isTypingContent(Keyboard.Keys.Ampersand)).toBeTruthy();
6
+ expect(Keyboard.isTypingContent(Keyboard.Keys.Shift)).toBeFalsy();
7
+ expect(Keyboard.isTypingContent(Keyboard.Keys.PrintScreen)).toBeFalsy();
8
+ });
@@ -1,5 +1,30 @@
1
1
  import { Utils } from '../src/Utils';
2
2
 
3
+ test('Tests for correctTypes', () => {
4
+ const input = {
5
+ id: '1',
6
+ price: '6.0',
7
+ amount: '',
8
+ date: '2022/01/28',
9
+ enabled: 'true',
10
+ ids: ['1', '2']
11
+ };
12
+ Utils.correctTypes(input, {
13
+ id: 'number',
14
+ price: 'number',
15
+ amount: 'number',
16
+ date: 'date',
17
+ enabled: 'boolean',
18
+ ids: 'number[]'
19
+ });
20
+ expect(typeof input.id).toBe('number');
21
+ expect(typeof input.price).toBe('number');
22
+ expect(input.amount).toBeUndefined();
23
+ expect((input.date as any) instanceof Date ? true : false).toBeTruthy();
24
+ expect(input.enabled).toBeTruthy();
25
+ expect(input.ids).toStrictEqual([1, 2]);
26
+ });
27
+
3
28
  test('Tests for getDataChanges', () => {
4
29
  const input = {
5
30
  id: 1,
@@ -48,7 +48,7 @@ export declare namespace DateUtils {
48
48
  * Format to 'yyyy-MM-dd', especially used for date input min/max property
49
49
  * @param date Input date
50
50
  */
51
- function formatForInput(date?: Date | string): string;
51
+ function formatForInput(date?: Date | string | null): string;
52
52
  /**
53
53
  * Get month's days
54
54
  * @param year Year
@@ -0,0 +1,261 @@
1
+ /**
2
+ * Keyboard functions
3
+ */
4
+ export declare namespace Keyboard {
5
+ /**
6
+ * Keys for KeyboardEvent.key
7
+ */
8
+ enum Keys {
9
+ Backspace = "Backspace",
10
+ Tab = "Tab",
11
+ Enter = "Enter",
12
+ Shift = "Shift",
13
+ Control = "Control",
14
+ Alt = "Alt",
15
+ Pause = "Pause",
16
+ CapsLock = "CapsLock",
17
+ Escape = "Escape",
18
+ Space = "",
19
+ PageUp = "PageUp",
20
+ PageDown = "PageDown",
21
+ End = "End",
22
+ Home = "Home",
23
+ ArrowLeft = "ArrowLeft",
24
+ ArrowUp = "ArrowUp",
25
+ ArrowRight = "ArrowRight",
26
+ ArrowDown = "ArrowDown",
27
+ PrintScreen = "PrintScreen",
28
+ Insert = "Insert",
29
+ Delete = "Delete",
30
+ Digit0 = "0",
31
+ Digit1 = "1",
32
+ Digit2 = "2",
33
+ Digit3 = "3",
34
+ Digit4 = "4",
35
+ Digit5 = "5",
36
+ Digit6 = "6",
37
+ Digit7 = "7",
38
+ Digit8 = "8",
39
+ Digit9 = "9",
40
+ A = "A",
41
+ B = "B",
42
+ C = "C",
43
+ D = "D",
44
+ E = "E",
45
+ F = "F",
46
+ G = "G",
47
+ H = "H",
48
+ I = "I",
49
+ J = "J",
50
+ K = "K",
51
+ L = "L",
52
+ M = "M",
53
+ N = "N",
54
+ O = "O",
55
+ P = "P",
56
+ Q = "Q",
57
+ R = "R",
58
+ S = "S",
59
+ T = "T",
60
+ U = "U",
61
+ V = "V",
62
+ W = "W",
63
+ X = "X",
64
+ Y = "Y",
65
+ Z = "Z",
66
+ a = "a",
67
+ b = "b",
68
+ c = "c",
69
+ d = "d",
70
+ e = "e",
71
+ f = "f",
72
+ g = "g",
73
+ h = "h",
74
+ i = "i",
75
+ j = "j",
76
+ k = "k",
77
+ l = "l",
78
+ m = "m",
79
+ n = "n",
80
+ o = "o",
81
+ p = "p",
82
+ q = "q",
83
+ r = "r",
84
+ s = "s",
85
+ t = "t",
86
+ u = "u",
87
+ v = "v",
88
+ w = "w",
89
+ x = "x",
90
+ y = "y",
91
+ z = "z",
92
+ Meta = "Meta",
93
+ ContextMenu = "ContextMenu",
94
+ AudioVolumeMute = "AudioVolumeMute",
95
+ AudioVolumeDown = "AudioVolumeDown",
96
+ AudioVolumeUp = "AudioVolumeUp",
97
+ F1 = "F1",
98
+ F2 = "F2",
99
+ F3 = "F3",
100
+ F4 = "F4",
101
+ F5 = "F5",
102
+ F6 = "F6",
103
+ F7 = "F7",
104
+ F8 = "F8",
105
+ F9 = "F9",
106
+ F10 = "F10",
107
+ F11 = "F11",
108
+ F12 = "F12",
109
+ NumLock = "NumLock",
110
+ ScrollLock = "ScrollLock",
111
+ Semicolon = ";",
112
+ Equal = "=",
113
+ Comma = ",",
114
+ Minus = "-",
115
+ Period = ".",
116
+ Slash = "/",
117
+ Backquote = "`",
118
+ BracketLeft = "[",
119
+ Backslash = "\\",
120
+ BracketRight = "]",
121
+ Quote = "'",
122
+ Tilde = "~",
123
+ Exclamation = "!",
124
+ At = "@",
125
+ Sharp = "#",
126
+ Dollar = "$",
127
+ Percent = "%",
128
+ Caret = "^",
129
+ Ampersand = "&",
130
+ Asterisk = "*",
131
+ ParenthesisLeft = "(",
132
+ ParenthesisRight = ")",
133
+ Underscore = "_",
134
+ Plus = "+",
135
+ OpenBrace = "{",
136
+ CloseBrace = "}",
137
+ Pipe = "|",
138
+ Colon = ":",
139
+ Quote2 = "\"",
140
+ AngleBracketLeft = "<",
141
+ AngleBracketRight = ">",
142
+ QuestionMark = "?"
143
+ }
144
+ /**
145
+ * Codes for KeyboardEvent.code
146
+ */
147
+ enum Codes {
148
+ Backspace = "Backspace",
149
+ Tab = "Tab",
150
+ Enter = "Enter",
151
+ ShiftLeft = "ShiftLeft",
152
+ ShiftRight = "ShiftRight",
153
+ ControlLeft = "ControlLeft",
154
+ ControlRight = "ControlRight",
155
+ AltLeft = "AltLeft",
156
+ AltRight = "AltRight",
157
+ Pause = "Pause",
158
+ CapsLock = "CapsLock",
159
+ Escape = "Escape",
160
+ Space = "Space",
161
+ PageUp = "PageUp",
162
+ PageDown = "PageDown",
163
+ End = "End",
164
+ Home = "Home",
165
+ ArrowLeft = "ArrowLeft",
166
+ ArrowUp = "ArrowUp",
167
+ ArrowRight = "ArrowRight",
168
+ ArrowDown = "ArrowDown",
169
+ PrintScreen = "PrintScreen",
170
+ Insert = "Insert",
171
+ Delete = "Delete",
172
+ Digit0 = "Digit0",
173
+ Digit1 = "Digit1",
174
+ Digit2 = "Digit2",
175
+ Digit3 = "Digit3",
176
+ Digit4 = "Digit4",
177
+ Digit5 = "Digit5",
178
+ Digit6 = "Digit6",
179
+ Digit7 = "Digit7",
180
+ Digit8 = "Digit8",
181
+ Digit9 = "Digit9",
182
+ AudioVolumeMute = "AudioVolumeMute",
183
+ AudioVolumeDown = "AudioVolumeDown",
184
+ AudioVolumeUp = "AudioVolumeUp",
185
+ KeyA = "KeyA",
186
+ KeyB = "KeyB",
187
+ KeyC = "KeyC",
188
+ KeyD = "KeyD",
189
+ KeyE = "KeyE",
190
+ KeyF = "KeyF",
191
+ KeyG = "KeyG",
192
+ KeyH = "KeyH",
193
+ KeyI = "KeyI",
194
+ KeyJ = "KeyJ",
195
+ KeyK = "KeyK",
196
+ KeyL = "KeyL",
197
+ KeyM = "KeyM",
198
+ KeyN = "KeyN",
199
+ KeyO = "KeyO",
200
+ KeyP = "KeyP",
201
+ KeyQ = "KeyQ",
202
+ KeyR = "KeyR",
203
+ KeyS = "KeyS",
204
+ KeyT = "KeyT",
205
+ KeyU = "KeyU",
206
+ KeyV = "KeyV",
207
+ KeyW = "KeyW",
208
+ KeyX = "KeyX",
209
+ KeyY = "KeyY",
210
+ KeyZ = "KeyZ",
211
+ MetaLeft = "MetaLeft",
212
+ MetaRight = "MetaRight",
213
+ ContextMenu = "ContextMenu",
214
+ Numpad0 = "Numpad0",
215
+ Numpad1 = "Numpad1",
216
+ Numpad2 = "Numpad2",
217
+ Numpad3 = "Numpad3",
218
+ Numpad4 = "Numpad4",
219
+ Numpad5 = "Numpad5",
220
+ Numpad6 = "Numpad6",
221
+ Numpad7 = "Numpad7",
222
+ Numpad8 = "Numpad8",
223
+ Numpad9 = "Numpad9",
224
+ NumpadMultiply = "NumpadMultiply",
225
+ NumpadAdd = "NumpadAdd",
226
+ NumpadSubtract = "NumpadSubtract",
227
+ NumpadDecimal = "NumpadDecimal",
228
+ NumpadDivide = "NumpadDivide",
229
+ F1 = "F1",
230
+ F2 = "F2",
231
+ F3 = "F3",
232
+ F4 = "F4",
233
+ F5 = "F5",
234
+ F6 = "F6",
235
+ F7 = "F7",
236
+ F8 = "F8",
237
+ F9 = "F9",
238
+ F10 = "F10",
239
+ F11 = "F11",
240
+ F12 = "F12",
241
+ NumLock = "NumLock",
242
+ ScrollLock = "ScrollLock",
243
+ Semicolon = "Semicolon",
244
+ Equal = "Equal",
245
+ Comma = "Comma",
246
+ Minus = "Minus",
247
+ Period = "Period",
248
+ Slash = "Slash",
249
+ Backquote = "Backquote",
250
+ BracketLeft = "BracketLeft",
251
+ Backslash = "Backslash",
252
+ BracketRight = "BracketRight",
253
+ Quote = "Quote"
254
+ }
255
+ /**
256
+ * Is typing content or press command key
257
+ * @param input Input key
258
+ * @returns Result
259
+ */
260
+ function isTypingContent(input: Keys | string): boolean;
261
+ }
@@ -0,0 +1,270 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Keyboard = void 0;
4
+ /**
5
+ * Keyboard functions
6
+ */
7
+ var Keyboard;
8
+ (function (Keyboard) {
9
+ /**
10
+ * Keys for KeyboardEvent.key
11
+ */
12
+ let Keys;
13
+ (function (Keys) {
14
+ Keys["Backspace"] = "Backspace";
15
+ Keys["Tab"] = "Tab";
16
+ Keys["Enter"] = "Enter";
17
+ Keys["Shift"] = "Shift";
18
+ Keys["Control"] = "Control";
19
+ Keys["Alt"] = "Alt";
20
+ Keys["Pause"] = "Pause";
21
+ Keys["CapsLock"] = "CapsLock";
22
+ Keys["Escape"] = "Escape";
23
+ Keys["Space"] = "";
24
+ Keys["PageUp"] = "PageUp";
25
+ Keys["PageDown"] = "PageDown";
26
+ Keys["End"] = "End";
27
+ Keys["Home"] = "Home";
28
+ Keys["ArrowLeft"] = "ArrowLeft";
29
+ Keys["ArrowUp"] = "ArrowUp";
30
+ Keys["ArrowRight"] = "ArrowRight";
31
+ Keys["ArrowDown"] = "ArrowDown";
32
+ Keys["PrintScreen"] = "PrintScreen";
33
+ Keys["Insert"] = "Insert";
34
+ Keys["Delete"] = "Delete";
35
+ Keys["Digit0"] = "0";
36
+ Keys["Digit1"] = "1";
37
+ Keys["Digit2"] = "2";
38
+ Keys["Digit3"] = "3";
39
+ Keys["Digit4"] = "4";
40
+ Keys["Digit5"] = "5";
41
+ Keys["Digit6"] = "6";
42
+ Keys["Digit7"] = "7";
43
+ Keys["Digit8"] = "8";
44
+ Keys["Digit9"] = "9";
45
+ Keys["A"] = "A";
46
+ Keys["B"] = "B";
47
+ Keys["C"] = "C";
48
+ Keys["D"] = "D";
49
+ Keys["E"] = "E";
50
+ Keys["F"] = "F";
51
+ Keys["G"] = "G";
52
+ Keys["H"] = "H";
53
+ Keys["I"] = "I";
54
+ Keys["J"] = "J";
55
+ Keys["K"] = "K";
56
+ Keys["L"] = "L";
57
+ Keys["M"] = "M";
58
+ Keys["N"] = "N";
59
+ Keys["O"] = "O";
60
+ Keys["P"] = "P";
61
+ Keys["Q"] = "Q";
62
+ Keys["R"] = "R";
63
+ Keys["S"] = "S";
64
+ Keys["T"] = "T";
65
+ Keys["U"] = "U";
66
+ Keys["V"] = "V";
67
+ Keys["W"] = "W";
68
+ Keys["X"] = "X";
69
+ Keys["Y"] = "Y";
70
+ Keys["Z"] = "Z";
71
+ Keys["a"] = "a";
72
+ Keys["b"] = "b";
73
+ Keys["c"] = "c";
74
+ Keys["d"] = "d";
75
+ Keys["e"] = "e";
76
+ Keys["f"] = "f";
77
+ Keys["g"] = "g";
78
+ Keys["h"] = "h";
79
+ Keys["i"] = "i";
80
+ Keys["j"] = "j";
81
+ Keys["k"] = "k";
82
+ Keys["l"] = "l";
83
+ Keys["m"] = "m";
84
+ Keys["n"] = "n";
85
+ Keys["o"] = "o";
86
+ Keys["p"] = "p";
87
+ Keys["q"] = "q";
88
+ Keys["r"] = "r";
89
+ Keys["s"] = "s";
90
+ Keys["t"] = "t";
91
+ Keys["u"] = "u";
92
+ Keys["v"] = "v";
93
+ Keys["w"] = "w";
94
+ Keys["x"] = "x";
95
+ Keys["y"] = "y";
96
+ Keys["z"] = "z";
97
+ Keys["Meta"] = "Meta";
98
+ Keys["ContextMenu"] = "ContextMenu";
99
+ Keys["AudioVolumeMute"] = "AudioVolumeMute";
100
+ Keys["AudioVolumeDown"] = "AudioVolumeDown";
101
+ Keys["AudioVolumeUp"] = "AudioVolumeUp";
102
+ Keys["F1"] = "F1";
103
+ Keys["F2"] = "F2";
104
+ Keys["F3"] = "F3";
105
+ Keys["F4"] = "F4";
106
+ Keys["F5"] = "F5";
107
+ Keys["F6"] = "F6";
108
+ Keys["F7"] = "F7";
109
+ Keys["F8"] = "F8";
110
+ Keys["F9"] = "F9";
111
+ Keys["F10"] = "F10";
112
+ Keys["F11"] = "F11";
113
+ Keys["F12"] = "F12";
114
+ Keys["NumLock"] = "NumLock";
115
+ Keys["ScrollLock"] = "ScrollLock";
116
+ Keys["Semicolon"] = ";";
117
+ Keys["Equal"] = "=";
118
+ Keys["Comma"] = ",";
119
+ Keys["Minus"] = "-";
120
+ Keys["Period"] = ".";
121
+ Keys["Slash"] = "/";
122
+ Keys["Backquote"] = "`";
123
+ Keys["BracketLeft"] = "[";
124
+ Keys["Backslash"] = "\\";
125
+ Keys["BracketRight"] = "]";
126
+ Keys["Quote"] = "'";
127
+ Keys["Tilde"] = "~";
128
+ Keys["Exclamation"] = "!";
129
+ Keys["At"] = "@";
130
+ Keys["Sharp"] = "#";
131
+ Keys["Dollar"] = "$";
132
+ Keys["Percent"] = "%";
133
+ Keys["Caret"] = "^";
134
+ Keys["Ampersand"] = "&";
135
+ Keys["Asterisk"] = "*";
136
+ Keys["ParenthesisLeft"] = "(";
137
+ Keys["ParenthesisRight"] = ")";
138
+ Keys["Underscore"] = "_";
139
+ Keys["Plus"] = "+";
140
+ Keys["OpenBrace"] = "{";
141
+ Keys["CloseBrace"] = "}";
142
+ Keys["Pipe"] = "|";
143
+ Keys["Colon"] = ":";
144
+ Keys["Quote2"] = "\"";
145
+ Keys["AngleBracketLeft"] = "<";
146
+ Keys["AngleBracketRight"] = ">";
147
+ Keys["QuestionMark"] = "?";
148
+ })(Keys = Keyboard.Keys || (Keyboard.Keys = {}));
149
+ /**
150
+ * Codes for KeyboardEvent.code
151
+ */
152
+ let Codes;
153
+ (function (Codes) {
154
+ Codes["Backspace"] = "Backspace";
155
+ Codes["Tab"] = "Tab";
156
+ Codes["Enter"] = "Enter";
157
+ Codes["ShiftLeft"] = "ShiftLeft";
158
+ Codes["ShiftRight"] = "ShiftRight";
159
+ Codes["ControlLeft"] = "ControlLeft";
160
+ Codes["ControlRight"] = "ControlRight";
161
+ Codes["AltLeft"] = "AltLeft";
162
+ Codes["AltRight"] = "AltRight";
163
+ Codes["Pause"] = "Pause";
164
+ Codes["CapsLock"] = "CapsLock";
165
+ Codes["Escape"] = "Escape";
166
+ Codes["Space"] = "Space";
167
+ Codes["PageUp"] = "PageUp";
168
+ Codes["PageDown"] = "PageDown";
169
+ Codes["End"] = "End";
170
+ Codes["Home"] = "Home";
171
+ Codes["ArrowLeft"] = "ArrowLeft";
172
+ Codes["ArrowUp"] = "ArrowUp";
173
+ Codes["ArrowRight"] = "ArrowRight";
174
+ Codes["ArrowDown"] = "ArrowDown";
175
+ Codes["PrintScreen"] = "PrintScreen";
176
+ Codes["Insert"] = "Insert";
177
+ Codes["Delete"] = "Delete";
178
+ Codes["Digit0"] = "Digit0";
179
+ Codes["Digit1"] = "Digit1";
180
+ Codes["Digit2"] = "Digit2";
181
+ Codes["Digit3"] = "Digit3";
182
+ Codes["Digit4"] = "Digit4";
183
+ Codes["Digit5"] = "Digit5";
184
+ Codes["Digit6"] = "Digit6";
185
+ Codes["Digit7"] = "Digit7";
186
+ Codes["Digit8"] = "Digit8";
187
+ Codes["Digit9"] = "Digit9";
188
+ Codes["AudioVolumeMute"] = "AudioVolumeMute";
189
+ Codes["AudioVolumeDown"] = "AudioVolumeDown";
190
+ Codes["AudioVolumeUp"] = "AudioVolumeUp";
191
+ Codes["KeyA"] = "KeyA";
192
+ Codes["KeyB"] = "KeyB";
193
+ Codes["KeyC"] = "KeyC";
194
+ Codes["KeyD"] = "KeyD";
195
+ Codes["KeyE"] = "KeyE";
196
+ Codes["KeyF"] = "KeyF";
197
+ Codes["KeyG"] = "KeyG";
198
+ Codes["KeyH"] = "KeyH";
199
+ Codes["KeyI"] = "KeyI";
200
+ Codes["KeyJ"] = "KeyJ";
201
+ Codes["KeyK"] = "KeyK";
202
+ Codes["KeyL"] = "KeyL";
203
+ Codes["KeyM"] = "KeyM";
204
+ Codes["KeyN"] = "KeyN";
205
+ Codes["KeyO"] = "KeyO";
206
+ Codes["KeyP"] = "KeyP";
207
+ Codes["KeyQ"] = "KeyQ";
208
+ Codes["KeyR"] = "KeyR";
209
+ Codes["KeyS"] = "KeyS";
210
+ Codes["KeyT"] = "KeyT";
211
+ Codes["KeyU"] = "KeyU";
212
+ Codes["KeyV"] = "KeyV";
213
+ Codes["KeyW"] = "KeyW";
214
+ Codes["KeyX"] = "KeyX";
215
+ Codes["KeyY"] = "KeyY";
216
+ Codes["KeyZ"] = "KeyZ";
217
+ Codes["MetaLeft"] = "MetaLeft";
218
+ Codes["MetaRight"] = "MetaRight";
219
+ Codes["ContextMenu"] = "ContextMenu";
220
+ Codes["Numpad0"] = "Numpad0";
221
+ Codes["Numpad1"] = "Numpad1";
222
+ Codes["Numpad2"] = "Numpad2";
223
+ Codes["Numpad3"] = "Numpad3";
224
+ Codes["Numpad4"] = "Numpad4";
225
+ Codes["Numpad5"] = "Numpad5";
226
+ Codes["Numpad6"] = "Numpad6";
227
+ Codes["Numpad7"] = "Numpad7";
228
+ Codes["Numpad8"] = "Numpad8";
229
+ Codes["Numpad9"] = "Numpad9";
230
+ Codes["NumpadMultiply"] = "NumpadMultiply";
231
+ Codes["NumpadAdd"] = "NumpadAdd";
232
+ Codes["NumpadSubtract"] = "NumpadSubtract";
233
+ Codes["NumpadDecimal"] = "NumpadDecimal";
234
+ Codes["NumpadDivide"] = "NumpadDivide";
235
+ Codes["F1"] = "F1";
236
+ Codes["F2"] = "F2";
237
+ Codes["F3"] = "F3";
238
+ Codes["F4"] = "F4";
239
+ Codes["F5"] = "F5";
240
+ Codes["F6"] = "F6";
241
+ Codes["F7"] = "F7";
242
+ Codes["F8"] = "F8";
243
+ Codes["F9"] = "F9";
244
+ Codes["F10"] = "F10";
245
+ Codes["F11"] = "F11";
246
+ Codes["F12"] = "F12";
247
+ Codes["NumLock"] = "NumLock";
248
+ Codes["ScrollLock"] = "ScrollLock";
249
+ Codes["Semicolon"] = "Semicolon";
250
+ Codes["Equal"] = "Equal";
251
+ Codes["Comma"] = "Comma";
252
+ Codes["Minus"] = "Minus";
253
+ Codes["Period"] = "Period";
254
+ Codes["Slash"] = "Slash";
255
+ Codes["Backquote"] = "Backquote";
256
+ Codes["BracketLeft"] = "BracketLeft";
257
+ Codes["Backslash"] = "Backslash";
258
+ Codes["BracketRight"] = "BracketRight";
259
+ Codes["Quote"] = "Quote";
260
+ })(Codes = Keyboard.Codes || (Keyboard.Codes = {}));
261
+ /**
262
+ * Is typing content or press command key
263
+ * @param input Input key
264
+ * @returns Result
265
+ */
266
+ function isTypingContent(input) {
267
+ return input.length === 1;
268
+ }
269
+ Keyboard.isTypingContent = isTypingContent;
270
+ })(Keyboard = exports.Keyboard || (exports.Keyboard = {}));
@@ -41,6 +41,14 @@ export declare namespace Utils {
41
41
  * @returns Number
42
42
  */
43
43
  function charsToNumber(base64Chars: string): number;
44
+ /**
45
+ * Correct object's property value type
46
+ * @param input Input object
47
+ * @param fields Fields to correct
48
+ */
49
+ function correctTypes<T extends {}, F extends {
50
+ [P in keyof T]: DataTypes.BasicNames;
51
+ }>(input: T, fields: F): void;
44
52
  /**
45
53
  * Two values equal
46
54
  * @param v1 Value 1
package/lib/cjs/Utils.js CHANGED
@@ -43,6 +43,21 @@ var Utils;
43
43
  }, 0);
44
44
  }
45
45
  Utils.charsToNumber = charsToNumber;
46
+ /**
47
+ * Correct object's property value type
48
+ * @param input Input object
49
+ * @param fields Fields to correct
50
+ */
51
+ function correctTypes(input, fields) {
52
+ for (const field in fields) {
53
+ const value = Reflect.get(input, field);
54
+ const newValue = DataTypes_1.DataTypes.convertByType(value, fields[field]);
55
+ if (newValue !== value) {
56
+ Reflect.set(input, field, newValue);
57
+ }
58
+ }
59
+ }
60
+ Utils.correctTypes = correctTypes;
46
61
  /**
47
62
  * Two values equal
48
63
  * @param v1 Value 1
@@ -5,6 +5,7 @@ export * from './DataTypes';
5
5
  export * from './DateUtils';
6
6
  export * from './DomUtils';
7
7
  export * from './ExtendUtils';
8
+ export * from './Keyboard';
8
9
  export * from './NumberUtils';
9
10
  export * from './StorageUtils';
10
11
  export * from './Utils';
package/lib/cjs/index.js CHANGED
@@ -17,6 +17,7 @@ __exportStar(require("./DataTypes"), exports);
17
17
  __exportStar(require("./DateUtils"), exports);
18
18
  __exportStar(require("./DomUtils"), exports);
19
19
  __exportStar(require("./ExtendUtils"), exports);
20
+ __exportStar(require("./Keyboard"), exports);
20
21
  __exportStar(require("./NumberUtils"), exports);
21
22
  __exportStar(require("./StorageUtils"), exports);
22
23
  __exportStar(require("./Utils"), exports);
@@ -48,7 +48,7 @@ export declare namespace DateUtils {
48
48
  * Format to 'yyyy-MM-dd', especially used for date input min/max property
49
49
  * @param date Input date
50
50
  */
51
- function formatForInput(date?: Date | string): string;
51
+ function formatForInput(date?: Date | string | null): string;
52
52
  /**
53
53
  * Get month's days
54
54
  * @param year Year