@wix/form-public 0.568.0 → 0.570.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 +129 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +129 -23
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -36548,6 +36548,7 @@ var require_messages_en2 = __commonJS({
|
|
|
36548
36548
|
"date-picker.a11y.arrow-right": "Go to next month",
|
|
36549
36549
|
"input.error.message.incomplete-date-error.time": "Enter a time.",
|
|
36550
36550
|
"field.signature.canvas.aria-label.signed": "Signature drawing area (signed)",
|
|
36551
|
+
"field.a11y.cleared-announcement": "{fieldLabel} cleared.",
|
|
36551
36552
|
"settings.default-value-conflict.regex-error": "The regex must be viable for the entered default value. Update the regex or change the text.",
|
|
36552
36553
|
"contacts-phone.input.error.message.format-error": "Enter a valid phone number.",
|
|
36553
36554
|
"tags.input.error.message.required-error": "Choose an option.",
|
|
@@ -43862,6 +43863,7 @@ function useTranslation2() {
|
|
|
43862
43863
|
|
|
43863
43864
|
// ../form-experiments/dist/esm/experiments.js
|
|
43864
43865
|
var EXPERIMENTS = {
|
|
43866
|
+
ADDRESS_HOUSE_NUMBER_FALLBACK: "addressHouseNumberFallback",
|
|
43865
43867
|
ENABLE_FORM_SCHEMA_V2_PRICING_PLANS: "enableFormSchemaV2PricingPlans",
|
|
43866
43868
|
STREETLESS_LOCALITY_FALLBACK: "streetlessLocalityFallback",
|
|
43867
43869
|
SUBMIT_SUCCESS_NO_FOCUS: "specs.forms.SubmitSuccessNoFocus",
|
|
@@ -58781,6 +58783,22 @@ var searchByPostalCode = async ({ postalCode, countryCode }) => {
|
|
|
58781
58783
|
proximity
|
|
58782
58784
|
})));
|
|
58783
58785
|
};
|
|
58786
|
+
var searchByQuery = async ({ query, countryCode }) => {
|
|
58787
|
+
const { searchResults } = await es_exports8.search({
|
|
58788
|
+
query,
|
|
58789
|
+
...countryCode ? {
|
|
58790
|
+
countryCodes: [
|
|
58791
|
+
countryCode
|
|
58792
|
+
]
|
|
58793
|
+
} : {}
|
|
58794
|
+
});
|
|
58795
|
+
return (searchResults ?? []).flatMap(({ address }) => {
|
|
58796
|
+
const commonAddress = toCommonAddress(address);
|
|
58797
|
+
return commonAddress ? [
|
|
58798
|
+
commonAddress
|
|
58799
|
+
] : [];
|
|
58800
|
+
});
|
|
58801
|
+
};
|
|
58784
58802
|
var AddressFieldsContext = /* @__PURE__ */ React172.createContext(void 0);
|
|
58785
58803
|
var AddressFieldsProvider = ({ children, fields }) => {
|
|
58786
58804
|
const value = React172.useMemo(() => ({
|
|
@@ -58863,35 +58881,111 @@ AddressLine2.Label = Label;
|
|
|
58863
58881
|
AddressLine2.Input = Input3;
|
|
58864
58882
|
AddressLine2.Description = Description;
|
|
58865
58883
|
AddressLine2.Error = Error2;
|
|
58884
|
+
|
|
58885
|
+
// ../form-fields/dist/esm/ui/address-input/resolve-place.js
|
|
58886
|
+
var STREET_PLACE_TYPE = "route";
|
|
58887
|
+
var isStreetPrediction = (prediction) => prediction.types?.includes(STREET_PLACE_TYPE) ?? false;
|
|
58888
|
+
var ADDRESS_TEXT_SEPARATORS = /[\s,]+/;
|
|
58889
|
+
var toAddressTokens = (text) => text ? text.toLowerCase().split(ADDRESS_TEXT_SEPARATORS) : [];
|
|
58890
|
+
var containsHouseNumber = (text, houseNumber, streetName) => {
|
|
58891
|
+
if (!text || !houseNumber) {
|
|
58892
|
+
return false;
|
|
58893
|
+
}
|
|
58894
|
+
const streetNameTokens = toAddressTokens(streetName);
|
|
58895
|
+
return toAddressTokens(text).filter((token) => !streetNameTokens.includes(token)).includes(houseNumber.toLowerCase());
|
|
58896
|
+
};
|
|
58897
|
+
var postalCodeBase = (postalCode) => postalCode.split("-")[0];
|
|
58898
|
+
var isSamePostalArea = (place, candidate) => !place.postalCode || !candidate.postalCode || postalCodeBase(place.postalCode) === postalCodeBase(candidate.postalCode);
|
|
58899
|
+
var isSameStreet = (place, candidate) => Boolean(place.streetAddress?.name) && place.streetAddress?.name?.toLowerCase() === candidate.streetAddress?.name?.toLowerCase();
|
|
58900
|
+
var isSameStreetLocation = (place, candidate) => candidate.country === place.country && candidate.subdivision === place.subdivision && isSamePostalArea(place, candidate) && isSameStreet(place, candidate);
|
|
58901
|
+
var searchHouseNumber = async (query, place, searchByQuery2) => {
|
|
58902
|
+
try {
|
|
58903
|
+
const candidates = await searchByQuery2({
|
|
58904
|
+
query,
|
|
58905
|
+
countryCode: place.country ?? void 0
|
|
58906
|
+
});
|
|
58907
|
+
return candidates?.find((candidate) => isSameStreetLocation(place, candidate) && containsHouseNumber(query, candidate.streetAddress?.number, place.streetAddress?.name))?.streetAddress?.number;
|
|
58908
|
+
} catch {
|
|
58909
|
+
return void 0;
|
|
58910
|
+
}
|
|
58911
|
+
};
|
|
58912
|
+
var withHouseNumber = (place, houseNumber, suggestionText) => {
|
|
58913
|
+
const streetAddress = {
|
|
58914
|
+
...place.streetAddress,
|
|
58915
|
+
number: houseNumber
|
|
58916
|
+
};
|
|
58917
|
+
if (!containsHouseNumber(suggestionText, houseNumber)) {
|
|
58918
|
+
return {
|
|
58919
|
+
...place,
|
|
58920
|
+
streetAddress
|
|
58921
|
+
};
|
|
58922
|
+
}
|
|
58923
|
+
return {
|
|
58924
|
+
...place,
|
|
58925
|
+
...place.addressLine ? {
|
|
58926
|
+
addressLine: suggestionText
|
|
58927
|
+
} : {},
|
|
58928
|
+
streetAddress: {
|
|
58929
|
+
...streetAddress,
|
|
58930
|
+
formattedAddressLine: suggestionText
|
|
58931
|
+
}
|
|
58932
|
+
};
|
|
58933
|
+
};
|
|
58934
|
+
var resolvePlace = async ({ searchId, prediction, getPlace: getPlace6, searchByQuery: searchByQuery2 }) => {
|
|
58935
|
+
const place = await getPlace6({
|
|
58936
|
+
searchId
|
|
58937
|
+
});
|
|
58938
|
+
if (!place || place.streetAddress?.number || !prediction?.description || !isStreetPrediction(prediction) || !searchByQuery2) {
|
|
58939
|
+
return place;
|
|
58940
|
+
}
|
|
58941
|
+
const houseNumber = await searchHouseNumber(prediction.description, place, searchByQuery2);
|
|
58942
|
+
return houseNumber ? withHouseNumber(place, houseNumber, prediction.textStructure?.mainText) : place;
|
|
58943
|
+
};
|
|
58944
|
+
|
|
58945
|
+
// ../form-fields/dist/esm/ui/address-input/use-atlas.js
|
|
58866
58946
|
var useAtlas = ({ enabled }) => {
|
|
58867
58947
|
const { actions } = useFieldActions();
|
|
58948
|
+
const { isExperimentEnabled: isExperimentEnabled2 } = useExperiments();
|
|
58949
|
+
const addressHouseNumberFallbackEnabled = isExperimentEnabled2(EXPERIMENTS.ADDRESS_HOUSE_NUMBER_FALLBACK);
|
|
58868
58950
|
const [sessionToken, setSessionToken] = React172.useState(generateUUID());
|
|
58869
58951
|
const refreshSessionToken = React172.useCallback(() => setSessionToken(generateUUID()), []);
|
|
58952
|
+
const resolvePlaceRequestId = React172.useRef(0);
|
|
58870
58953
|
return React172.useMemo(() => {
|
|
58871
|
-
const { predict: predict6, getPlace: getPlace6, searchByPostalCode: searchByPostalCode2 } = actions ?? {};
|
|
58954
|
+
const { predict: predict6, getPlace: getPlace6, searchByPostalCode: searchByPostalCode2, searchByQuery: searchByQuery2 } = actions ?? {};
|
|
58872
58955
|
if (!enabled || !predict6 || !getPlace6 || !searchByPostalCode2) {
|
|
58873
58956
|
return void 0;
|
|
58874
58957
|
}
|
|
58958
|
+
const getPlaceInSession = (params) => getPlace6({
|
|
58959
|
+
...params,
|
|
58960
|
+
sessionToken,
|
|
58961
|
+
refreshSessionToken
|
|
58962
|
+
});
|
|
58875
58963
|
return {
|
|
58876
58964
|
predict: (params) => predict6({
|
|
58877
58965
|
...params,
|
|
58878
58966
|
sessionToken
|
|
58879
58967
|
}),
|
|
58880
|
-
getPlace:
|
|
58881
|
-
...params,
|
|
58882
|
-
sessionToken,
|
|
58883
|
-
refreshSessionToken
|
|
58884
|
-
}),
|
|
58968
|
+
getPlace: getPlaceInSession,
|
|
58885
58969
|
searchByPostalCode: (params) => searchByPostalCode2({
|
|
58886
58970
|
...params,
|
|
58887
58971
|
sessionToken
|
|
58888
|
-
})
|
|
58972
|
+
}),
|
|
58973
|
+
resolvePlace: async (params) => {
|
|
58974
|
+
const requestId = ++resolvePlaceRequestId.current;
|
|
58975
|
+
const place = await resolvePlace({
|
|
58976
|
+
...params,
|
|
58977
|
+
getPlace: getPlaceInSession,
|
|
58978
|
+
searchByQuery: addressHouseNumberFallbackEnabled ? searchByQuery2 : void 0
|
|
58979
|
+
});
|
|
58980
|
+
return requestId === resolvePlaceRequestId.current ? place : void 0;
|
|
58981
|
+
}
|
|
58889
58982
|
};
|
|
58890
58983
|
}, [
|
|
58891
58984
|
enabled,
|
|
58892
58985
|
actions,
|
|
58893
58986
|
sessionToken,
|
|
58894
|
-
refreshSessionToken
|
|
58987
|
+
refreshSessionToken,
|
|
58988
|
+
addressHouseNumberFallbackEnabled
|
|
58895
58989
|
]);
|
|
58896
58990
|
};
|
|
58897
58991
|
|
|
@@ -59092,8 +59186,10 @@ var AddressLineAutocomplete = ({ children, value, onChange, disabled, readOnly,
|
|
|
59092
59186
|
return;
|
|
59093
59187
|
}
|
|
59094
59188
|
clearPredictions();
|
|
59095
|
-
const
|
|
59096
|
-
|
|
59189
|
+
const searchId = String(key);
|
|
59190
|
+
const address = await atlas?.resolvePlace({
|
|
59191
|
+
searchId,
|
|
59192
|
+
prediction: predictions.find((prediction) => prediction.searchId === searchId)
|
|
59097
59193
|
});
|
|
59098
59194
|
if (address && onAddressSelect) {
|
|
59099
59195
|
onAddressSelect(address);
|
|
@@ -59101,7 +59197,8 @@ var AddressLineAutocomplete = ({ children, value, onChange, disabled, readOnly,
|
|
|
59101
59197
|
}, [
|
|
59102
59198
|
onAddressSelect,
|
|
59103
59199
|
clearPredictions,
|
|
59104
|
-
atlas
|
|
59200
|
+
atlas,
|
|
59201
|
+
predictions
|
|
59105
59202
|
]);
|
|
59106
59203
|
const handleBlur = React172.useCallback(() => {
|
|
59107
59204
|
clearPredictions();
|
|
@@ -59868,8 +59965,10 @@ var StreetNameAutocomplete = ({ children, value, onChange, disabled, readOnly, r
|
|
|
59868
59965
|
if (!key) {
|
|
59869
59966
|
return;
|
|
59870
59967
|
}
|
|
59871
|
-
const
|
|
59872
|
-
|
|
59968
|
+
const searchId = String(key);
|
|
59969
|
+
const address = await atlas?.resolvePlace({
|
|
59970
|
+
searchId,
|
|
59971
|
+
prediction: predictions.find((prediction) => prediction.searchId === searchId)
|
|
59873
59972
|
});
|
|
59874
59973
|
if (address && onAddressSelect) {
|
|
59875
59974
|
onAddressSelect(address);
|
|
@@ -59877,7 +59976,8 @@ var StreetNameAutocomplete = ({ children, value, onChange, disabled, readOnly, r
|
|
|
59877
59976
|
}, [
|
|
59878
59977
|
onAddressSelect,
|
|
59879
59978
|
clearPredictions,
|
|
59880
|
-
atlas
|
|
59979
|
+
atlas,
|
|
59980
|
+
predictions
|
|
59881
59981
|
]);
|
|
59882
59982
|
const handleBlur = React172.useCallback(() => {
|
|
59883
59983
|
clearPredictions();
|
|
@@ -60182,15 +60282,21 @@ var MultilineAddress = ({ children, className }) => {
|
|
|
60182
60282
|
const { validateFields: parentValidateFields } = useFieldValidation();
|
|
60183
60283
|
const formSchema = useForm();
|
|
60184
60284
|
const fieldActions = useFieldActions();
|
|
60185
|
-
const headlessFieldActions = React172.useMemo(() =>
|
|
60186
|
-
|
|
60187
|
-
|
|
60188
|
-
|
|
60189
|
-
|
|
60190
|
-
|
|
60191
|
-
|
|
60192
|
-
|
|
60193
|
-
|
|
60285
|
+
const headlessFieldActions = React172.useMemo(() => {
|
|
60286
|
+
const hostResolvesPlaces = Boolean(fieldActions.actions?.getPlace);
|
|
60287
|
+
return {
|
|
60288
|
+
...fieldActions,
|
|
60289
|
+
actions: {
|
|
60290
|
+
predict: predict5,
|
|
60291
|
+
getPlace: getPlace5,
|
|
60292
|
+
searchByPostalCode,
|
|
60293
|
+
...hostResolvesPlaces ? {} : {
|
|
60294
|
+
searchByQuery
|
|
60295
|
+
},
|
|
60296
|
+
...fieldActions.actions
|
|
60297
|
+
}
|
|
60298
|
+
};
|
|
60299
|
+
}, [
|
|
60194
60300
|
fieldActions
|
|
60195
60301
|
]);
|
|
60196
60302
|
const { form, isMultilineAddressField: isMultilineAddressField2 } = useMultilineAddressForm({
|