form-payload 1.0.3 → 1.2.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.
- package/package.json +5 -1
- package/readme.md +1 -1
- package/src/libs/enums/control-type.enum.d.ts +1 -1
- package/src/libs/enums/control-type.enum.js +1 -1
- package/src/packages/get-form-control-payload/get-form-control-payload.d.ts +3 -2
- package/src/packages/get-form-control-payload/get-form-control-payload.d.ts.map +1 -1
- package/src/packages/get-form-control-payload/get-form-control-payload.js +37 -21
- package/src/packages/get-form-control-payload/helpers/get-datatime-local-value/get-datatime-local-value.helper.d.ts +6 -0
- package/src/packages/get-form-control-payload/helpers/get-datatime-local-value/get-datatime-local-value.helper.d.ts.map +1 -0
- package/src/packages/get-form-control-payload/helpers/get-datatime-local-value/get-datatime-local-value.helper.js +9 -0
- package/src/packages/get-form-control-payload/helpers/helpers.d.ts +1 -0
- package/src/packages/get-form-control-payload/helpers/helpers.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "form-payload",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Gets form-payload via form.elements",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"form",
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"type": "git",
|
|
18
18
|
"url": "git+https://github.com/what1s1ove/form-payload.git"
|
|
19
19
|
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/what1s1ove/form-payload/issues",
|
|
22
|
+
"email": "hello@whatislove.dev"
|
|
23
|
+
},
|
|
20
24
|
"license": "MIT",
|
|
21
25
|
"type": "module",
|
|
22
26
|
"main": "./src/index.js",
|
package/readme.md
CHANGED
|
@@ -72,7 +72,6 @@ PS. _The library works perfectly with any framework. Just use a valid [HTMLFormE
|
|
|
72
72
|
| [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="url"` | ✅ | `string` |
|
|
73
73
|
| [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="tel"` | ✅ | `string` |
|
|
74
74
|
| [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="color"` | ✅ | `string` |
|
|
75
|
-
| [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="datetime-local"` | ✅ | `string` |
|
|
76
75
|
| [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="radio"` | ✅ | `string` |
|
|
77
76
|
| [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="hidden"` | ✅ | `string` |
|
|
78
77
|
| [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="number"` | ✅ | `number` |
|
|
@@ -82,6 +81,7 @@ PS. _The library works perfectly with any framework. Just use a valid [HTMLFormE
|
|
|
82
81
|
| [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="time"` | ✅ | [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) |
|
|
83
82
|
| [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="month"` | ✅ | [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) |
|
|
84
83
|
| [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="week"` | ✅ | [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) |
|
|
84
|
+
| [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="datetime-local"` | ✅ | [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) |
|
|
85
85
|
| [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="file"` | ✅ | [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) or `null` |
|
|
86
86
|
| [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="file"` and `multiple` | ✅ | <code>Array<[File](https://developer.mozilla.org/en-US/docs/Web/API/File)></code> |
|
|
87
87
|
| [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="button"` | ❌ | – |
|
|
@@ -6,7 +6,6 @@ export namespace ControlType {
|
|
|
6
6
|
let URL: "url";
|
|
7
7
|
let TEL: "tel";
|
|
8
8
|
let COLOR: "color";
|
|
9
|
-
let DATETIME_LOCAL: "datetime-local";
|
|
10
9
|
let RADIO: "radio";
|
|
11
10
|
let HIDDEN: "hidden";
|
|
12
11
|
let NUMBER: "number";
|
|
@@ -16,6 +15,7 @@ export namespace ControlType {
|
|
|
16
15
|
let TIME: "time";
|
|
17
16
|
let MONTH: "month";
|
|
18
17
|
let WEEK: "week";
|
|
18
|
+
let DATETIME_LOCAL: "datetime-local";
|
|
19
19
|
let FILE: "file";
|
|
20
20
|
let BUTTON: "button";
|
|
21
21
|
let SUBMIT: "submit";
|
|
@@ -6,7 +6,6 @@ const ControlType = /** @type {const} */ ({
|
|
|
6
6
|
URL: 'url',
|
|
7
7
|
TEL: 'tel',
|
|
8
8
|
COLOR: 'color',
|
|
9
|
-
DATETIME_LOCAL: 'datetime-local',
|
|
10
9
|
RADIO: 'radio',
|
|
11
10
|
HIDDEN: 'hidden',
|
|
12
11
|
|
|
@@ -19,6 +18,7 @@ const ControlType = /** @type {const} */ ({
|
|
|
19
18
|
TIME: 'time',
|
|
20
19
|
MONTH: 'month',
|
|
21
20
|
WEEK: 'week',
|
|
21
|
+
DATETIME_LOCAL: 'datetime-local',
|
|
22
22
|
|
|
23
23
|
FILE: 'file',
|
|
24
24
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export type HTMLFormControlElement = import('../../libs/types/types.js').HTMLFormControlElement;
|
|
2
2
|
export type HTMLFormOperationalControlElement = import('../../libs/types/types.js').HTMLFormOperationalControlElement;
|
|
3
3
|
/**
|
|
4
|
+
* @template {unknown} T
|
|
4
5
|
* @param {HTMLFormOperationalControlElement} controlNode
|
|
5
|
-
* @returns {
|
|
6
|
+
* @returns {T}
|
|
6
7
|
* @throws {FormPayloadError}
|
|
7
8
|
*/
|
|
8
|
-
export function getFormControlPayload(controlNode: HTMLFormOperationalControlElement):
|
|
9
|
+
export function getFormControlPayload<T extends unknown>(controlNode: HTMLFormOperationalControlElement): T;
|
|
9
10
|
/** @typedef {import('../../libs/types/types.js').HTMLFormControlElement} HTMLFormControlElement */
|
|
10
11
|
/** @typedef {import('../../libs/types/types.js').HTMLFormOperationalControlElement} HTMLFormOperationalControlElement */
|
|
11
12
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-form-control-payload.d.ts","sourceRoot":"","sources":["../../../../src/packages/get-form-control-payload/get-form-control-payload.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-form-control-payload.d.ts","sourceRoot":"","sources":["../../../../src/packages/get-form-control-payload/get-form-control-payload.js"],"names":[],"mappings":"qCAcc,OAAO,2BAA2B,EAAE,sBAAsB;gDAC1D,OAAO,2BAA2B,EAAE,iCAAiC;AA+BnF;;;;;GAKG;AACH,sEAJW,iCAAiC,KAqF3C;AAvHD,mGAAmG;AACnG,yHAAyH;AAEzH;;;;GAIG;AACH,8FAHc,sBAAsB,OAyBnC"}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
checkIsReferToAnotherNode,
|
|
5
5
|
getAllowedElements,
|
|
6
6
|
getCheckboxValue,
|
|
7
|
+
getDatetimeLocalValue,
|
|
7
8
|
getFormControlValue,
|
|
8
9
|
getInputDateValue,
|
|
9
10
|
getInputFileValue,
|
|
@@ -44,8 +45,9 @@ const getFormControlsPayload = (...controlElements) => {
|
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
/**
|
|
48
|
+
* @template {unknown} T
|
|
47
49
|
* @param {HTMLFormOperationalControlElement} controlNode
|
|
48
|
-
* @returns {
|
|
50
|
+
* @returns {T}
|
|
49
51
|
* @throws {FormPayloadError}
|
|
50
52
|
*/
|
|
51
53
|
const getFormControlPayload = (controlNode) => {
|
|
@@ -57,48 +59,60 @@ const getFormControlPayload = (controlNode) => {
|
|
|
57
59
|
case ControlType.URL:
|
|
58
60
|
case ControlType.TEL:
|
|
59
61
|
case ControlType.COLOR:
|
|
60
|
-
case ControlType.DATETIME_LOCAL:
|
|
61
62
|
case ControlType.RADIO:
|
|
62
63
|
case ControlType.HIDDEN:
|
|
63
64
|
case ControlType.TEXTAREA:
|
|
64
65
|
case ControlType.SELECT_ONE:
|
|
65
66
|
case ControlType.OUTPUT: {
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
return /** @type {T} */ (
|
|
68
|
+
getFormControlValue(
|
|
69
|
+
/**
|
|
70
|
+
* @type {HTMLInputElement
|
|
71
|
+
* | HTMLOutputElement
|
|
72
|
+
* | HTMLTextAreaElement
|
|
73
|
+
* | HTMLSelectElement}
|
|
74
|
+
*/ (controlNode),
|
|
75
|
+
)
|
|
73
76
|
);
|
|
74
77
|
}
|
|
75
78
|
case ControlType.NUMBER:
|
|
76
79
|
case ControlType.RANGE: {
|
|
77
|
-
return
|
|
78
|
-
|
|
80
|
+
return /** @type {T} */ (
|
|
81
|
+
getInputNumericValue(
|
|
82
|
+
/** @type {HTMLInputElement} */ (controlNode),
|
|
83
|
+
)
|
|
79
84
|
);
|
|
80
85
|
}
|
|
81
86
|
case ControlType.CHECKBOX: {
|
|
82
|
-
return
|
|
83
|
-
/** @type {HTMLInputElement} */ (controlNode)
|
|
87
|
+
return /** @type {T} */ (
|
|
88
|
+
getCheckboxValue(/** @type {HTMLInputElement} */ (controlNode))
|
|
84
89
|
);
|
|
85
90
|
}
|
|
86
91
|
case ControlType.DATE:
|
|
87
92
|
case ControlType.TIME:
|
|
88
93
|
case ControlType.MONTH:
|
|
89
94
|
case ControlType.WEEK: {
|
|
90
|
-
return
|
|
91
|
-
/** @type {HTMLInputElement} */ (controlNode)
|
|
95
|
+
return /** @type {T} */ (
|
|
96
|
+
getInputDateValue(/** @type {HTMLInputElement} */ (controlNode))
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
case ControlType.DATETIME_LOCAL: {
|
|
100
|
+
return /** @type {T} */ (
|
|
101
|
+
getDatetimeLocalValue(
|
|
102
|
+
/** @type {HTMLInputElement} */ (controlNode),
|
|
103
|
+
)
|
|
92
104
|
);
|
|
93
105
|
}
|
|
94
106
|
case ControlType.FILE: {
|
|
95
|
-
return
|
|
96
|
-
/** @type {HTMLInputElement} */ (controlNode)
|
|
107
|
+
return /** @type {T} */ (
|
|
108
|
+
getInputFileValue(/** @type {HTMLInputElement} */ (controlNode))
|
|
97
109
|
);
|
|
98
110
|
}
|
|
99
111
|
case ControlType.SELECT_MULTIPLE: {
|
|
100
|
-
return
|
|
101
|
-
|
|
112
|
+
return /** @type {T} */ (
|
|
113
|
+
getMultiSelectValues(
|
|
114
|
+
/** @type {HTMLSelectElement} */ (controlNode),
|
|
115
|
+
)
|
|
102
116
|
);
|
|
103
117
|
}
|
|
104
118
|
case ControlType.FIELDSET: {
|
|
@@ -106,8 +120,10 @@ const getFormControlPayload = (controlNode) => {
|
|
|
106
120
|
.../** @type {HTMLFieldSetElement} */ (controlNode).elements,
|
|
107
121
|
];
|
|
108
122
|
|
|
109
|
-
return
|
|
110
|
-
|
|
123
|
+
return /** @type {T} */ (
|
|
124
|
+
getFormControlsPayload(
|
|
125
|
+
.../** @type {HTMLFormControlElement[]} */ (elements),
|
|
126
|
+
)
|
|
111
127
|
);
|
|
112
128
|
}
|
|
113
129
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-datatime-local-value.helper.d.ts","sourceRoot":"","sources":["../../../../../../src/packages/get-form-control-payload/helpers/get-datatime-local-value/get-datatime-local-value.helper.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,+CAHW,gBAAgB,GACd,IAAI,CAIhB"}
|
|
@@ -2,6 +2,7 @@ export { checkIsReferToAnotherNode } from "./check-is-refer-to-another-node/chec
|
|
|
2
2
|
export { getAllowedElements } from "./get-allowed-elements/get-allowed-elements.helper.js";
|
|
3
3
|
export { getCheckboxValue } from "./get-checkbox-value/get-checkbox-value.helper.js";
|
|
4
4
|
export { getFormControlValue } from "./get-control-value/get-control-value.helper.js";
|
|
5
|
+
export { getDatetimeLocalValue } from "./get-datatime-local-value/get-datatime-local-value.helper.js";
|
|
5
6
|
export { getInputDateValue } from "./get-input-date-value/get-input-date-value.helper.js";
|
|
6
7
|
export { getInputFileValue } from "./get-input-file-value/get-input-file-value.helper.js";
|
|
7
8
|
export { getInputNumericValue } from "./get-input-numeric-value/get-input-numeric-value.helper.js";
|
|
@@ -2,6 +2,7 @@ export { checkIsReferToAnotherNode } from './check-is-refer-to-another-node/chec
|
|
|
2
2
|
export { getAllowedElements } from './get-allowed-elements/get-allowed-elements.helper.js';
|
|
3
3
|
export { getCheckboxValue } from './get-checkbox-value/get-checkbox-value.helper.js';
|
|
4
4
|
export { getFormControlValue } from './get-control-value/get-control-value.helper.js';
|
|
5
|
+
export { getDatetimeLocalValue } from './get-datatime-local-value/get-datatime-local-value.helper.js';
|
|
5
6
|
export { getInputDateValue } from './get-input-date-value/get-input-date-value.helper.js';
|
|
6
7
|
export { getInputFileValue } from './get-input-file-value/get-input-file-value.helper.js';
|
|
7
8
|
export { getInputNumericValue } from './get-input-numeric-value/get-input-numeric-value.helper.js';
|