@wix/form-public 0.176.0 → 0.177.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.cjs +6 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -32031,20 +32031,20 @@ var AUTOFILL_FIELDS = [
|
|
|
32031
32031
|
{ fieldType: FIELD_TYPES.CONTACTS_LAST_NAME, key: "lastName" },
|
|
32032
32032
|
{ fieldType: FIELD_TYPES.CONTACTS_PHONE, key: "phone" }
|
|
32033
32033
|
];
|
|
32034
|
-
function
|
|
32034
|
+
function autofillValues(form, values, config) {
|
|
32035
|
+
const result2 = { ...values };
|
|
32035
32036
|
const userData = config?.userData;
|
|
32036
32037
|
if (!userData || form?.autoFillContact !== ContactAutofill.MEMBER_DATA) {
|
|
32037
|
-
return
|
|
32038
|
+
return result2;
|
|
32038
32039
|
}
|
|
32039
32040
|
const fields = form?.fields ?? [];
|
|
32040
|
-
const result2 = {};
|
|
32041
32041
|
for (const { fieldType, key } of AUTOFILL_FIELDS) {
|
|
32042
32042
|
const value = userData[key]?.trim();
|
|
32043
32043
|
if (!value) {
|
|
32044
32044
|
continue;
|
|
32045
32045
|
}
|
|
32046
32046
|
const target = fields.find((field) => field.view?.fieldType === fieldType)?.target;
|
|
32047
|
-
if (target) {
|
|
32047
|
+
if (target && (result2[target] == null || result2[target] === "")) {
|
|
32048
32048
|
result2[target] = value;
|
|
32049
32049
|
}
|
|
32050
32050
|
}
|
|
@@ -32055,15 +32055,10 @@ function getAutofillValues(form, config) {
|
|
|
32055
32055
|
var useFormValues = (form, values, onChange, config, enableAutofill) => {
|
|
32056
32056
|
const hasAutofilled = React42.useRef(false);
|
|
32057
32057
|
const normalizedValues = React42.useMemo(() => {
|
|
32058
|
-
|
|
32058
|
+
let filled = fillEmptyValues(form, values);
|
|
32059
32059
|
if (enableAutofill && !hasAutofilled.current && config?.userData) {
|
|
32060
32060
|
hasAutofilled.current = true;
|
|
32061
|
-
|
|
32062
|
-
for (const [key, value] of Object.entries(autofill)) {
|
|
32063
|
-
if (filled[key] == null) {
|
|
32064
|
-
filled[key] = value;
|
|
32065
|
-
}
|
|
32066
|
-
}
|
|
32061
|
+
filled = autofillValues(form, filled, config);
|
|
32067
32062
|
}
|
|
32068
32063
|
return normalizeValues(form, filled, true, config);
|
|
32069
32064
|
}, [form, values, config, enableAutofill]);
|