form-payload 1.4.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 (32) hide show
  1. package/package.json +1 -1
  2. package/readme.md +34 -33
  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/maps/{element-name-to-element-instance.map.d.ts → banned-element-name-to-element-instance.map.d.ts} +1 -1
  12. package/src/libs/maps/banned-element-name-to-element-instance.map.d.ts.map +1 -0
  13. package/src/libs/maps/maps.d.ts +1 -1
  14. package/src/libs/maps/maps.js +1 -1
  15. package/src/packages/get-form-control-payload/get-form-control-payload.d.ts.map +1 -1
  16. package/src/packages/get-form-control-payload/get-form-control-payload.js +18 -6
  17. package/src/packages/get-form-control-payload/helpers/check-has-value-as-array/check-has-value-as-array.helper.d.ts +8 -0
  18. package/src/packages/get-form-control-payload/helpers/check-has-value-as-array/check-has-value-as-array.helper.d.ts.map +1 -0
  19. package/src/packages/get-form-control-payload/helpers/check-has-value-as-array/check-has-value-as-array.helper.js +21 -0
  20. 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
  21. 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
  22. package/src/packages/get-form-control-payload/helpers/check-is-refer-to-another-node/check-is-refer-to-another-node.helper.js +2 -2
  23. package/src/packages/get-form-control-payload/helpers/get-checkbox-value/get-checkbox-value.helper.d.ts +2 -2
  24. package/src/packages/get-form-control-payload/helpers/get-checkbox-value/get-checkbox-value.helper.d.ts.map +1 -1
  25. package/src/packages/get-form-control-payload/helpers/get-checkbox-value/get-checkbox-value.helper.js +9 -1
  26. 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
  27. 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
  28. 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
  29. package/src/packages/get-form-control-payload/helpers/helpers.d.ts +2 -0
  30. package/src/packages/get-form-control-payload/helpers/helpers.js +2 -0
  31. package/src/libs/maps/element-name-to-element-instance.map.d.ts.map +0 -1
  32. /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.4.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,36 +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 | 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="date"` | ✅ | [`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="time"` | ✅ | [`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="month"` | ✅ | [`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="week"` | ✅ | [`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="datetime-local"` | ✅ | [`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="file"` | ✅ | [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) or `null` |
87
- | [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> |
88
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="button"` | | |
89
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="submit"` | ❌ | – |
90
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="reset"` | ❌ | – |
91
- | [HTMLInputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement) | `type="image"` | ❌ | – |
92
- | [HTMLTextAreaElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextareaElement) | | | `string` |
93
- | [HTMLSelectElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement) | – | ✅ | `string` |
94
- | [HTMLSelectElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement) | `multiple` | ✅ | `Array<string>` |
95
- | [HTMLOutputElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLOutputElement) | | ✅ | `string` |
96
- | [HTMLFieldsetElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFieldsetElement) | – | ✅ | `Object<name: string, value: unknown>` (recursive values of nested elements) |
97
- | [HTMLButtonElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement) | – | | |
98
- | [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 };
@@ -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":"qCAec,OAAO,2BAA2B,EAAE,sBAAsB;gDAC1D,OAAO,2BAA2B,EAAE,iCAAiC;AA+BnF;;;;;GAKG;AACH,sEAJW,iCAAiC,KAmG3C;AArID,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,9 +1,11 @@
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,
@@ -24,22 +26,32 @@ import {
24
26
  const getFormControlsPayload = (...controlElements) => {
25
27
  const allowedElements = getAllowedElements(controlElements);
26
28
 
27
- let elementsValues = /** @type {T} */ ({});
29
+ const elementsValues = /** @type {T} */ ({});
28
30
 
29
31
  for (const element of allowedElements) {
30
32
  const isReferToAnotherNode = checkIsReferToAnotherNode(
31
33
  element,
32
- ...allowedElements,
34
+ allowedElements,
33
35
  );
34
36
 
35
37
  if (isReferToAnotherNode) {
36
38
  continue;
37
39
  }
38
40
 
39
- elementsValues = {
40
- ...elementsValues,
41
- [element.name]: getFormControlPayload(element),
42
- };
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;
43
55
  }
44
56
 
45
57
  return elementsValues;
@@ -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 };
@@ -1,6 +1,8 @@
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";
@@ -1,6 +1,8 @@
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';
@@ -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":""}