@etsoo/shared 1.1.71 → 1.1.72
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 +1 -0
- package/lib/cjs/DomUtils.d.ts +6 -0
- package/lib/cjs/DomUtils.js +18 -0
- package/lib/mjs/DomUtils.d.ts +6 -0
- package/lib/mjs/DomUtils.js +18 -0
- package/package.json +3 -3
- package/src/DomUtils.ts +16 -0
package/README.md
CHANGED
|
@@ -169,6 +169,7 @@ DOM/window related utilities
|
|
|
169
169
|
|formDataToObject|Form data to object|
|
|
170
170
|
|getCulture|Get the available culture definition|
|
|
171
171
|
|getDataChanges|Get data changed fields with input data updated|
|
|
172
|
+
|getInputValue|Get input value depending on its type|
|
|
172
173
|
|getLocationKey|Get an unique key combined with current URL|
|
|
173
174
|
|headersToObject|Convert headers to object|
|
|
174
175
|
|isFormData|Is IFormData type guard|
|
package/lib/cjs/DomUtils.d.ts
CHANGED
|
@@ -82,6 +82,12 @@ export declare namespace DomUtils {
|
|
|
82
82
|
*/
|
|
83
83
|
compatibleName?: string[] | undefined;
|
|
84
84
|
}> | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Get input value depending on its type
|
|
87
|
+
* @param input HTML input
|
|
88
|
+
* @returns Result
|
|
89
|
+
*/
|
|
90
|
+
function getInputValue(input: HTMLInputElement): string | number | Date | null;
|
|
85
91
|
/**
|
|
86
92
|
* Get an unique key combined with current URL
|
|
87
93
|
* @param key Key
|
package/lib/cjs/DomUtils.js
CHANGED
|
@@ -293,6 +293,24 @@ var DomUtils;
|
|
|
293
293
|
// Default
|
|
294
294
|
return items[0];
|
|
295
295
|
};
|
|
296
|
+
/**
|
|
297
|
+
* Get input value depending on its type
|
|
298
|
+
* @param input HTML input
|
|
299
|
+
* @returns Result
|
|
300
|
+
*/
|
|
301
|
+
function getInputValue(input) {
|
|
302
|
+
const type = input.type;
|
|
303
|
+
if (type === 'number' || type === 'range') {
|
|
304
|
+
const num = input.valueAsNumber;
|
|
305
|
+
if (isNaN(num))
|
|
306
|
+
return null;
|
|
307
|
+
return num;
|
|
308
|
+
}
|
|
309
|
+
else if (type === 'date' || type === 'datetime-local')
|
|
310
|
+
return input.valueAsDate;
|
|
311
|
+
return input.value;
|
|
312
|
+
}
|
|
313
|
+
DomUtils.getInputValue = getInputValue;
|
|
296
314
|
/**
|
|
297
315
|
* Get an unique key combined with current URL
|
|
298
316
|
* @param key Key
|
package/lib/mjs/DomUtils.d.ts
CHANGED
|
@@ -82,6 +82,12 @@ export declare namespace DomUtils {
|
|
|
82
82
|
*/
|
|
83
83
|
compatibleName?: string[] | undefined;
|
|
84
84
|
}> | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Get input value depending on its type
|
|
87
|
+
* @param input HTML input
|
|
88
|
+
* @returns Result
|
|
89
|
+
*/
|
|
90
|
+
function getInputValue(input: HTMLInputElement): string | number | Date | null;
|
|
85
91
|
/**
|
|
86
92
|
* Get an unique key combined with current URL
|
|
87
93
|
* @param key Key
|
package/lib/mjs/DomUtils.js
CHANGED
|
@@ -290,6 +290,24 @@ export var DomUtils;
|
|
|
290
290
|
// Default
|
|
291
291
|
return items[0];
|
|
292
292
|
};
|
|
293
|
+
/**
|
|
294
|
+
* Get input value depending on its type
|
|
295
|
+
* @param input HTML input
|
|
296
|
+
* @returns Result
|
|
297
|
+
*/
|
|
298
|
+
function getInputValue(input) {
|
|
299
|
+
const type = input.type;
|
|
300
|
+
if (type === 'number' || type === 'range') {
|
|
301
|
+
const num = input.valueAsNumber;
|
|
302
|
+
if (isNaN(num))
|
|
303
|
+
return null;
|
|
304
|
+
return num;
|
|
305
|
+
}
|
|
306
|
+
else if (type === 'date' || type === 'datetime-local')
|
|
307
|
+
return input.valueAsDate;
|
|
308
|
+
return input.value;
|
|
309
|
+
}
|
|
310
|
+
DomUtils.getInputValue = getInputValue;
|
|
293
311
|
/**
|
|
294
312
|
* Get an unique key combined with current URL
|
|
295
313
|
* @param key Key
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/shared",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.72",
|
|
4
4
|
"description": "TypeScript shared utilities and functions",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
},
|
|
55
55
|
"homepage": "https://github.com/ETSOO/Shared#readme",
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@types/jest": "^29.2.
|
|
57
|
+
"@types/jest": "^29.2.2",
|
|
58
58
|
"@typescript-eslint/eslint-plugin": "^5.42.0",
|
|
59
59
|
"@typescript-eslint/parser": "^5.42.0",
|
|
60
|
-
"eslint": "^8.
|
|
60
|
+
"eslint": "^8.27.0",
|
|
61
61
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
62
62
|
"eslint-plugin-import": "^2.26.0",
|
|
63
63
|
"jest": "^29.2.2",
|
package/src/DomUtils.ts
CHANGED
|
@@ -341,6 +341,22 @@ export namespace DomUtils {
|
|
|
341
341
|
return items[0];
|
|
342
342
|
};
|
|
343
343
|
|
|
344
|
+
/**
|
|
345
|
+
* Get input value depending on its type
|
|
346
|
+
* @param input HTML input
|
|
347
|
+
* @returns Result
|
|
348
|
+
*/
|
|
349
|
+
export function getInputValue(input: HTMLInputElement) {
|
|
350
|
+
const type = input.type;
|
|
351
|
+
if (type === 'number' || type === 'range') {
|
|
352
|
+
const num = input.valueAsNumber;
|
|
353
|
+
if (isNaN(num)) return null;
|
|
354
|
+
return num;
|
|
355
|
+
} else if (type === 'date' || type === 'datetime-local')
|
|
356
|
+
return input.valueAsDate;
|
|
357
|
+
return input.value;
|
|
358
|
+
}
|
|
359
|
+
|
|
344
360
|
/**
|
|
345
361
|
* Get an unique key combined with current URL
|
|
346
362
|
* @param key Key
|