@wix/form-public 0.16.0 → 0.18.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.
@@ -12,13 +12,6 @@ export declare const CheckboxGroupMapper: PropsMapper;
12
12
 
13
13
  export declare const CheckboxMapper: PropsMapper;
14
14
 
15
- /**
16
- * Deeply converts all object keys from snake_case to camelCase
17
- * @param obj - The object to convert
18
- * @returns The object with all nested keys converted to camelCase
19
- */
20
- export declare function convertKeysToCamelCase<T = unknown>(obj: T): T;
21
-
22
15
  export declare type Currency = {
23
16
  sign?: string;
24
17
  code?: string;
@@ -71,6 +64,13 @@ export declare const ImageChoiceMapper: PropsMapper;
71
64
 
72
65
  export declare const MultilineAddressMapper: PropsMapper;
73
66
 
67
+ /**
68
+ * Normalizes object schema by removing underscore prefixes and converting keys to camelCase
69
+ * @param obj - The object to normalize
70
+ * @returns The object with all nested keys normalized
71
+ */
72
+ export declare function normalizeSchema<T = unknown>(obj: T): T;
73
+
74
74
  export declare const NumberInputMapper: PropsMapper;
75
75
 
76
76
  export declare const PaymentInputMapper: PropsMapper;
@@ -12,13 +12,6 @@ export declare const CheckboxGroupMapper: PropsMapper;
12
12
 
13
13
  export declare const CheckboxMapper: PropsMapper;
14
14
 
15
- /**
16
- * Deeply converts all object keys from snake_case to camelCase
17
- * @param obj - The object to convert
18
- * @returns The object with all nested keys converted to camelCase
19
- */
20
- export declare function convertKeysToCamelCase<T = unknown>(obj: T): T;
21
-
22
15
  export declare type Currency = {
23
16
  sign?: string;
24
17
  code?: string;
@@ -71,6 +64,13 @@ export declare const ImageChoiceMapper: PropsMapper;
71
64
 
72
65
  export declare const MultilineAddressMapper: PropsMapper;
73
66
 
67
+ /**
68
+ * Normalizes object schema by removing underscore prefixes and converting keys to camelCase
69
+ * @param obj - The object to normalize
70
+ * @returns The object with all nested keys normalized
71
+ */
72
+ export declare function normalizeSchema<T = unknown>(obj: T): T;
73
+
74
74
  export declare const NumberInputMapper: PropsMapper;
75
75
 
76
76
  export declare const PaymentInputMapper: PropsMapper;
package/dist/index.cjs CHANGED
@@ -29982,19 +29982,19 @@ var FIELD_TYPE_MAP = {
29982
29982
  RICH_TEXT: "TEXT",
29983
29983
  SUBMIT_BUTTON: "SUBMIT_BUTTON"
29984
29984
  };
29985
- function convertKeysToCamelCase(obj) {
29985
+ function normalizeSchema(obj) {
29986
29986
  if (Array.isArray(obj)) {
29987
- return obj.map(convertKeysToCamelCase);
29987
+ return obj.map(normalizeSchema);
29988
29988
  }
29989
29989
  if (obj !== null && typeof obj === "object") {
29990
- const converted = mapKeys__default.default(
29991
- obj,
29992
- (_23, key) => camelCase__default.default(key)
29993
- );
29990
+ const converted = mapKeys__default.default(obj, (_23, key) => {
29991
+ const keyWithoutUnderscore = key.startsWith("_") ? key.substring(1) : key;
29992
+ return camelCase__default.default(keyWithoutUnderscore);
29993
+ });
29994
29994
  return Object.fromEntries(
29995
29995
  Object.entries(converted).map(([key, value]) => [
29996
29996
  key,
29997
- convertKeysToCamelCase(value)
29997
+ normalizeSchema(value)
29998
29998
  ])
29999
29999
  );
30000
30000
  }
@@ -30020,7 +30020,7 @@ var Form2 = ({
30020
30020
  errors,
30021
30021
  onValidate
30022
30022
  }) => {
30023
- const form = convertKeysToCamelCase(unformattedForm);
30023
+ const form = normalizeSchema(unformattedForm);
30024
30024
  const siteConfig = {
30025
30025
  locale: {
30026
30026
  languageCode: "en"