@dmitryvim/form-builder 0.1.40 → 0.1.42

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.
@@ -1661,7 +1661,7 @@ function validateForm(skipValidation = false) {
1661
1661
  if (child.hidden) {
1662
1662
  // For hidden child elements, use their default value
1663
1663
  itemData[child.key] =
1664
- child.default !== undefined ? child.default : "";
1664
+ child.default !== undefined ? child.default : null;
1665
1665
  } else {
1666
1666
  const childKey = `${fullKey}[${actualIndex}].${child.key}`;
1667
1667
  itemData[child.key] = validateElement(
@@ -1683,7 +1683,7 @@ function validateForm(skipValidation = false) {
1683
1683
  if (child.hidden) {
1684
1684
  // For hidden child elements, use their default value
1685
1685
  groupData[child.key] =
1686
- child.default !== undefined ? child.default : "";
1686
+ child.default !== undefined ? child.default : null;
1687
1687
  } else {
1688
1688
  const childKey = `${key}.${child.key}`;
1689
1689
  groupData[child.key] = validateElement(
@@ -1716,7 +1716,7 @@ function validateForm(skipValidation = false) {
1716
1716
  if (child.hidden) {
1717
1717
  // For hidden child elements, use their default value
1718
1718
  itemData[child.key] =
1719
- child.default !== undefined ? child.default : "";
1719
+ child.default !== undefined ? child.default : null;
1720
1720
  } else {
1721
1721
  const childKey = `${key}[${i}].${child.key}`;
1722
1722
  itemData[child.key] = validateElement(
@@ -1755,7 +1755,7 @@ function validateForm(skipValidation = false) {
1755
1755
  if (child.hidden) {
1756
1756
  // For hidden child elements, use their default value
1757
1757
  containerData[child.key] =
1758
- child.default !== undefined ? child.default : "";
1758
+ child.default !== undefined ? child.default : null;
1759
1759
  } else {
1760
1760
  const childKey = `${key}.${child.key}`;
1761
1761
  containerData[child.key] = validateElement(
@@ -1776,7 +1776,9 @@ function validateForm(skipValidation = false) {
1776
1776
  state.schema.elements.forEach((element) => {
1777
1777
  // Handle hidden elements - use their default value instead of reading from DOM
1778
1778
  if (element.hidden) {
1779
- data[element.key] = element.default !== undefined ? element.default : "";
1779
+ // Use null as default for consistency with empty field behavior
1780
+ // File fields, number fields, and other non-text fields return null when empty
1781
+ data[element.key] = element.default !== undefined ? element.default : null;
1780
1782
  } else {
1781
1783
  data[element.key] = validateElement(element, { path: "" });
1782
1784
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.40",
6
+ "version": "0.1.42",
7
7
  "description": "A reusable JSON schema form builder library",
8
8
  "main": "dist/form-builder.js",
9
9
  "module": "dist/form-builder.js",
@@ -43,7 +43,10 @@
43
43
  "url": "git+https://github.com/picazru/form-builder.git"
44
44
  },
45
45
  "devDependencies": {
46
+ "@babel/core": "^7.28.5",
47
+ "@babel/preset-env": "^7.28.5",
46
48
  "@eslint/js": "^9.35.0",
49
+ "babel-jest": "^30.2.0",
47
50
  "eslint": "^9.35.0",
48
51
  "jest": "^29.0.0",
49
52
  "jest-environment-jsdom": "^29.7.0",