form-payload 1.3.0 → 1.5.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.
Files changed (37) hide show
  1. package/package.json +1 -1
  2. package/readme.md +34 -32
  3. package/src/libs/constants/constants.d.ts +2 -0
  4. package/src/libs/constants/constants.js +2 -0
  5. package/src/libs/constants/value-as-array-custom-control-types.constant.d.ts +2 -0
  6. package/src/libs/constants/value-as-array-custom-control-types.constant.d.ts.map +1 -0
  7. package/src/libs/constants/value-as-array-custom-control-types.constant.js +5 -0
  8. package/src/libs/constants/value-as-array-identifier.constant.d.ts +2 -0
  9. package/src/libs/constants/value-as-array-identifier.constant.d.ts.map +1 -0
  10. package/src/libs/constants/value-as-array-identifier.constant.js +3 -0
  11. package/src/libs/enums/control-type.enum.d.ts +1 -1
  12. package/src/libs/enums/control-type.enum.js +3 -1
  13. package/src/libs/maps/{element-name-to-element-instance.map.d.ts → banned-element-name-to-element-instance.map.d.ts} +1 -1
  14. package/src/libs/maps/banned-element-name-to-element-instance.map.d.ts.map +1 -0
  15. package/src/libs/maps/maps.d.ts +1 -1
  16. package/src/libs/maps/maps.js +1 -1
  17. package/src/packages/get-form-control-payload/get-form-control-payload.d.ts.map +1 -1
  18. package/src/packages/get-form-control-payload/get-form-control-payload.js +26 -7
  19. package/src/packages/get-form-control-payload/helpers/check-has-value-as-array/check-has-value-as-array.helper.d.ts +8 -0
  20. package/src/packages/get-form-control-payload/helpers/check-has-value-as-array/check-has-value-as-array.helper.d.ts.map +1 -0
  21. package/src/packages/get-form-control-payload/helpers/check-has-value-as-array/check-has-value-as-array.helper.js +21 -0
  22. package/src/packages/get-form-control-payload/helpers/check-is-refer-to-another-node/check-is-refer-to-another-node.helper.d.ts +2 -2
  23. package/src/packages/get-form-control-payload/helpers/check-is-refer-to-another-node/check-is-refer-to-another-node.helper.d.ts.map +1 -1
  24. package/src/packages/get-form-control-payload/helpers/check-is-refer-to-another-node/check-is-refer-to-another-node.helper.js +2 -2
  25. package/src/packages/get-form-control-payload/helpers/get-checkbox-value/get-checkbox-value.helper.d.ts +2 -2
  26. package/src/packages/get-form-control-payload/helpers/get-checkbox-value/get-checkbox-value.helper.d.ts.map +1 -1
  27. package/src/packages/get-form-control-payload/helpers/get-checkbox-value/get-checkbox-value.helper.js +9 -1
  28. package/src/packages/get-form-control-payload/helpers/get-cleaned-value-as-array-control-name/get-cleaned-value-as-array-control-name.helper.d.ts +8 -0
  29. package/src/packages/get-form-control-payload/helpers/get-cleaned-value-as-array-control-name/get-cleaned-value-as-array-control-name.helper.d.ts.map +1 -0
  30. package/src/packages/get-form-control-payload/helpers/get-cleaned-value-as-array-control-name/get-cleaned-value-as-array-control-name.helper.js +13 -0
  31. package/src/packages/get-form-control-payload/helpers/get-input-email-value/get-input-email-value.helper.d.ts +6 -0
  32. package/src/packages/get-form-control-payload/helpers/get-input-email-value/get-input-email-value.helper.d.ts.map +1 -0
  33. package/src/packages/get-form-control-payload/helpers/get-input-email-value/get-input-email-value.helper.js +20 -0
  34. package/src/packages/get-form-control-payload/helpers/helpers.d.ts +3 -0
  35. package/src/packages/get-form-control-payload/helpers/helpers.js +3 -0
  36. package/src/libs/maps/element-name-to-element-instance.map.d.ts.map +0 -1
  37. /package/src/libs/maps/{element-name-to-element-instance.map.js → banned-element-name-to-element-instance.map.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "form-payload",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "Gets form-payload via form.elements",
5
5
  "keywords": [
6
6
  "form",
package/readme.md CHANGED
@@ -63,35 +63,37 @@ PS. _The library works perfectly with any framework. Just use a valid [HTMLFormE
63
63
 
64
64
  ## Value Correspondence Table
65
65
 
66
- | HTMLElement | Attributes | Included | Value |
67
- | ------------------------------------------------------------------------------------------- | ---------------------------- | -------- | ----------------------------------------------------------------------------------------------- |
68
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="text"` | ✅ | `string` |
69
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="password"` | ✅ | `string` |
70
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="email"` | ✅ | `string` |
71
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="search"` | ✅ | `string` |
72
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="url"` | ✅ | `string` |
73
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="tel"` | ✅ | `string` |
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="radio"` | ✅ | `string` |
76
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="hidden"` | ✅ | `string` |
77
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="number"` | ✅ | `number` |
78
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="range"` | ✅ | `number` |
79
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="checkbox"` | ✅ | `boolean` |
80
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="date"` | ✅ | [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) |
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) |
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) |
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
- | [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
- | [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
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="button"` | | |
88
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="submit"` | | |
89
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="reset"` | ❌ | – |
90
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="image"` | ❌ | – |
91
- | [HTMLTextAreaElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextareaElement) | | | `string` |
92
- | [HTMLSelectElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement) | | | `string` |
93
- | [HTMLSelectElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement) | `multiple` | ✅ | `Array<string>` |
94
- | [HTMLOutputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement) | – | ✅ | `string` |
95
- | [HTMLFieldsetElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFieldsetElement) | | ✅ | `Object<name: string, value: unknown>` (recursive values of nested elements) |
96
- | [HTMLButtonElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement) | – | | |
97
- | [HTMLObjectElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement) | – | | |
66
+ | HTMLElement | Attributes | Included | Return Value |
67
+ | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | -------- | ----------------------------------------------------------------------------------------------- |
68
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="text"` | ✅ | `string` |
69
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="password"` | ✅ | `string` |
70
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="search"` | ✅ | `string` |
71
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="url"` | ✅ | `string` |
72
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="tel"` | ✅ | `string` |
73
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="color"` | ✅ | `string` |
74
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="radio"` | ✅ | `string` |
75
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="hidden"` | ✅ | `string` |
76
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="email"` | ✅ | `string` |
77
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="email"` and `multiple` | ✅ | `Array<string>` |
78
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="number"` | ✅ | `number` |
79
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="range"` | ✅ | `number` |
80
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="checkbox"` | ✅ | `boolean` |
81
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="checkbox"` and `[]` in `name` (Ex. `name="fruits[]"`) | ✅ | `Array<string>` |
82
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="date"` | ✅ | [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) |
83
+ | [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) |
84
+ | [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) |
85
+ | [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) |
86
+ | [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) |
87
+ | [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` |
88
+ | [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> |
89
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="button"` | ❌ | – |
90
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="submit"` | ❌ | – |
91
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="reset"` | | |
92
+ | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="image"` | | |
93
+ | [HTMLTextAreaElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextareaElement) | | ✅ | `string` |
94
+ | [HTMLSelectElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement) | – | ✅ | `string` |
95
+ | [HTMLSelectElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement) | `multiple` | ✅ | `Array<string>` |
96
+ | [HTMLOutputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement) | – | | `string` |
97
+ | [HTMLFieldsetElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFieldsetElement) | – | | `Object<name: string, value: unknown>` (recursive values of nested elements) |
98
+ | [HTMLButtonElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement) | – | ❌ | – |
99
+ | [HTMLObjectElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement) | – | ❌ | – |
@@ -1,2 +1,4 @@
1
1
  export { BANNED_CONTROL_TYPES } from "./banned-control-types.constant.js";
2
+ export { VALUE_AS_ARRAY_CUSTOM_CONTROL_TYPES } from "./value-as-array-custom-control-types.constant.js";
3
+ export { VALUE_AS_ARRAY_IDENTIFIER } from "./value-as-array-identifier.constant.js";
2
4
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1,3 @@
1
1
  export { BANNED_CONTROL_TYPES } from './banned-control-types.constant.js';
2
+ export { VALUE_AS_ARRAY_CUSTOM_CONTROL_TYPES } from './value-as-array-custom-control-types.constant.js';
3
+ export { VALUE_AS_ARRAY_IDENTIFIER } from './value-as-array-identifier.constant.js';
@@ -0,0 +1,2 @@
1
+ export const VALUE_AS_ARRAY_CUSTOM_CONTROL_TYPES: "checkbox"[];
2
+ //# sourceMappingURL=value-as-array-custom-control-types.constant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value-as-array-custom-control-types.constant.d.ts","sourceRoot":"","sources":["../../../../src/libs/constants/value-as-array-custom-control-types.constant.js"],"names":[],"mappings":"AAEA,+DAAmE"}
@@ -0,0 +1,5 @@
1
+ import { ControlType } from '../enums/enums.js';
2
+
3
+ const VALUE_AS_ARRAY_CUSTOM_CONTROL_TYPES = [ControlType.CHECKBOX];
4
+
5
+ export { VALUE_AS_ARRAY_CUSTOM_CONTROL_TYPES };
@@ -0,0 +1,2 @@
1
+ export const VALUE_AS_ARRAY_IDENTIFIER: "[]";
2
+ //# sourceMappingURL=value-as-array-identifier.constant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value-as-array-identifier.constant.d.ts","sourceRoot":"","sources":["../../../../src/libs/constants/value-as-array-identifier.constant.js"],"names":[],"mappings":"AAAA,6CAAuC"}
@@ -0,0 +1,3 @@
1
+ const VALUE_AS_ARRAY_IDENTIFIER = '[]';
2
+
3
+ export { VALUE_AS_ARRAY_IDENTIFIER };
@@ -1,13 +1,13 @@
1
1
  export namespace ControlType {
2
2
  let TEXT: "text";
3
3
  let PASSWORD: "password";
4
- let EMAIL: "email";
5
4
  let SEARCH: "search";
6
5
  let URL: "url";
7
6
  let TEL: "tel";
8
7
  let COLOR: "color";
9
8
  let RADIO: "radio";
10
9
  let HIDDEN: "hidden";
10
+ let EMAIL: "email";
11
11
  let NUMBER: "number";
12
12
  let RANGE: "range";
13
13
  let CHECKBOX: "checkbox";
@@ -1,7 +1,6 @@
1
1
  const ControlType = /** @type {const} */ ({
2
2
  TEXT: 'text',
3
3
  PASSWORD: 'password',
4
- EMAIL: 'email',
5
4
  SEARCH: 'search',
6
5
  URL: 'url',
7
6
  TEL: 'tel',
@@ -9,6 +8,8 @@ const ControlType = /** @type {const} */ ({
9
8
  RADIO: 'radio',
10
9
  HIDDEN: 'hidden',
11
10
 
11
+ EMAIL: 'email',
12
+
12
13
  NUMBER: 'number',
13
14
  RANGE: 'range',
14
15
 
@@ -18,6 +19,7 @@ const ControlType = /** @type {const} */ ({
18
19
  TIME: 'time',
19
20
  MONTH: 'month',
20
21
  WEEK: 'week',
22
+
21
23
  DATETIME_LOCAL: 'datetime-local',
22
24
 
23
25
  FILE: 'file',
@@ -8,4 +8,4 @@ export namespace bannedElementNameToElementInstance {
8
8
  prototype: HTMLObjectElement;
9
9
  };
10
10
  }
11
- //# sourceMappingURL=element-name-to-element-instance.map.d.ts.map
11
+ //# sourceMappingURL=banned-element-name-to-element-instance.map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"banned-element-name-to-element-instance.map.d.ts","sourceRoot":"","sources":["../../../../src/libs/maps/banned-element-name-to-element-instance.map.js"],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- export { bannedElementNameToElementInstance } from "./element-name-to-element-instance.map.js";
1
+ export { bannedElementNameToElementInstance } from "./banned-element-name-to-element-instance.map.js";
2
2
  //# sourceMappingURL=maps.d.ts.map
@@ -1 +1 @@
1
- export { bannedElementNameToElementInstance } from './element-name-to-element-instance.map.js';
1
+ export { bannedElementNameToElementInstance } from './banned-element-name-to-element-instance.map.js';
@@ -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":"qCAcc,OAAO,2BAA2B,EAAE,sBAAsB;gDAC1D,OAAO,2BAA2B,EAAE,iCAAiC;AA+BnF;;;;;GAKG;AACH,sEAJW,iCAAiC,KA6F3C;AA/HD,mGAAmG;AACnG,yHAAyH;AAEzH;;;;GAIG;AACH,8FAHc,sBAAsB,OAyBnC"}
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":"qCAiBc,OAAO,2BAA2B,EAAE,sBAAsB;gDAC1D,OAAO,2BAA2B,EAAE,iCAAiC;AAyCnF;;;;;GAKG;AACH,sEAJW,iCAAiC,KAmG3C;AA/ID,mGAAmG;AACnG,yHAAyH;AAEzH;;;;GAIG;AACH,8FAHc,sBAAsB,OAmCnC"}
@@ -1,12 +1,15 @@
1
1
  import { ControlType } from '../../libs/enums/enums.js';
2
2
  import { FormPayloadError } from '../../libs/exceptions/exceptions.js';
3
3
  import {
4
+ checkHasValueAsArray,
4
5
  checkIsReferToAnotherNode,
5
6
  getAllowedElements,
6
7
  getCheckboxValue,
8
+ getCleanedValueAsArrayControlName,
7
9
  getDatetimeLocalValue,
8
10
  getFormControlValue,
9
11
  getInputDateValue,
12
+ getInputEmailValue,
10
13
  getInputFileValue,
11
14
  getInputNumericValue,
12
15
  getMultiSelectValues,
@@ -23,22 +26,32 @@ import {
23
26
  const getFormControlsPayload = (...controlElements) => {
24
27
  const allowedElements = getAllowedElements(controlElements);
25
28
 
26
- let elementsValues = /** @type {T} */ ({});
29
+ const elementsValues = /** @type {T} */ ({});
27
30
 
28
31
  for (const element of allowedElements) {
29
32
  const isReferToAnotherNode = checkIsReferToAnotherNode(
30
33
  element,
31
- ...allowedElements,
34
+ allowedElements,
32
35
  );
33
36
 
34
37
  if (isReferToAnotherNode) {
35
38
  continue;
36
39
  }
37
40
 
38
- elementsValues = {
39
- ...elementsValues,
40
- [element.name]: getFormControlPayload(element),
41
- };
41
+ let key = /** @type {keyof T} */ (element.name);
42
+ let value = /** @type {T[keyof T]} */ (getFormControlPayload(element));
43
+ const hasValueAsArray = checkHasValueAsArray(element);
44
+
45
+ if (hasValueAsArray) {
46
+ key = getCleanedValueAsArrayControlName(element);
47
+
48
+ value = /** @type {T[keyof T]} */ ([
49
+ .../** @type {unknown[]} */ (elementsValues[key] ?? []),
50
+ .../** @type {unknown[]} */ (getFormControlPayload(element)),
51
+ ]);
52
+ }
53
+
54
+ elementsValues[key] = value;
42
55
  }
43
56
 
44
57
  return elementsValues;
@@ -62,7 +75,6 @@ const getFormControlPayload = (controlNode) => {
62
75
  switch (controlNode.type) {
63
76
  case ControlType.TEXT:
64
77
  case ControlType.PASSWORD:
65
- case ControlType.EMAIL:
66
78
  case ControlType.SEARCH:
67
79
  case ControlType.URL:
68
80
  case ControlType.TEL:
@@ -83,6 +95,13 @@ const getFormControlPayload = (controlNode) => {
83
95
  )
84
96
  );
85
97
  }
98
+ case ControlType.EMAIL: {
99
+ return /** @type {T} */ (
100
+ getInputEmailValue(
101
+ /** @type {HTMLInputElement} */ (controlNode),
102
+ )
103
+ );
104
+ }
86
105
  case ControlType.NUMBER:
87
106
  case ControlType.RANGE: {
88
107
  return /** @type {T} */ (
@@ -0,0 +1,8 @@
1
+ export type HTMLFormOperationalControlElement = import('../../../../libs/types/types.js').HTMLFormOperationalControlElement;
2
+ /** @typedef {import('../../../../libs/types/types.js').HTMLFormOperationalControlElement} HTMLFormOperationalControlElement */
3
+ /**
4
+ * @param {HTMLFormOperationalControlElement} element
5
+ * @returns {boolean}
6
+ */
7
+ export function checkHasValueAsArray(element: HTMLFormOperationalControlElement): boolean;
8
+ //# sourceMappingURL=check-has-value-as-array.helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-has-value-as-array.helper.d.ts","sourceRoot":"","sources":["../../../../../../src/packages/get-form-control-payload/helpers/check-has-value-as-array/check-has-value-as-array.helper.js"],"names":[],"mappings":"gDAKc,OAAO,iCAAiC,EAAE,iCAAiC;AAAzF,+HAA+H;AAE/H;;;GAGG;AACH,8CAHW,iCAAiC,GAC/B,OAAO,CASnB"}
@@ -0,0 +1,21 @@
1
+ import {
2
+ VALUE_AS_ARRAY_CUSTOM_CONTROL_TYPES,
3
+ VALUE_AS_ARRAY_IDENTIFIER,
4
+ } from '../../../../libs/constants/constants.js';
5
+
6
+ /** @typedef {import('../../../../libs/types/types.js').HTMLFormOperationalControlElement} HTMLFormOperationalControlElement */
7
+
8
+ /**
9
+ * @param {HTMLFormOperationalControlElement} element
10
+ * @returns {boolean}
11
+ */
12
+ const checkHasValueAsArray = (element) => {
13
+ return (
14
+ element.name.endsWith(VALUE_AS_ARRAY_IDENTIFIER) &&
15
+ /** @type {readonly string[]} */ (
16
+ VALUE_AS_ARRAY_CUSTOM_CONTROL_TYPES
17
+ ).includes(element.type)
18
+ );
19
+ };
20
+
21
+ export { checkHasValueAsArray };
@@ -3,8 +3,8 @@ export type HTMLFormOperationalControlElement = import('../../../../libs/types/t
3
3
  /**
4
4
  * @template {HTMLFormOperationalControlElement} T
5
5
  * @param {T} currentNode
6
- * @param {...T} checkNodes
6
+ * @param {T[]} checkNodes
7
7
  * @returns {boolean}
8
8
  */
9
- export function checkIsReferToAnotherNode<T extends import("../../../../libs/types/html-form-operational-control-element.type.js").HTMLFormOperationalControlElement>(currentNode: T, ...checkNodes: T[]): boolean;
9
+ export function checkIsReferToAnotherNode<T extends import("../../../../libs/types/html-form-operational-control-element.type.js").HTMLFormOperationalControlElement>(currentNode: T, checkNodes: T[]): boolean;
10
10
  //# sourceMappingURL=check-is-refer-to-another-node.helper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"check-is-refer-to-another-node.helper.d.ts","sourceRoot":"","sources":["../../../../../../src/packages/get-form-control-payload/helpers/check-is-refer-to-another-node/check-is-refer-to-another-node.helper.js"],"names":[],"mappings":"gDAAc,OAAO,iCAAiC,EAAE,iCAAiC;AAAzF,+HAA+H;AAE/H;;;;;GAKG;AACH,2MAFa,OAAO,CAenB"}
1
+ {"version":3,"file":"check-is-refer-to-another-node.helper.d.ts","sourceRoot":"","sources":["../../../../../../src/packages/get-form-control-payload/helpers/check-is-refer-to-another-node/check-is-refer-to-another-node.helper.js"],"names":[],"mappings":"gDAAc,OAAO,iCAAiC,EAAE,iCAAiC;AAAzF,+HAA+H;AAE/H;;;;;GAKG;AACH,wMAFa,OAAO,CAenB"}
@@ -3,10 +3,10 @@
3
3
  /**
4
4
  * @template {HTMLFormOperationalControlElement} T
5
5
  * @param {T} currentNode
6
- * @param {...T} checkNodes
6
+ * @param {T[]} checkNodes
7
7
  * @returns {boolean}
8
8
  */
9
- const checkIsReferToAnotherNode = (currentNode, ...checkNodes) => {
9
+ const checkIsReferToAnotherNode = (currentNode, checkNodes) => {
10
10
  return checkNodes.some((checkNode) => {
11
11
  const hasElements =
12
12
  'elements' in checkNode && checkNode.elements.length > 0;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @param {HTMLInputElement} element
3
- * @returns {boolean}
3
+ * @returns {boolean | string[]}
4
4
  */
5
- export function getCheckboxValue(element: HTMLInputElement): boolean;
5
+ export function getCheckboxValue(element: HTMLInputElement): boolean | string[];
6
6
  //# sourceMappingURL=get-checkbox-value.helper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-checkbox-value.helper.d.ts","sourceRoot":"","sources":["../../../../../../src/packages/get-form-control-payload/helpers/get-checkbox-value/get-checkbox-value.helper.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,0CAHW,gBAAgB,GACd,OAAO,CAInB"}
1
+ {"version":3,"file":"get-checkbox-value.helper.d.ts","sourceRoot":"","sources":["../../../../../../src/packages/get-form-control-payload/helpers/get-checkbox-value/get-checkbox-value.helper.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH,0CAHW,gBAAgB,GACd,OAAO,GAAG,MAAM,EAAE,CAU9B"}
@@ -1,8 +1,16 @@
1
+ import { VALUE_AS_ARRAY_IDENTIFIER } from '../../../../libs/constants/constants.js';
2
+
1
3
  /**
2
4
  * @param {HTMLInputElement} element
3
- * @returns {boolean}
5
+ * @returns {boolean | string[]}
4
6
  */
5
7
  const getCheckboxValue = (element) => {
8
+ const hasArrayValue = element.name.endsWith(VALUE_AS_ARRAY_IDENTIFIER);
9
+
10
+ if (hasArrayValue) {
11
+ return element.checked ? [element.value] : [];
12
+ }
13
+
6
14
  return element.checked;
7
15
  };
8
16
 
@@ -0,0 +1,8 @@
1
+ export type HTMLFormOperationalControlElement = import('../../../../libs/types/types.js').HTMLFormOperationalControlElement;
2
+ /** @typedef {import('../../../../libs/types/types.js').HTMLFormOperationalControlElement} HTMLFormOperationalControlElement */
3
+ /**
4
+ * @param {HTMLFormOperationalControlElement} element
5
+ * @returns {string}
6
+ */
7
+ export function getCleanedValueAsArrayControlName(element: HTMLFormOperationalControlElement): string;
8
+ //# sourceMappingURL=get-cleaned-value-as-array-control-name.helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-cleaned-value-as-array-control-name.helper.d.ts","sourceRoot":"","sources":["../../../../../../src/packages/get-form-control-payload/helpers/get-cleaned-value-as-array-control-name/get-cleaned-value-as-array-control-name.helper.js"],"names":[],"mappings":"gDAEc,OAAO,iCAAiC,EAAE,iCAAiC;AAAzF,+HAA+H;AAE/H;;;GAGG;AACH,2DAHW,iCAAiC,GAC/B,MAAM,CAIlB"}
@@ -0,0 +1,13 @@
1
+ import { VALUE_AS_ARRAY_IDENTIFIER } from '../../../../libs/constants/constants.js';
2
+
3
+ /** @typedef {import('../../../../libs/types/types.js').HTMLFormOperationalControlElement} HTMLFormOperationalControlElement */
4
+
5
+ /**
6
+ * @param {HTMLFormOperationalControlElement} element
7
+ * @returns {string}
8
+ */
9
+ const getCleanedValueAsArrayControlName = (element) => {
10
+ return element.name.replace(VALUE_AS_ARRAY_IDENTIFIER, '');
11
+ };
12
+
13
+ export { getCleanedValueAsArrayControlName };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @param {HTMLInputElement} inputNode
3
+ * @returns {string | string[]}
4
+ */
5
+ export function getInputEmailValue(inputNode: HTMLInputElement): string | string[];
6
+ //# sourceMappingURL=get-input-email-value.helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-input-email-value.helper.d.ts","sourceRoot":"","sources":["../../../../../../src/packages/get-form-control-payload/helpers/get-input-email-value/get-input-email-value.helper.js"],"names":[],"mappings":"AAIA;;;GAGG;AACH,8CAHW,gBAAgB,GACd,MAAM,GAAG,MAAM,EAAE,CAW7B"}
@@ -0,0 +1,20 @@
1
+ import { getFormControlValue } from '../get-control-value/get-control-value.helper.js';
2
+
3
+ const EMAIL_SEPARATOR = ',';
4
+
5
+ /**
6
+ * @param {HTMLInputElement} inputNode
7
+ * @returns {string | string[]}
8
+ */
9
+ const getInputEmailValue = (inputNode) => {
10
+ if (inputNode.multiple) {
11
+ return inputNode.value
12
+ .split(EMAIL_SEPARATOR)
13
+ .map((email) => email.trim())
14
+ .filter((email) => email !== '');
15
+ }
16
+
17
+ return getFormControlValue(inputNode);
18
+ };
19
+
20
+ export { getInputEmailValue };
@@ -1,9 +1,12 @@
1
+ export { checkHasValueAsArray } from "./check-has-value-as-array/check-has-value-as-array.helper.js";
1
2
  export { checkIsReferToAnotherNode } from "./check-is-refer-to-another-node/check-is-refer-to-another-node.helper.js";
2
3
  export { getAllowedElements } from "./get-allowed-elements/get-allowed-elements.helper.js";
3
4
  export { getCheckboxValue } from "./get-checkbox-value/get-checkbox-value.helper.js";
5
+ export { getCleanedValueAsArrayControlName } from "./get-cleaned-value-as-array-control-name/get-cleaned-value-as-array-control-name.helper.js";
4
6
  export { getFormControlValue } from "./get-control-value/get-control-value.helper.js";
5
7
  export { getDatetimeLocalValue } from "./get-datatime-local-value/get-datatime-local-value.helper.js";
6
8
  export { getInputDateValue } from "./get-input-date-value/get-input-date-value.helper.js";
9
+ export { getInputEmailValue } from "./get-input-email-value/get-input-email-value.helper.js";
7
10
  export { getInputFileValue } from "./get-input-file-value/get-input-file-value.helper.js";
8
11
  export { getInputNumericValue } from "./get-input-numeric-value/get-input-numeric-value.helper.js";
9
12
  export { getMultiSelectValues } from "./get-multi-select-values/get-multi-select-values.helper.js";
@@ -1,9 +1,12 @@
1
+ export { checkHasValueAsArray } from './check-has-value-as-array/check-has-value-as-array.helper.js';
1
2
  export { checkIsReferToAnotherNode } from './check-is-refer-to-another-node/check-is-refer-to-another-node.helper.js';
2
3
  export { getAllowedElements } from './get-allowed-elements/get-allowed-elements.helper.js';
3
4
  export { getCheckboxValue } from './get-checkbox-value/get-checkbox-value.helper.js';
5
+ export { getCleanedValueAsArrayControlName } from './get-cleaned-value-as-array-control-name/get-cleaned-value-as-array-control-name.helper.js';
4
6
  export { getFormControlValue } from './get-control-value/get-control-value.helper.js';
5
7
  export { getDatetimeLocalValue } from './get-datatime-local-value/get-datatime-local-value.helper.js';
6
8
  export { getInputDateValue } from './get-input-date-value/get-input-date-value.helper.js';
9
+ export { getInputEmailValue } from './get-input-email-value/get-input-email-value.helper.js';
7
10
  export { getInputFileValue } from './get-input-file-value/get-input-file-value.helper.js';
8
11
  export { getInputNumericValue } from './get-input-numeric-value/get-input-numeric-value.helper.js';
9
12
  export { getMultiSelectValues } from './get-multi-select-values/get-multi-select-values.helper.js';
@@ -1 +0,0 @@
1
- {"version":3,"file":"element-name-to-element-instance.map.d.ts","sourceRoot":"","sources":["../../../../src/libs/maps/element-name-to-element-instance.map.js"],"names":[],"mappings":""}