@wix/form-public 0.13.0 → 0.15.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.
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  import * as React30 from 'react';
2
2
  import React30__default, { createContext, forwardRef, useState, useMemo, useRef, useEffect, useCallback, useImperativeHandle, useContext } from 'react';
3
3
  import ReactDOM from 'react-dom';
4
- import { jsx, Fragment } from 'react/jsx-runtime';
4
+ import camelCase from 'lodash.camelcase';
5
+ import mapKeys from 'lodash.mapkeys';
6
+ import { jsx } from 'react/jsx-runtime';
5
7
 
6
8
  var __create = Object.create;
7
9
  var __defProp = Object.defineProperty;
@@ -4449,7 +4451,7 @@ var require_react_is_development = __commonJS({
4449
4451
  var ContextProvider = REACT_PROVIDER_TYPE;
4450
4452
  var Element2 = REACT_ELEMENT_TYPE;
4451
4453
  var ForwardRef = REACT_FORWARD_REF_TYPE;
4452
- var Fragment2 = REACT_FRAGMENT_TYPE;
4454
+ var Fragment = REACT_FRAGMENT_TYPE;
4453
4455
  var Lazy = REACT_LAZY_TYPE;
4454
4456
  var Memo = REACT_MEMO_TYPE;
4455
4457
  var Portal = REACT_PORTAL_TYPE;
@@ -4508,7 +4510,7 @@ var require_react_is_development = __commonJS({
4508
4510
  exports.ContextProvider = ContextProvider;
4509
4511
  exports.Element = Element2;
4510
4512
  exports.ForwardRef = ForwardRef;
4511
- exports.Fragment = Fragment2;
4513
+ exports.Fragment = Fragment;
4512
4514
  exports.Lazy = Lazy;
4513
4515
  exports.Memo = Memo;
4514
4516
  exports.Portal = Portal;
@@ -29951,6 +29953,24 @@ var FIELD_TYPE_MAP = {
29951
29953
  RICH_TEXT: "TEXT",
29952
29954
  SUBMIT_BUTTON: "SUBMIT_BUTTON"
29953
29955
  };
29956
+ function convertKeysToCamelCase(obj) {
29957
+ if (Array.isArray(obj)) {
29958
+ return obj.map(convertKeysToCamelCase);
29959
+ }
29960
+ if (obj !== null && typeof obj === "object") {
29961
+ const converted = mapKeys(
29962
+ obj,
29963
+ (_23, key) => camelCase(key)
29964
+ );
29965
+ return Object.fromEntries(
29966
+ Object.entries(converted).map(([key, value]) => [
29967
+ key,
29968
+ convertKeysToCamelCase(value)
29969
+ ])
29970
+ );
29971
+ }
29972
+ return obj;
29973
+ }
29954
29974
  var mapFieldProps = (fields, mappers) => Object.fromEntries(
29955
29975
  Object.entries(fields).map(([fieldType, Component]) => [
29956
29976
  fieldType,
@@ -29963,27 +29983,40 @@ var mapFieldTypes = (fields, typeMap) => ({
29963
29983
  Object.entries(typeMap).filter(([, targetType]) => fields[targetType]).map(([newName, targetType]) => [newName, fields[targetType]])
29964
29984
  )
29965
29985
  });
29966
- var Form2 = (props) => {
29986
+ var Form2 = ({
29987
+ form: unformattedForm,
29988
+ fields,
29989
+ values,
29990
+ onChange,
29991
+ errors,
29992
+ onValidate
29993
+ }) => {
29994
+ const form = convertKeysToCamelCase(unformattedForm);
29967
29995
  const siteConfig = {
29968
29996
  locale: {
29969
29997
  languageCode: "en"
29970
29998
  }
29971
29999
  };
29972
30000
  const i18n2 = initI18n({ locale: siteConfig.locale.languageCode });
29973
- const mappedFieldProps = mapFieldProps(props.fields, FIELD_PROP_MAP);
30001
+ const mappedFieldProps = mapFieldProps(fields, FIELD_PROP_MAP);
29974
30002
  const mappedFieldTypes = mapFieldTypes(mappedFieldProps, FIELD_TYPE_MAP);
29975
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
30003
+ return /* @__PURE__ */ jsx(
29976
30004
  FormViewerStatic,
29977
30005
  {
29978
- form: props.form || {},
29979
- values: props.values,
29980
- onChange: props.onChange,
29981
- errors: props.errors,
29982
- onValidate: props.onValidate,
30006
+ form,
30007
+ values,
30008
+ onChange,
30009
+ errors,
30010
+ onValidate,
29983
30011
  fields: mappedFieldTypes,
29984
- i18n: i18n2
30012
+ i18n: i18n2,
30013
+ WixRicosViewer: () => null,
30014
+ config: {
30015
+ locale: siteConfig.locale.languageCode,
30016
+ regionalFormat: siteConfig.locale.languageCode
30017
+ }
29985
30018
  }
29986
- ) });
30019
+ );
29987
30020
  };
29988
30021
  /*! Bundled license information:
29989
30022