@nomos-ui/form 0.1.1 → 0.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.
|
@@ -2,7 +2,7 @@ export declare function getNestedErrorMessage(errors: Record<string, any>, path:
|
|
|
2
2
|
/**
|
|
3
3
|
* Converts a JSON object to FormData with support for nested objects, arrays, and files.
|
|
4
4
|
*
|
|
5
|
-
* @param {Record<string, any>}
|
|
5
|
+
* @param {Record<string, any>} obj - The JSON object to convert
|
|
6
6
|
* @param {FormData} [formData=new FormData()] - Optional existing FormData to append to
|
|
7
7
|
* @param {string} [parentKey=''] - Internal parameter for tracking nested keys
|
|
8
8
|
* @returns {FormData} The populated FormData object
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/helpers/form.helpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,IAAI,EAAE,MAAM,OAWb;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACxB,QAAQ,GAAE,QAAyB,EACnC,SAAS,GAAE,MAAW,GACrB,QAAQ,
|
|
1
|
+
{"version":3,"file":"form.helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/helpers/form.helpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,IAAI,EAAE,MAAM,OAWb;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACxB,QAAQ,GAAE,QAAyB,EACnC,SAAS,GAAE,MAAW,GACrB,QAAQ,CAgDV"}
|
|
@@ -15,7 +15,7 @@ function getNestedErrorMessage(errors, path) {
|
|
|
15
15
|
/**
|
|
16
16
|
* Converts a JSON object to FormData with support for nested objects, arrays, and files.
|
|
17
17
|
*
|
|
18
|
-
* @param {Record<string, any>}
|
|
18
|
+
* @param {Record<string, any>} obj - The JSON object to convert
|
|
19
19
|
* @param {FormData} [formData=new FormData()] - Optional existing FormData to append to
|
|
20
20
|
* @param {string} [parentKey=''] - Internal parameter for tracking nested keys
|
|
21
21
|
* @returns {FormData} The populated FormData object
|
|
@@ -55,18 +55,26 @@ function objectToFormData(obj, formData = new FormData(), parentKey = "") {
|
|
|
55
55
|
formData.append(`${formKey}[]`, "");
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
|
-
value.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
const isFileArray = value.every((item) => item instanceof File || item instanceof Blob);
|
|
59
|
+
if (isFileArray) {
|
|
60
|
+
value.forEach((file) => {
|
|
61
|
+
formData.append(formKey, file);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
value.forEach((item, index) => {
|
|
66
|
+
const arrayKey = `${formKey}[${index}]`;
|
|
67
|
+
if (typeof item === "object" &&
|
|
68
|
+
item !== null &&
|
|
69
|
+
!(item instanceof File) &&
|
|
70
|
+
!(item instanceof Blob)) {
|
|
71
|
+
objectToFormData(item, formData, arrayKey);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
formData.append(arrayKey, item);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
70
78
|
}
|
|
71
79
|
}
|
|
72
80
|
else if (typeof value === "object" && value !== null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.helpers.js","sourceRoot":"","sources":["../../../src/utils/helpers/form.helpers.ts"],"names":[],"mappings":";;AAAA,sDAaC;AA6BD,
|
|
1
|
+
{"version":3,"file":"form.helpers.js","sourceRoot":"","sources":["../../../src/utils/helpers/form.helpers.ts"],"names":[],"mappings":";;AAAA,sDAaC;AA6BD,4CAoDC;AA9FD,SAAgB,qBAAqB,CACnC,MAA2B,EAC3B,IAAY;IAEZ,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE9B,IAAI,OAAO,GAAG,MAAM,CAAC;IACrB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QAC5C,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,gBAAgB,CAC9B,GAAwB,EACxB,WAAqB,IAAI,QAAQ,EAAE,EACnC,YAAoB,EAAE;IAEtB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IAEvD,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC;YAAE,SAAS;QAEvC,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QACvB,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QAEzD,IAAI,CAAC,KAAK,YAAY,IAAI,IAAI,KAAK,YAAY,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;YAC9D,QAAQ,CAAC,MAA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,OAAO,CAAC,CAAC;QAC7C,CAAC;aAAM,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAC/B,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nomos-ui/form",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "The Shadcn library for building robust React forms",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/exports/index.js",
|
|
@@ -19,9 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"typesVersions": {
|
|
21
21
|
"*": {
|
|
22
|
-
"utils": [
|
|
23
|
-
"./dist/exports/utils/index.d.ts"
|
|
24
|
-
]
|
|
22
|
+
"utils": ["./dist/exports/utils/index.d.ts"]
|
|
25
23
|
}
|
|
26
24
|
},
|
|
27
25
|
"scripts": {
|
|
@@ -64,14 +62,14 @@
|
|
|
64
62
|
"url": "https://github.com/uanela/nomos-ui/issues"
|
|
65
63
|
},
|
|
66
64
|
"homepage": "https://github.com/uanela/nomos-ui",
|
|
67
|
-
"files": [
|
|
68
|
-
"dist",
|
|
69
|
-
"README.md",
|
|
70
|
-
"LICENSE"
|
|
71
|
-
],
|
|
65
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
72
66
|
"sideEffects": false,
|
|
73
67
|
"packageManager": "pnpm@10.13.1",
|
|
74
68
|
"dependencies": {
|
|
69
|
+
"@nomos-ui/common": "^0.3.1",
|
|
70
|
+
"@nomos-ui/core": "^0.5.1",
|
|
71
|
+
"@nomos-ui/layout": "^0.0.6",
|
|
72
|
+
"@nomos-ui/uanela-redux-next": "^0.3.1",
|
|
75
73
|
"@radix-ui/react-select": "^2.2.6",
|
|
76
74
|
"@radix-ui/react-slot": "^1.2.3",
|
|
77
75
|
"@tailwindcss/postcss": "^4.1.16",
|