@rkosafo/cai.components 0.0.24 → 0.0.25
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.
|
@@ -166,10 +166,30 @@
|
|
|
166
166
|
return (hidden = true);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
169
|
+
// Convert FormData into a proper object with arrays
|
|
170
|
+
const data: Record<string, any> = {};
|
|
171
|
+
combinedFormData.forEach((value, key) => {
|
|
172
|
+
if (data[key] !== undefined) {
|
|
173
|
+
// Already exists, convert to array (or push to existing array)
|
|
174
|
+
if (!Array.isArray(data[key])) {
|
|
175
|
+
data[key] = [data[key]];
|
|
176
|
+
}
|
|
177
|
+
data[key].push(value);
|
|
178
|
+
} else {
|
|
179
|
+
data[key] = value;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Optionally cast certain values
|
|
184
|
+
Object.keys(data).forEach((key) => {
|
|
185
|
+
if (data[key] === 'true') data[key] = true;
|
|
186
|
+
else if (data[key] === 'false') data[key] = false;
|
|
187
|
+
else if (!isNaN(data[key]) && data[key] !== '' && !Array.isArray(data[key])) {
|
|
188
|
+
data[key] = Number(data[key]);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
if (typeof onaction === 'function' && onaction({ action: returnValue, data }) === false) {
|
|
173
193
|
return;
|
|
174
194
|
}
|
|
175
195
|
|