@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/_tsup-dts-rollup.d.cts +8 -1
- package/dist/_tsup-dts-rollup.d.ts +8 -1
- package/dist/index.cjs +47 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +46 -13
- package/dist/index.js.map +1 -1
- package/package.json +8 -2
|
@@ -12,6 +12,13 @@ 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
|
+
|
|
15
22
|
export declare type Currency = {
|
|
16
23
|
sign?: string;
|
|
17
24
|
code?: string;
|
|
@@ -39,7 +46,7 @@ export declare const FileUploadMapper: PropsMapper;
|
|
|
39
46
|
|
|
40
47
|
export declare const FixedPaymentMapper: PropsMapper;
|
|
41
48
|
|
|
42
|
-
declare const Form: (
|
|
49
|
+
declare const Form: ({ form: unformattedForm, fields, values, onChange, errors, onValidate, }: FormProps) => JSX_2.Element;
|
|
43
50
|
export { Form }
|
|
44
51
|
export { Form as Form_alias_1 }
|
|
45
52
|
|
|
@@ -12,6 +12,13 @@ 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
|
+
|
|
15
22
|
export declare type Currency = {
|
|
16
23
|
sign?: string;
|
|
17
24
|
code?: string;
|
|
@@ -39,7 +46,7 @@ export declare const FileUploadMapper: PropsMapper;
|
|
|
39
46
|
|
|
40
47
|
export declare const FixedPaymentMapper: PropsMapper;
|
|
41
48
|
|
|
42
|
-
declare const Form: (
|
|
49
|
+
declare const Form: ({ form: unformattedForm, fields, values, onChange, errors, onValidate, }: FormProps) => JSX_2.Element;
|
|
43
50
|
export { Form }
|
|
44
51
|
export { Form as Form_alias_1 }
|
|
45
52
|
|
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var React30 = require('react');
|
|
4
4
|
var ReactDOM = require('react-dom');
|
|
5
|
+
var camelCase = require('lodash.camelcase');
|
|
6
|
+
var mapKeys = require('lodash.mapkeys');
|
|
5
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
8
|
|
|
7
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -26,6 +28,8 @@ function _interopNamespace(e) {
|
|
|
26
28
|
|
|
27
29
|
var React30__namespace = /*#__PURE__*/_interopNamespace(React30);
|
|
28
30
|
var ReactDOM__default = /*#__PURE__*/_interopDefault(ReactDOM);
|
|
31
|
+
var camelCase__default = /*#__PURE__*/_interopDefault(camelCase);
|
|
32
|
+
var mapKeys__default = /*#__PURE__*/_interopDefault(mapKeys);
|
|
29
33
|
|
|
30
34
|
var __create = Object.create;
|
|
31
35
|
var __defProp = Object.defineProperty;
|
|
@@ -4473,7 +4477,7 @@ var require_react_is_development = __commonJS({
|
|
|
4473
4477
|
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
4474
4478
|
var Element2 = REACT_ELEMENT_TYPE;
|
|
4475
4479
|
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
4476
|
-
var
|
|
4480
|
+
var Fragment = REACT_FRAGMENT_TYPE;
|
|
4477
4481
|
var Lazy = REACT_LAZY_TYPE;
|
|
4478
4482
|
var Memo = REACT_MEMO_TYPE;
|
|
4479
4483
|
var Portal = REACT_PORTAL_TYPE;
|
|
@@ -4532,7 +4536,7 @@ var require_react_is_development = __commonJS({
|
|
|
4532
4536
|
exports.ContextProvider = ContextProvider;
|
|
4533
4537
|
exports.Element = Element2;
|
|
4534
4538
|
exports.ForwardRef = ForwardRef;
|
|
4535
|
-
exports.Fragment =
|
|
4539
|
+
exports.Fragment = Fragment;
|
|
4536
4540
|
exports.Lazy = Lazy;
|
|
4537
4541
|
exports.Memo = Memo;
|
|
4538
4542
|
exports.Portal = Portal;
|
|
@@ -29975,6 +29979,24 @@ var FIELD_TYPE_MAP = {
|
|
|
29975
29979
|
RICH_TEXT: "TEXT",
|
|
29976
29980
|
SUBMIT_BUTTON: "SUBMIT_BUTTON"
|
|
29977
29981
|
};
|
|
29982
|
+
function convertKeysToCamelCase(obj) {
|
|
29983
|
+
if (Array.isArray(obj)) {
|
|
29984
|
+
return obj.map(convertKeysToCamelCase);
|
|
29985
|
+
}
|
|
29986
|
+
if (obj !== null && typeof obj === "object") {
|
|
29987
|
+
const converted = mapKeys__default.default(
|
|
29988
|
+
obj,
|
|
29989
|
+
(_23, key) => camelCase__default.default(key)
|
|
29990
|
+
);
|
|
29991
|
+
return Object.fromEntries(
|
|
29992
|
+
Object.entries(converted).map(([key, value]) => [
|
|
29993
|
+
key,
|
|
29994
|
+
convertKeysToCamelCase(value)
|
|
29995
|
+
])
|
|
29996
|
+
);
|
|
29997
|
+
}
|
|
29998
|
+
return obj;
|
|
29999
|
+
}
|
|
29978
30000
|
var mapFieldProps = (fields, mappers) => Object.fromEntries(
|
|
29979
30001
|
Object.entries(fields).map(([fieldType, Component]) => [
|
|
29980
30002
|
fieldType,
|
|
@@ -29987,27 +30009,40 @@ var mapFieldTypes = (fields, typeMap) => ({
|
|
|
29987
30009
|
Object.entries(typeMap).filter(([, targetType]) => fields[targetType]).map(([newName, targetType]) => [newName, fields[targetType]])
|
|
29988
30010
|
)
|
|
29989
30011
|
});
|
|
29990
|
-
var Form2 = (
|
|
30012
|
+
var Form2 = ({
|
|
30013
|
+
form: unformattedForm,
|
|
30014
|
+
fields,
|
|
30015
|
+
values,
|
|
30016
|
+
onChange,
|
|
30017
|
+
errors,
|
|
30018
|
+
onValidate
|
|
30019
|
+
}) => {
|
|
30020
|
+
const form = convertKeysToCamelCase(unformattedForm);
|
|
29991
30021
|
const siteConfig = {
|
|
29992
30022
|
locale: {
|
|
29993
30023
|
languageCode: "en"
|
|
29994
30024
|
}
|
|
29995
30025
|
};
|
|
29996
30026
|
const i18n2 = initI18n({ locale: siteConfig.locale.languageCode });
|
|
29997
|
-
const mappedFieldProps = mapFieldProps(
|
|
30027
|
+
const mappedFieldProps = mapFieldProps(fields, FIELD_PROP_MAP);
|
|
29998
30028
|
const mappedFieldTypes = mapFieldTypes(mappedFieldProps, FIELD_TYPE_MAP);
|
|
29999
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
30029
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
30000
30030
|
FormViewerStatic,
|
|
30001
30031
|
{
|
|
30002
|
-
form
|
|
30003
|
-
values
|
|
30004
|
-
onChange
|
|
30005
|
-
errors
|
|
30006
|
-
onValidate
|
|
30032
|
+
form,
|
|
30033
|
+
values,
|
|
30034
|
+
onChange,
|
|
30035
|
+
errors,
|
|
30036
|
+
onValidate,
|
|
30007
30037
|
fields: mappedFieldTypes,
|
|
30008
|
-
i18n: i18n2
|
|
30038
|
+
i18n: i18n2,
|
|
30039
|
+
WixRicosViewer: () => null,
|
|
30040
|
+
config: {
|
|
30041
|
+
locale: siteConfig.locale.languageCode,
|
|
30042
|
+
regionalFormat: siteConfig.locale.languageCode
|
|
30043
|
+
}
|
|
30009
30044
|
}
|
|
30010
|
-
)
|
|
30045
|
+
);
|
|
30011
30046
|
};
|
|
30012
30047
|
/*! Bundled license information:
|
|
30013
30048
|
|