@nuskin/shipping-address-form 1.7.8-fixes-2.1 → 1.7.8-fixes-3.2
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/addressLookup/components/SmartyIntlResults.js +114 -114
- package/dist/addressLookup/components/SmartyIntlResults.js.map +1 -1
- package/dist/addressLookup/components/SmartyUSResults.js +3 -3
- package/dist/addressLookup/components/SmartyUSResults.js.map +1 -1
- package/dist/addressLookup/utils/addressMapping.js +3 -0
- package/dist/addressLookup/utils/addressMapping.js.map +1 -1
- package/dist/addressLookup/utils/addressVerification.js +12 -12
- package/dist/addressLookup/utils/addressVerification.js.map +1 -1
- package/dist/shippingAddressForm/ShippingAddressForm.js +4 -4
- package/dist/shippingAddressForm/ShippingAddressForm.js.map +1 -1
- package/dist/shippingAddressForm/utils/shippingStrings.js +4 -0
- package/dist/shippingAddressForm/utils/shippingStrings.js.map +1 -1
- package/package.json +2 -2
|
@@ -32,12 +32,12 @@ const stripGeocode = (address = {}) => {
|
|
|
32
32
|
return nextAddress;
|
|
33
33
|
};
|
|
34
34
|
const FIELD_TEST_IDS = {
|
|
35
|
-
address1:
|
|
36
|
-
address2:
|
|
37
|
-
district:
|
|
38
|
-
region:
|
|
39
|
-
city:
|
|
40
|
-
postalCode:
|
|
35
|
+
address1: "qa-address1",
|
|
36
|
+
address2: "qa-address2",
|
|
37
|
+
district: "qa-address-county",
|
|
38
|
+
region: "qa-address-region",
|
|
39
|
+
city: "qa-address-city",
|
|
40
|
+
postalCode: "qa-address-zip"
|
|
41
41
|
};
|
|
42
42
|
const FIELD_IDS = {
|
|
43
43
|
address1: 'address-address1',
|
|
@@ -49,14 +49,14 @@ const FIELD_IDS = {
|
|
|
49
49
|
};
|
|
50
50
|
const getFieldTestId = field => FIELD_TEST_IDS[field] || `qa-address-${field}`;
|
|
51
51
|
const getFieldId = field => FIELD_IDS[field] || `address-${field}`;
|
|
52
|
-
const LOOKUP_LIST_BUTTON_SELECTOR =
|
|
52
|
+
const LOOKUP_LIST_BUTTON_SELECTOR = ".ns-address-lookup__list-button";
|
|
53
53
|
const SmartyIntlResults = ({
|
|
54
54
|
countryCode,
|
|
55
55
|
onSelect,
|
|
56
56
|
initialAddress = null,
|
|
57
57
|
readOnlyView = false,
|
|
58
58
|
validationRequestId = 0,
|
|
59
|
-
language =
|
|
59
|
+
language = "en",
|
|
60
60
|
strings = null,
|
|
61
61
|
formDefinition = null,
|
|
62
62
|
deferFormLookup = false,
|
|
@@ -64,8 +64,8 @@ const SmartyIntlResults = ({
|
|
|
64
64
|
suppressRequiredFieldsHint = false
|
|
65
65
|
}) => {
|
|
66
66
|
var _formDefinition$addre;
|
|
67
|
-
const [mode, setMode] = (0, _react.useState)(
|
|
68
|
-
const [query, setQuery] = (0, _react.useState)(
|
|
67
|
+
const [mode, setMode] = (0, _react.useState)("autocomplete");
|
|
68
|
+
const [query, setQuery] = (0, _react.useState)("");
|
|
69
69
|
const [selectedAddress, setSelectedAddress] = (0, _react.useState)(null);
|
|
70
70
|
const [selectedIntlAddressId, setSelectedIntlAddressId] = (0, _react.useState)(null);
|
|
71
71
|
const [formData, setFormData] = (0, _react.useState)(initialAddress || {});
|
|
@@ -113,7 +113,7 @@ const SmartyIntlResults = ({
|
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
}, []);
|
|
116
|
-
const isAutocompleteMode = mode ===
|
|
116
|
+
const isAutocompleteMode = mode === "autocomplete";
|
|
117
117
|
const {
|
|
118
118
|
labels: fieldLabels,
|
|
119
119
|
isLoading: areLabelsLoading
|
|
@@ -125,19 +125,19 @@ const SmartyIntlResults = ({
|
|
|
125
125
|
} = (0, _useAddressForm.default)(countryCode, shouldLoadAddressForm);
|
|
126
126
|
const providedAddressForm = formDefinition !== null && formDefinition !== void 0 && (_formDefinition$addre = formDefinition.addressElements) !== null && _formDefinition$addre !== void 0 && _formDefinition$addre.length ? formDefinition : null;
|
|
127
127
|
const resolvedAddressForm = providedAddressForm || loadedAddressForm;
|
|
128
|
-
const entryMode = (resolvedAddressForm === null || resolvedAddressForm === void 0 ? void 0 : resolvedAddressForm.entryMode) ||
|
|
129
|
-
const allowValidation = (resolvedAddressForm === null || resolvedAddressForm === void 0 ? void 0 : resolvedAddressForm.validationMode) !==
|
|
130
|
-
const lookupField = (resolvedAddressForm === null || resolvedAddressForm === void 0 ? void 0 : resolvedAddressForm.lookupField) ||
|
|
128
|
+
const entryMode = (resolvedAddressForm === null || resolvedAddressForm === void 0 ? void 0 : resolvedAddressForm.entryMode) || "both";
|
|
129
|
+
const allowValidation = (resolvedAddressForm === null || resolvedAddressForm === void 0 ? void 0 : resolvedAddressForm.validationMode) !== "disabled" && !readOnlyView;
|
|
130
|
+
const lookupField = (resolvedAddressForm === null || resolvedAddressForm === void 0 ? void 0 : resolvedAddressForm.lookupField) || "address1";
|
|
131
131
|
(0, _react.useEffect)(() => {
|
|
132
|
-
setMode(entryMode ===
|
|
132
|
+
setMode(entryMode === "manual" ? "manual" : "autocomplete");
|
|
133
133
|
}, [entryMode]);
|
|
134
134
|
const requiredFields = (0, _addressStatus.getRequiredFieldsFromAddressForm)(resolvedAddressForm);
|
|
135
|
-
const hasEmailField = ((resolvedAddressForm === null || resolvedAddressForm === void 0 ? void 0 : resolvedAddressForm.addressElements) || []).some(field => field.field ===
|
|
135
|
+
const hasEmailField = ((resolvedAddressForm === null || resolvedAddressForm === void 0 ? void 0 : resolvedAddressForm.addressElements) || []).some(field => field.field === "email");
|
|
136
136
|
const hasMapCoordinates = (formData === null || formData === void 0 ? void 0 : formData.latitude) !== undefined && (formData === null || formData === void 0 ? void 0 : formData.longitude) !== undefined;
|
|
137
|
-
const hasLookupValue = Boolean(String((formData === null || formData === void 0 ? void 0 : formData[lookupField]) ||
|
|
138
|
-
const canAttemptMap = Boolean(!isAutocompleteMode && hasLookupValue || isAutocompleteMode && [
|
|
137
|
+
const hasLookupValue = Boolean(String((formData === null || formData === void 0 ? void 0 : formData[lookupField]) || "").trim());
|
|
138
|
+
const canAttemptMap = Boolean(!isAutocompleteMode && hasLookupValue || isAutocompleteMode && ["autocomplete", "verified", "partial"].includes(verificationStatus) && hasLookupValue);
|
|
139
139
|
const showMapAction = !readOnlyView && (hasMapCoordinates || allowValidation && canAttemptMap);
|
|
140
|
-
const mapInfoLines = (mapAddressLines.length ? mapAddressLines : [formData.address1, formData.address2, formData.district, [formData.postalCode, formData.city].filter(Boolean).join(
|
|
140
|
+
const mapInfoLines = (mapAddressLines.length ? mapAddressLines : [formData.address1, formData.address2, formData.district, [formData.postalCode, formData.city].filter(Boolean).join(" "), formData.region]).filter(Boolean);
|
|
141
141
|
const {
|
|
142
142
|
mapContainerRef,
|
|
143
143
|
pendingMapOpen,
|
|
@@ -156,7 +156,7 @@ const SmartyIntlResults = ({
|
|
|
156
156
|
loading,
|
|
157
157
|
error,
|
|
158
158
|
rateLimited
|
|
159
|
-
} = (0, _useSmartyInternationalLookup.default)(!readOnlyView && shouldSearchRef.current && isAutocompleteMode ? query :
|
|
159
|
+
} = (0, _useSmartyInternationalLookup.default)(!readOnlyView && shouldSearchRef.current && isAutocompleteMode ? query : "", countryCode, selectedIntlAddressId, 500);
|
|
160
160
|
const {
|
|
161
161
|
suggestions: validationSuggestions,
|
|
162
162
|
loading: validationLoading,
|
|
@@ -164,8 +164,8 @@ const SmartyIntlResults = ({
|
|
|
164
164
|
rateLimited: validationRateLimited
|
|
165
165
|
} = (0, _useIntlAddressValidation.default)(formData, countryCode, allowValidation ? validationTrigger : 0, lookupField);
|
|
166
166
|
const lookupValue = formData[lookupField];
|
|
167
|
-
const lookupErrorMessage = lookupServiceError !== null && lookupServiceError !== void 0 && lookupServiceError.rateLimited ? (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.rateLimited) ||
|
|
168
|
-
const validationErrorMessage = validationServiceError !== null && validationServiceError !== void 0 && validationServiceError.rateLimited ? (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.rateLimited) ||
|
|
167
|
+
const lookupErrorMessage = lookupServiceError !== null && lookupServiceError !== void 0 && lookupServiceError.rateLimited ? (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.rateLimited) || "Too many requests. Please wait a moment and try again." : (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.lookupError) || "We could not look up that address right now.";
|
|
168
|
+
const validationErrorMessage = validationServiceError !== null && validationServiceError !== void 0 && validationServiceError.rateLimited ? (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.rateLimited) || "Too many requests. Please wait a moment and try again." : (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.validationError) || "We could not validate that address right now.";
|
|
169
169
|
(0, _react.useEffect)(() => {
|
|
170
170
|
if (!validationRequestId) {
|
|
171
171
|
return;
|
|
@@ -180,7 +180,7 @@ const SmartyIntlResults = ({
|
|
|
180
180
|
requireValidation: allowValidation
|
|
181
181
|
});
|
|
182
182
|
onSelect === null || onSelect === void 0 || onSelect({
|
|
183
|
-
type:
|
|
183
|
+
type: "validation-request",
|
|
184
184
|
address: formData,
|
|
185
185
|
status: currentStatus
|
|
186
186
|
});
|
|
@@ -222,7 +222,7 @@ const SmartyIntlResults = ({
|
|
|
222
222
|
return;
|
|
223
223
|
}
|
|
224
224
|
onSelect === null || onSelect === void 0 || onSelect({
|
|
225
|
-
type:
|
|
225
|
+
type: "lookup-error",
|
|
226
226
|
address: formData,
|
|
227
227
|
status: (0, _addressStatus.buildAddressStatus)({
|
|
228
228
|
countryCode,
|
|
@@ -233,8 +233,8 @@ const SmartyIntlResults = ({
|
|
|
233
233
|
requireValidation: allowValidation
|
|
234
234
|
}),
|
|
235
235
|
error: {
|
|
236
|
-
kind: lookupServiceError.rateLimited ?
|
|
237
|
-
source:
|
|
236
|
+
kind: lookupServiceError.rateLimited ? "rate-limited" : "api",
|
|
237
|
+
source: "autocomplete",
|
|
238
238
|
message: lookupErrorMessage
|
|
239
239
|
}
|
|
240
240
|
});
|
|
@@ -244,7 +244,7 @@ const SmartyIntlResults = ({
|
|
|
244
244
|
return;
|
|
245
245
|
}
|
|
246
246
|
onSelect === null || onSelect === void 0 || onSelect({
|
|
247
|
-
type:
|
|
247
|
+
type: "validation-error",
|
|
248
248
|
address: formData,
|
|
249
249
|
status: (0, _addressStatus.buildAddressStatus)({
|
|
250
250
|
countryCode,
|
|
@@ -255,8 +255,8 @@ const SmartyIntlResults = ({
|
|
|
255
255
|
requireValidation: allowValidation
|
|
256
256
|
}),
|
|
257
257
|
error: {
|
|
258
|
-
kind: validationServiceError.rateLimited ?
|
|
259
|
-
source:
|
|
258
|
+
kind: validationServiceError.rateLimited ? "rate-limited" : "api",
|
|
259
|
+
source: "validation",
|
|
260
260
|
message: validationErrorMessage
|
|
261
261
|
}
|
|
262
262
|
});
|
|
@@ -286,10 +286,10 @@ const SmartyIntlResults = ({
|
|
|
286
286
|
delete nextAddress.email;
|
|
287
287
|
return nextAddress;
|
|
288
288
|
};
|
|
289
|
-
const buildTrackedAddress = (address = {}, status =
|
|
289
|
+
const buildTrackedAddress = (address = {}, status = "unverified", source = null) => stripUnusedEmail((0, _addressVerification.withAddressVerification)(address, status, source));
|
|
290
290
|
const isAcceptableInitialValidationResult = validatedAddress => {
|
|
291
291
|
var _validatedAddress$val;
|
|
292
|
-
return [
|
|
292
|
+
return ["verified", "verified-sub-building-changed", "partial"].includes(validatedAddress === null || validatedAddress === void 0 || (_validatedAddress$val = validatedAddress.validationSummary) === null || _validatedAddress$val === void 0 ? void 0 : _validatedAddress$val.code);
|
|
293
293
|
};
|
|
294
294
|
(0, _useInitialAddressVerification.default)({
|
|
295
295
|
initialAddress,
|
|
@@ -308,12 +308,12 @@ const SmartyIntlResults = ({
|
|
|
308
308
|
if (suggestions.length === 1 && suggestions[0].isDetailed) {
|
|
309
309
|
setSelectedAddress(suggestions[0]);
|
|
310
310
|
setSelectedIntlAddressId(null);
|
|
311
|
-
setQuery(
|
|
311
|
+
setQuery("");
|
|
312
312
|
setCustomError(null);
|
|
313
313
|
} else if (suggestions.length === 0 && !loading) {
|
|
314
|
-
setCustomError(
|
|
314
|
+
setCustomError("Unable to retrieve address details. Please try another address or enter manually.");
|
|
315
315
|
setSelectedIntlAddressId(null);
|
|
316
|
-
setQuery(
|
|
316
|
+
setQuery("");
|
|
317
317
|
}
|
|
318
318
|
} else if (suggestions.length > 0 && !suggestions[0].isDetailed && !selectedAddress) {
|
|
319
319
|
setSelectedAddress(null);
|
|
@@ -327,7 +327,7 @@ const SmartyIntlResults = ({
|
|
|
327
327
|
}, [lookupValue, selectedAddress]);
|
|
328
328
|
(0, _react.useEffect)(() => {
|
|
329
329
|
var _suggestionButtons$;
|
|
330
|
-
const shouldShowValidationResults = allowValidation && showValidationSuggestions && validationSuggestions.length > 0 && !validationLoading && (!isAutocompleteMode || [
|
|
330
|
+
const shouldShowValidationResults = allowValidation && showValidationSuggestions && validationSuggestions.length > 0 && !validationLoading && (!isAutocompleteMode || ["map", "initial"].includes(validationTriggerSource));
|
|
331
331
|
if (!shouldShowValidationResults) {
|
|
332
332
|
return;
|
|
333
333
|
}
|
|
@@ -351,7 +351,7 @@ const SmartyIntlResults = ({
|
|
|
351
351
|
}
|
|
352
352
|
}, [validationTrigger, validationTriggerSource]);
|
|
353
353
|
(0, _react.useEffect)(() => {
|
|
354
|
-
if (validationTriggerSource ===
|
|
354
|
+
if (validationTriggerSource === "map" && validationLoading) {
|
|
355
355
|
mapValidationStartedRef.current = true;
|
|
356
356
|
}
|
|
357
357
|
if (validationLoading && ['autocomplete', 'map', 'initial', 'save'].includes(validationTriggerSource)) {
|
|
@@ -359,7 +359,7 @@ const SmartyIntlResults = ({
|
|
|
359
359
|
}
|
|
360
360
|
}, [validationLoading, validationTriggerSource]);
|
|
361
361
|
(0, _react.useEffect)(() => {
|
|
362
|
-
if (validationTriggerSource ===
|
|
362
|
+
if (validationTriggerSource === "map" && mapValidationStartedRef.current && showValidationSuggestions && !validationLoading && validationSuggestions.length === 0) {
|
|
363
363
|
setPendingMapOpen(false);
|
|
364
364
|
mapValidationStartedRef.current = false;
|
|
365
365
|
}
|
|
@@ -376,7 +376,7 @@ const SmartyIntlResults = ({
|
|
|
376
376
|
const suggestionsList = suggestionsListRef.current;
|
|
377
377
|
if ((suggestionsList === null || suggestionsList === void 0 ? void 0 : suggestionsList.contains(event.target)) === false) {
|
|
378
378
|
shouldSearchRef.current = false;
|
|
379
|
-
setQuery(
|
|
379
|
+
setQuery("");
|
|
380
380
|
setSelectedAddress(null);
|
|
381
381
|
setSelectedIntlAddressId(null);
|
|
382
382
|
setShowValidationSuggestions(false);
|
|
@@ -387,9 +387,9 @@ const SmartyIntlResults = ({
|
|
|
387
387
|
setHasPendingLookupDraft(false);
|
|
388
388
|
}
|
|
389
389
|
};
|
|
390
|
-
document.addEventListener(
|
|
390
|
+
document.addEventListener("pointerdown", handleDocumentMouseDown);
|
|
391
391
|
return () => {
|
|
392
|
-
document.removeEventListener(
|
|
392
|
+
document.removeEventListener("pointerdown", handleDocumentMouseDown);
|
|
393
393
|
};
|
|
394
394
|
}, [hasPendingLookupDraft, suggestions]);
|
|
395
395
|
(0, _react.useEffect)(() => {
|
|
@@ -403,14 +403,14 @@ const SmartyIntlResults = ({
|
|
|
403
403
|
}
|
|
404
404
|
setShowValidationSuggestions(false);
|
|
405
405
|
};
|
|
406
|
-
document.addEventListener(
|
|
406
|
+
document.addEventListener("pointerdown", handleDocumentPointerDown);
|
|
407
407
|
return () => {
|
|
408
|
-
document.removeEventListener(
|
|
408
|
+
document.removeEventListener("pointerdown", handleDocumentPointerDown);
|
|
409
409
|
};
|
|
410
410
|
}, [isAutocompleteMode, showValidationSuggestions, validationLoading, validationSuggestions]);
|
|
411
411
|
(0, _react.useEffect)(() => {
|
|
412
412
|
if (selectedAddress) {
|
|
413
|
-
const selectionKey = selectedAddress.address_id || `${selectedAddress.street ||
|
|
413
|
+
const selectionKey = selectedAddress.address_id || `${selectedAddress.street || ""}|${selectedAddress.locality || ""}|${selectedAddress.postal_code || ""}`;
|
|
414
414
|
if (appliedSelectionKeyRef.current === selectionKey) {
|
|
415
415
|
return;
|
|
416
416
|
}
|
|
@@ -421,7 +421,7 @@ const SmartyIntlResults = ({
|
|
|
421
421
|
...mapped,
|
|
422
422
|
email: formData.email
|
|
423
423
|
};
|
|
424
|
-
const normalizedFormData = buildTrackedAddress(updatedFormData,
|
|
424
|
+
const normalizedFormData = buildTrackedAddress(updatedFormData, "autocomplete", "smarty-intl");
|
|
425
425
|
setFormData(normalizedFormData);
|
|
426
426
|
setMapAddressLines([]);
|
|
427
427
|
lastCommittedAddressRef.current = normalizedFormData;
|
|
@@ -430,10 +430,10 @@ const SmartyIntlResults = ({
|
|
|
430
430
|
clearServiceErrors({
|
|
431
431
|
custom: true
|
|
432
432
|
});
|
|
433
|
-
const currentVerificationStatus =
|
|
433
|
+
const currentVerificationStatus = "autocomplete";
|
|
434
434
|
setVerificationStatus(currentVerificationStatus);
|
|
435
435
|
onSelect === null || onSelect === void 0 || onSelect({
|
|
436
|
-
type:
|
|
436
|
+
type: "autocomplete",
|
|
437
437
|
address: normalizedFormData,
|
|
438
438
|
status: (0, _addressStatus.buildAddressStatus)({
|
|
439
439
|
countryCode,
|
|
@@ -452,7 +452,7 @@ const SmartyIntlResults = ({
|
|
|
452
452
|
// Trigger validation instead of directly selecting.
|
|
453
453
|
// Keep suggestions visible in case multiple candidates are returned.
|
|
454
454
|
setShowValidationSuggestions(true);
|
|
455
|
-
setValidationTriggerSource(
|
|
455
|
+
setValidationTriggerSource("autocomplete");
|
|
456
456
|
setValidationTrigger(prev => prev + 1);
|
|
457
457
|
}
|
|
458
458
|
}
|
|
@@ -480,26 +480,26 @@ const SmartyIntlResults = ({
|
|
|
480
480
|
...stripGeocode(formData),
|
|
481
481
|
[lookupField]: value
|
|
482
482
|
});
|
|
483
|
-
setFormData(buildTrackedAddress(updatedFormData,
|
|
484
|
-
setVerificationStatus(
|
|
483
|
+
setFormData(buildTrackedAddress(updatedFormData, "unverified"));
|
|
484
|
+
setVerificationStatus("unverified");
|
|
485
485
|
};
|
|
486
486
|
const isFieldRequired = field => requiredFields.includes(field);
|
|
487
|
-
const isFieldBlank = field => String(formData[field] ||
|
|
487
|
+
const isFieldBlank = field => String(formData[field] || "").trim() === "";
|
|
488
488
|
const hasInvalidPostalCodeFormat = field => {
|
|
489
|
-
if (field !==
|
|
489
|
+
if (field !== "postalCode") {
|
|
490
490
|
return false;
|
|
491
491
|
}
|
|
492
|
-
const value = String(formData.postalCode ||
|
|
492
|
+
const value = String(formData.postalCode || "").trim();
|
|
493
493
|
if (!value || !resolvedAddressForm.postalCodeRegex) {
|
|
494
494
|
return false;
|
|
495
495
|
}
|
|
496
496
|
return !resolvedAddressForm.postalCodeRegex.test((0, _validators.normalizePostalCodeValue)(value));
|
|
497
497
|
};
|
|
498
498
|
const hasInvalidEmailFormat = field => {
|
|
499
|
-
if (field !==
|
|
499
|
+
if (field !== "email") {
|
|
500
500
|
return false;
|
|
501
501
|
}
|
|
502
|
-
const value = String(formData.email ||
|
|
502
|
+
const value = String(formData.email || "").trim();
|
|
503
503
|
if (!value) {
|
|
504
504
|
return false;
|
|
505
505
|
}
|
|
@@ -537,7 +537,7 @@ const SmartyIntlResults = ({
|
|
|
537
537
|
};
|
|
538
538
|
const getFieldErrorMessage = field => {
|
|
539
539
|
if (!shouldShowFieldError(field)) {
|
|
540
|
-
return
|
|
540
|
+
return "";
|
|
541
541
|
}
|
|
542
542
|
if (isFieldRequired(field) && isFieldBlank(field)) {
|
|
543
543
|
if (areLabelsLoading) {
|
|
@@ -548,10 +548,10 @@ const SmartyIntlResults = ({
|
|
|
548
548
|
return fieldDisplayLabel ? `${fieldDisplayLabel} ${(fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.fieldRequiredSuffix) || 'is required'}` : fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.fieldRequired;
|
|
549
549
|
}
|
|
550
550
|
if (hasInvalidPostalCodeFormat(field)) {
|
|
551
|
-
return areLabelsLoading ?
|
|
551
|
+
return areLabelsLoading ? "" : fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.invalidPostalCode;
|
|
552
552
|
}
|
|
553
553
|
if (hasInvalidEmailFormat(field)) {
|
|
554
|
-
return areLabelsLoading ?
|
|
554
|
+
return areLabelsLoading ? "" : fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.invalidEmail;
|
|
555
555
|
}
|
|
556
556
|
if (hasIllegalCharacters(field)) {
|
|
557
557
|
return areLabelsLoading ? '' : (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.illegalCharacters) || 'Contains invalid characters.';
|
|
@@ -572,11 +572,11 @@ const SmartyIntlResults = ({
|
|
|
572
572
|
custom: true
|
|
573
573
|
});
|
|
574
574
|
const requiredFieldsForVerification = (resolvedAddressForm === null || resolvedAddressForm === void 0 ? void 0 : resolvedAddressForm.requiredFields) || requiredFields;
|
|
575
|
-
const nextVerificationStatus = (0, _addressVerification.getManualEditVerificationStatus)(
|
|
576
|
-
const updatedFormData = (0, _addressVerification.withManualAddressVerificationEdit)(stripUnusedEmail({
|
|
575
|
+
const nextVerificationStatus = (0, _addressVerification.getManualEditVerificationStatus)(field, verificationStatus, lookupField, requiredFieldsForVerification);
|
|
576
|
+
const updatedFormData = (0, _addressVerification.withManualAddressVerificationEdit)(field, stripUnusedEmail({
|
|
577
577
|
...stripGeocode(formData),
|
|
578
578
|
[field]: normalizedValue
|
|
579
|
-
}),
|
|
579
|
+
}), nextVerificationStatus);
|
|
580
580
|
setFormData(updatedFormData);
|
|
581
581
|
setVerificationStatus(nextVerificationStatus);
|
|
582
582
|
if (fieldTimerRef.current) {
|
|
@@ -584,7 +584,7 @@ const SmartyIntlResults = ({
|
|
|
584
584
|
}
|
|
585
585
|
fieldTimerRef.current = setTimeout(() => {
|
|
586
586
|
const payload = {
|
|
587
|
-
type:
|
|
587
|
+
type: "field-change",
|
|
588
588
|
field,
|
|
589
589
|
value: normalizedValue,
|
|
590
590
|
address: updatedFormData,
|
|
@@ -597,7 +597,7 @@ const SmartyIntlResults = ({
|
|
|
597
597
|
requireValidation: allowValidation
|
|
598
598
|
})
|
|
599
599
|
};
|
|
600
|
-
if (hasEmailField && field ===
|
|
600
|
+
if (hasEmailField && field === "email" && value) {
|
|
601
601
|
payload.isValidEmail = (0, _validators.isValidEmail)(normalizedValue);
|
|
602
602
|
}
|
|
603
603
|
onSelect === null || onSelect === void 0 || onSelect(payload);
|
|
@@ -619,7 +619,7 @@ const SmartyIntlResults = ({
|
|
|
619
619
|
appliedSelectionKeyRef.current = null;
|
|
620
620
|
setSelectedIntlAddressId(null);
|
|
621
621
|
setSelectedAddress(address);
|
|
622
|
-
setQuery(
|
|
622
|
+
setQuery("");
|
|
623
623
|
}
|
|
624
624
|
};
|
|
625
625
|
const handleValidationSelect = validatedAddress => {
|
|
@@ -634,7 +634,7 @@ const SmartyIntlResults = ({
|
|
|
634
634
|
mapped: formattedMapped,
|
|
635
635
|
mapAddressLines: nextMapAddressLines
|
|
636
636
|
} = (0, _addressMapping.buildIntlConfiguredVerificationMapping)(validatedAddress, resolvedAddressForm);
|
|
637
|
-
let mapped = (0, _addressMapping.preserveBlankConfiguredMappings)(formattedMapped, formData, config,
|
|
637
|
+
let mapped = (0, _addressMapping.preserveBlankConfiguredMappings)(formattedMapped, formData, config, "verification");
|
|
638
638
|
|
|
639
639
|
// Preserve user-entered address2 if verification didn't return one
|
|
640
640
|
if (!mapped.address2 && formData.address2) {
|
|
@@ -643,7 +643,7 @@ const SmartyIntlResults = ({
|
|
|
643
643
|
|
|
644
644
|
// Apply address wrapping if enabled
|
|
645
645
|
if (resolvedAddressForm.wrapAddress1ToAddress2) {
|
|
646
|
-
const address1Field = config.find(f => f.field ===
|
|
646
|
+
const address1Field = config.find(f => f.field === "address1");
|
|
647
647
|
if (address1Field !== null && address1Field !== void 0 && address1Field.maxLength) {
|
|
648
648
|
const wrapped = (0, _addressWrapper.wrapAddress1ToAddress2)(mapped.address1, mapped.address2, address1Field.maxLength);
|
|
649
649
|
mapped.address1 = wrapped.address1;
|
|
@@ -659,12 +659,12 @@ const SmartyIntlResults = ({
|
|
|
659
659
|
};
|
|
660
660
|
const currentVerificationStatus = (_validatedAddress$ana => {
|
|
661
661
|
switch ((_validatedAddress$ana = validatedAddress.analysis) === null || _validatedAddress$ana === void 0 ? void 0 : _validatedAddress$ana.verification_status) {
|
|
662
|
-
case
|
|
663
|
-
return
|
|
664
|
-
case
|
|
665
|
-
return
|
|
662
|
+
case "Verified":
|
|
663
|
+
return "verified";
|
|
664
|
+
case "Partial":
|
|
665
|
+
return "partial";
|
|
666
666
|
default:
|
|
667
|
-
return
|
|
667
|
+
return "unverified";
|
|
668
668
|
}
|
|
669
669
|
})();
|
|
670
670
|
const normalizedFormData = buildTrackedAddress(updatedFormData, currentVerificationStatus, 'smarty-intl');
|
|
@@ -693,7 +693,7 @@ const SmartyIntlResults = ({
|
|
|
693
693
|
validationAttempted: true
|
|
694
694
|
});
|
|
695
695
|
onSelect === null || onSelect === void 0 || onSelect({
|
|
696
|
-
type:
|
|
696
|
+
type: "validation",
|
|
697
697
|
address: normalizedFormData,
|
|
698
698
|
verification: validatedAddress.analysis,
|
|
699
699
|
status: validationStatus
|
|
@@ -716,49 +716,49 @@ const SmartyIntlResults = ({
|
|
|
716
716
|
custom: false
|
|
717
717
|
});
|
|
718
718
|
setShowValidationSuggestions(true);
|
|
719
|
-
setValidationTriggerSource(
|
|
719
|
+
setValidationTriggerSource("manual");
|
|
720
720
|
setValidationTrigger(prev => prev + 1);
|
|
721
721
|
};
|
|
722
722
|
const getFieldKey = fieldConfig => fieldConfig.field;
|
|
723
|
-
const getSuggestionKey = suggestion => suggestion.address_id || [suggestion.displayText, suggestion.street, suggestion.address_text, suggestion.locality, suggestion.administrative_area, suggestion.postal_code, suggestion.entries].filter(value => value !== undefined && value !== null).join(
|
|
723
|
+
const getSuggestionKey = suggestion => suggestion.address_id || [suggestion.displayText, suggestion.street, suggestion.address_text, suggestion.locality, suggestion.administrative_area, suggestion.postal_code, suggestion.entries].filter(value => value !== undefined && value !== null).join("|");
|
|
724
724
|
const getValidationSuggestionKey = suggestion => {
|
|
725
725
|
var _suggestion$component, _suggestion$component2, _suggestion$component3, _suggestion$component4, _suggestion$component5;
|
|
726
|
-
return [suggestion.displayText, suggestion.address1, suggestion.address2, suggestion.address3, (_suggestion$component = suggestion.components) === null || _suggestion$component === void 0 ? void 0 : _suggestion$component.thoroughfare, (_suggestion$component2 = suggestion.components) === null || _suggestion$component2 === void 0 ? void 0 : _suggestion$component2.premise, (_suggestion$component3 = suggestion.components) === null || _suggestion$component3 === void 0 ? void 0 : _suggestion$component3.locality, (_suggestion$component4 = suggestion.components) === null || _suggestion$component4 === void 0 ? void 0 : _suggestion$component4.administrative_area, (_suggestion$component5 = suggestion.components) === null || _suggestion$component5 === void 0 ? void 0 : _suggestion$component5.postal_code].filter(value => value !== undefined && value !== null).join(
|
|
726
|
+
return [suggestion.displayText, suggestion.address1, suggestion.address2, suggestion.address3, (_suggestion$component = suggestion.components) === null || _suggestion$component === void 0 ? void 0 : _suggestion$component.thoroughfare, (_suggestion$component2 = suggestion.components) === null || _suggestion$component2 === void 0 ? void 0 : _suggestion$component2.premise, (_suggestion$component3 = suggestion.components) === null || _suggestion$component3 === void 0 ? void 0 : _suggestion$component3.locality, (_suggestion$component4 = suggestion.components) === null || _suggestion$component4 === void 0 ? void 0 : _suggestion$component4.administrative_area, (_suggestion$component5 = suggestion.components) === null || _suggestion$component5 === void 0 ? void 0 : _suggestion$component5.postal_code].filter(value => value !== undefined && value !== null).join("|");
|
|
727
727
|
};
|
|
728
728
|
const getIntlValidationSummaryTitle = suggestion => {
|
|
729
729
|
var _suggestion$validatio, _suggestion$validatio2, _suggestion$validatio3, _suggestion$validatio4, _suggestion$validatio5, _suggestion$validatio6, _suggestion$validatio7;
|
|
730
730
|
const code = (_suggestion$validatio = suggestion.validationSummary) === null || _suggestion$validatio === void 0 ? void 0 : _suggestion$validatio.code;
|
|
731
731
|
switch (code) {
|
|
732
|
-
case
|
|
733
|
-
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlVerifiedTitle) || ((_suggestion$validatio2 = suggestion.validationSummary) === null || _suggestion$validatio2 === void 0 ? void 0 : _suggestion$validatio2.title) ||
|
|
734
|
-
case
|
|
735
|
-
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlVerifiedSubBuildingChangedTitle) || ((_suggestion$validatio3 = suggestion.validationSummary) === null || _suggestion$validatio3 === void 0 ? void 0 : _suggestion$validatio3.title) ||
|
|
736
|
-
case
|
|
737
|
-
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlPartialTitle) || ((_suggestion$validatio4 = suggestion.validationSummary) === null || _suggestion$validatio4 === void 0 ? void 0 : _suggestion$validatio4.title) ||
|
|
738
|
-
case
|
|
739
|
-
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlAmbiguousTitle) || ((_suggestion$validatio5 = suggestion.validationSummary) === null || _suggestion$validatio5 === void 0 ? void 0 : _suggestion$validatio5.title) ||
|
|
740
|
-
case
|
|
741
|
-
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlNotVerifiedTitle) || ((_suggestion$validatio6 = suggestion.validationSummary) === null || _suggestion$validatio6 === void 0 ? void 0 : _suggestion$validatio6.title) ||
|
|
732
|
+
case "verified":
|
|
733
|
+
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlVerifiedTitle) || ((_suggestion$validatio2 = suggestion.validationSummary) === null || _suggestion$validatio2 === void 0 ? void 0 : _suggestion$validatio2.title) || "Verified";
|
|
734
|
+
case "verified-sub-building-changed":
|
|
735
|
+
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlVerifiedSubBuildingChangedTitle) || ((_suggestion$validatio3 = suggestion.validationSummary) === null || _suggestion$validatio3 === void 0 ? void 0 : _suggestion$validatio3.title) || "Verified with unit changes";
|
|
736
|
+
case "partial":
|
|
737
|
+
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlPartialTitle) || ((_suggestion$validatio4 = suggestion.validationSummary) === null || _suggestion$validatio4 === void 0 ? void 0 : _suggestion$validatio4.title) || "Partially verified";
|
|
738
|
+
case "ambiguous":
|
|
739
|
+
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlAmbiguousTitle) || ((_suggestion$validatio5 = suggestion.validationSummary) === null || _suggestion$validatio5 === void 0 ? void 0 : _suggestion$validatio5.title) || "Multiple matches found";
|
|
740
|
+
case "not-verified":
|
|
741
|
+
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlNotVerifiedTitle) || ((_suggestion$validatio6 = suggestion.validationSummary) === null || _suggestion$validatio6 === void 0 ? void 0 : _suggestion$validatio6.title) || "Not verified";
|
|
742
742
|
default:
|
|
743
|
-
return ((_suggestion$validatio7 = suggestion.validationSummary) === null || _suggestion$validatio7 === void 0 ? void 0 : _suggestion$validatio7.title) ||
|
|
743
|
+
return ((_suggestion$validatio7 = suggestion.validationSummary) === null || _suggestion$validatio7 === void 0 ? void 0 : _suggestion$validatio7.title) || "Unknown";
|
|
744
744
|
}
|
|
745
745
|
};
|
|
746
746
|
const getIntlValidationSummaryMessage = suggestion => {
|
|
747
747
|
var _suggestion$validatio8, _suggestion$validatio9, _suggestion$validatio0, _suggestion$validatio1, _suggestion$validatio10, _suggestion$validatio11, _suggestion$validatio12;
|
|
748
748
|
const code = (_suggestion$validatio8 = suggestion.validationSummary) === null || _suggestion$validatio8 === void 0 ? void 0 : _suggestion$validatio8.code;
|
|
749
749
|
switch (code) {
|
|
750
|
-
case
|
|
751
|
-
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlVerifiedMessage) || ((_suggestion$validatio9 = suggestion.validationSummary) === null || _suggestion$validatio9 === void 0 ? void 0 : _suggestion$validatio9.message) ||
|
|
752
|
-
case
|
|
753
|
-
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlVerifiedSubBuildingChangedMessage) || ((_suggestion$validatio0 = suggestion.validationSummary) === null || _suggestion$validatio0 === void 0 ? void 0 : _suggestion$validatio0.message) ||
|
|
754
|
-
case
|
|
755
|
-
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlPartialMessage) || ((_suggestion$validatio1 = suggestion.validationSummary) === null || _suggestion$validatio1 === void 0 ? void 0 : _suggestion$validatio1.message) ||
|
|
756
|
-
case
|
|
757
|
-
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlAmbiguousMessage) || ((_suggestion$validatio10 = suggestion.validationSummary) === null || _suggestion$validatio10 === void 0 ? void 0 : _suggestion$validatio10.message) ||
|
|
758
|
-
case
|
|
759
|
-
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlNotVerifiedMessage) || ((_suggestion$validatio11 = suggestion.validationSummary) === null || _suggestion$validatio11 === void 0 ? void 0 : _suggestion$validatio11.message) ||
|
|
750
|
+
case "verified":
|
|
751
|
+
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlVerifiedMessage) || ((_suggestion$validatio9 = suggestion.validationSummary) === null || _suggestion$validatio9 === void 0 ? void 0 : _suggestion$validatio9.message) || "";
|
|
752
|
+
case "verified-sub-building-changed":
|
|
753
|
+
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlVerifiedSubBuildingChangedMessage) || ((_suggestion$validatio0 = suggestion.validationSummary) === null || _suggestion$validatio0 === void 0 ? void 0 : _suggestion$validatio0.message) || "";
|
|
754
|
+
case "partial":
|
|
755
|
+
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlPartialMessage) || ((_suggestion$validatio1 = suggestion.validationSummary) === null || _suggestion$validatio1 === void 0 ? void 0 : _suggestion$validatio1.message) || "";
|
|
756
|
+
case "ambiguous":
|
|
757
|
+
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlAmbiguousMessage) || ((_suggestion$validatio10 = suggestion.validationSummary) === null || _suggestion$validatio10 === void 0 ? void 0 : _suggestion$validatio10.message) || "";
|
|
758
|
+
case "not-verified":
|
|
759
|
+
return (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.intlNotVerifiedMessage) || ((_suggestion$validatio11 = suggestion.validationSummary) === null || _suggestion$validatio11 === void 0 ? void 0 : _suggestion$validatio11.message) || "";
|
|
760
760
|
default:
|
|
761
|
-
return ((_suggestion$validatio12 = suggestion.validationSummary) === null || _suggestion$validatio12 === void 0 ? void 0 : _suggestion$validatio12.message) ||
|
|
761
|
+
return ((_suggestion$validatio12 = suggestion.validationSummary) === null || _suggestion$validatio12 === void 0 ? void 0 : _suggestion$validatio12.message) || "";
|
|
762
762
|
}
|
|
763
763
|
};
|
|
764
764
|
const handleOpenMap = () => {
|
|
@@ -777,7 +777,7 @@ const SmartyIntlResults = ({
|
|
|
777
777
|
mapValidationStartedRef.current = false;
|
|
778
778
|
setPendingMapOpen(true);
|
|
779
779
|
setShowValidationSuggestions(true);
|
|
780
|
-
setValidationTriggerSource(
|
|
780
|
+
setValidationTriggerSource("map");
|
|
781
781
|
setValidationTrigger(prev => prev + 1);
|
|
782
782
|
};
|
|
783
783
|
const renderLookupActions = () => /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
@@ -794,17 +794,17 @@ const SmartyIntlResults = ({
|
|
|
794
794
|
}), !isAutocompleteMode && allowValidation && /*#__PURE__*/(0, _jsxRuntime.jsx)(_foundationUiComponents.NsButton, {
|
|
795
795
|
type: "button",
|
|
796
796
|
onClick: handleValidate,
|
|
797
|
-
disabled: validationLoading || !String(formData[lookupField] ||
|
|
797
|
+
disabled: validationLoading || !String(formData[lookupField] || "").trim(),
|
|
798
798
|
variant: "contained",
|
|
799
799
|
color: "primary",
|
|
800
800
|
size: "small",
|
|
801
801
|
className: "ns-address-lookup__validate-button",
|
|
802
|
-
children: validationLoading ? (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.validatingAddress) ||
|
|
803
|
-
}), entryMode ===
|
|
802
|
+
children: validationLoading ? (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.validatingAddress) || "Validating..." : (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.validateAddress) || "Validate Address"
|
|
803
|
+
}), entryMode === "both" && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
804
804
|
type: "button",
|
|
805
805
|
onClick: handleModeSwitch,
|
|
806
806
|
className: "ns-address-lookup__toggle",
|
|
807
|
-
children: mode ===
|
|
807
|
+
children: mode === "autocomplete" ? fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.switchToManualEntry : fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels.switchToAutocomplete
|
|
808
808
|
})]
|
|
809
809
|
});
|
|
810
810
|
|
|
@@ -830,7 +830,7 @@ const SmartyIntlResults = ({
|
|
|
830
830
|
return Array.from(((_componentRef$current2 = componentRef.current) === null || _componentRef$current2 === void 0 ? void 0 : _componentRef$current2.querySelectorAll(LOOKUP_LIST_BUTTON_SELECTOR)) || []);
|
|
831
831
|
};
|
|
832
832
|
const handleLookupInputKeyDown = event => {
|
|
833
|
-
if (event.key !==
|
|
833
|
+
if (event.key !== "ArrowDown" && event.key !== "ArrowUp") {
|
|
834
834
|
return;
|
|
835
835
|
}
|
|
836
836
|
const suggestionButtons = getVisibleSuggestionButtons();
|
|
@@ -838,7 +838,7 @@ const SmartyIntlResults = ({
|
|
|
838
838
|
return;
|
|
839
839
|
}
|
|
840
840
|
event.preventDefault();
|
|
841
|
-
const targetButton = event.key ===
|
|
841
|
+
const targetButton = event.key === "ArrowUp" ? suggestionButtons[suggestionButtons.length - 1] : suggestionButtons[0];
|
|
842
842
|
targetButton === null || targetButton === void 0 || targetButton.focus();
|
|
843
843
|
};
|
|
844
844
|
const handleSuggestionButtonKeyDown = (event, index) => {
|
|
@@ -846,7 +846,7 @@ const SmartyIntlResults = ({
|
|
|
846
846
|
if (suggestionButtons.length === 0) {
|
|
847
847
|
return;
|
|
848
848
|
}
|
|
849
|
-
if (event.key ===
|
|
849
|
+
if (event.key === "ArrowDown") {
|
|
850
850
|
var _suggestionButtons;
|
|
851
851
|
event.preventDefault();
|
|
852
852
|
if (index === suggestionButtons.length - 1) {
|
|
@@ -857,7 +857,7 @@ const SmartyIntlResults = ({
|
|
|
857
857
|
(_suggestionButtons = suggestionButtons[index + 1]) === null || _suggestionButtons === void 0 || _suggestionButtons.focus();
|
|
858
858
|
return;
|
|
859
859
|
}
|
|
860
|
-
if (event.key ===
|
|
860
|
+
if (event.key === "ArrowUp") {
|
|
861
861
|
var _suggestionButtons2;
|
|
862
862
|
event.preventDefault();
|
|
863
863
|
if (index === 0) {
|
|
@@ -868,7 +868,7 @@ const SmartyIntlResults = ({
|
|
|
868
868
|
(_suggestionButtons2 = suggestionButtons[index - 1]) === null || _suggestionButtons2 === void 0 || _suggestionButtons2.focus();
|
|
869
869
|
return;
|
|
870
870
|
}
|
|
871
|
-
if (event.key ===
|
|
871
|
+
if (event.key === "Escape") {
|
|
872
872
|
var _getLookupInputElemen4;
|
|
873
873
|
event.preventDefault();
|
|
874
874
|
(_getLookupInputElemen4 = getLookupInputElement()) === null || _getLookupInputElemen4 === void 0 || _getLookupInputElemen4.focus();
|
|
@@ -878,8 +878,8 @@ const SmartyIntlResults = ({
|
|
|
878
878
|
if (readOnlyView) {
|
|
879
879
|
return null;
|
|
880
880
|
}
|
|
881
|
-
const shouldShowValidationResults = allowValidation && showValidationSuggestions && (!isAutocompleteMode || [
|
|
882
|
-
const shouldShowNoResults = shouldShowValidationResults && !validationLoading && validationSuggestions.length === 0 && !validationServiceError && (validationTriggerSource !==
|
|
881
|
+
const shouldShowValidationResults = allowValidation && showValidationSuggestions && (!isAutocompleteMode || ["map", "initial"].includes(validationTriggerSource));
|
|
882
|
+
const shouldShowNoResults = shouldShowValidationResults && !validationLoading && validationSuggestions.length === 0 && !validationServiceError && (validationTriggerSource !== "map" || mapValidationStartedRef.current);
|
|
883
883
|
if (!isLookupField) {
|
|
884
884
|
return null;
|
|
885
885
|
}
|
|
@@ -888,7 +888,7 @@ const SmartyIntlResults = ({
|
|
|
888
888
|
ref: suggestionsListRef,
|
|
889
889
|
className: "ns-address-lookup__list ns-address-lookup__list--suggestions",
|
|
890
890
|
children: suggestions.map((suggestion, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
891
|
-
className: [
|
|
891
|
+
className: ["ns-address-lookup__list-item", index < suggestions.length - 1 ? "ns-address-lookup__list-item--divided" : ""].filter(Boolean).join(" "),
|
|
892
892
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
893
893
|
type: "button",
|
|
894
894
|
onClick: () => handleSelect(suggestion),
|
|
@@ -905,7 +905,7 @@ const SmartyIntlResults = ({
|
|
|
905
905
|
children: validationSuggestions.map((suggestion, index) => {
|
|
906
906
|
var _suggestion$validatio13;
|
|
907
907
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
908
|
-
className: [
|
|
908
|
+
className: ["ns-address-lookup__list-item", ((_suggestion$validatio13 = suggestion.validationSummary) === null || _suggestion$validatio13 === void 0 ? void 0 : _suggestion$validatio13.code) === "not-verified" ? "ns-address-lookup__list-item--not-verified" : "", index < validationSuggestions.length - 1 ? "ns-address-lookup__list-item--divided" : ""].filter(Boolean).join(" "),
|
|
909
909
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
|
|
910
910
|
type: "button",
|
|
911
911
|
onClick: () => handleValidationSelect(suggestion),
|
|
@@ -938,14 +938,14 @@ const SmartyIntlResults = ({
|
|
|
938
938
|
if (['autocomplete', 'map', 'save'].includes(validationTriggerSource) && validationSuggestions.length === 1 && autoApplyValidationStartedRef.current) {
|
|
939
939
|
handleValidationSelect(validationSuggestions[0]);
|
|
940
940
|
}
|
|
941
|
-
if (validationTriggerSource ===
|
|
941
|
+
if (validationTriggerSource === "initial" && validationSuggestions.length === 1 && autoApplyValidationStartedRef.current && isAcceptableInitialValidationResult(validationSuggestions[0])) {
|
|
942
942
|
handleValidationSelect(validationSuggestions[0]);
|
|
943
943
|
}
|
|
944
944
|
}, [validationSuggestions, validationTriggerSource]);
|
|
945
945
|
const renderField = fieldConfig => {
|
|
946
946
|
const isLookupField = fieldConfig.field === lookupField;
|
|
947
947
|
const fieldId = getFieldId(fieldConfig.field);
|
|
948
|
-
const fieldLabel = areLabelsLoading ?
|
|
948
|
+
const fieldLabel = areLabelsLoading ? "" : (fieldLabels === null || fieldLabels === void 0 ? void 0 : fieldLabels[fieldConfig.field]) || fieldConfig.label;
|
|
949
949
|
const fieldError = getFieldErrorMessage(fieldConfig.field);
|
|
950
950
|
const isInvalid = hasVisibleFieldError(fieldConfig.field);
|
|
951
951
|
const isValid = (0, _fieldValidation.getIsFieldValid)({
|
|
@@ -957,8 +957,8 @@ const SmartyIntlResults = ({
|
|
|
957
957
|
});
|
|
958
958
|
const isReadOnly = readOnlyView || !fieldConfig.editable && !isLookupField && isAutocompleteMode;
|
|
959
959
|
const fieldWidth = fieldConfig.width === 'full' ? '100%' : fieldConfig.width === 'third' ? '33.333333%' : '50%';
|
|
960
|
-
const inputClassName = [
|
|
961
|
-
const labelRowClassName = [
|
|
960
|
+
const inputClassName = ["ns-address-lookup__input", isReadOnly ? "ns-address-lookup__input--readonly" : "", isInvalid ? "ns-address-lookup__input--invalid" : "", isLookupField && loading ? "ns-address-lookup__input--loading" : ""].filter(Boolean).join(" ");
|
|
961
|
+
const labelRowClassName = ["ns-address-lookup__label-row", isLookupField ? "" : "ns-address-lookup__label-row--field"].filter(Boolean).join(" ");
|
|
962
962
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
963
963
|
className: "ns-address-lookup__field",
|
|
964
964
|
style: {
|