@bigbinary/neeto-molecules 3.5.12 → 3.5.14
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/Insights.js +16 -15
- package/dist/Insights.js.map +1 -1
- package/dist/PhoneNumber.js +2 -2
- package/dist/SessionEnvironment.js +1 -1
- package/dist/cjs/Insights.js +17 -15
- package/dist/cjs/Insights.js.map +1 -1
- package/dist/cjs/PhoneNumber.js +1 -1
- package/dist/cjs/SessionEnvironment.js +1 -1
- package/dist/cjs/{phone-number-904b0a70.js → phone-number-b28bc9dd.js} +21 -6
- package/dist/cjs/{phone-number-904b0a70.js.map → phone-number-b28bc9dd.js.map} +1 -1
- package/dist/{phone-number-cf3e77d7.js → phone-number-1d33eea1.js} +23 -8
- package/dist/{phone-number-cf3e77d7.js.map → phone-number-1d33eea1.js.map} +1 -1
- package/package.json +1 -1
- package/src/translations/en.json +2 -2
- package/types/Insights.d.ts +1 -1
|
@@ -4,13 +4,13 @@ import { shallow } from 'zustand/shallow';
|
|
|
4
4
|
import { memo, useState, useEffect, forwardRef, useRef, useMemo, useCallback } from 'react';
|
|
5
5
|
import classnames from 'classnames';
|
|
6
6
|
import { getCountries, getCountryCallingCode, isValidPhoneNumber, parsePhoneNumber, formatIncompletePhoneNumber } from 'libphonenumber-js/min';
|
|
7
|
-
import { noop } from '@bigbinary/neeto-cist';
|
|
7
|
+
import { findBy, noop } from '@bigbinary/neeto-cist';
|
|
8
8
|
import Input from '@bigbinary/neetoui/Input';
|
|
9
9
|
import { useTranslation } from 'react-i18next';
|
|
10
10
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
11
11
|
import Select from '@bigbinary/neetoui/Select';
|
|
12
12
|
import { c as commonjsGlobal } from './_commonjsHelpers-1c8beb5f.js';
|
|
13
|
-
import { mergeLeft, assoc
|
|
13
|
+
import { mergeLeft, assoc } from 'ramda';
|
|
14
14
|
import Tooltip from '@bigbinary/neetoui/Tooltip';
|
|
15
15
|
import Typography from '@bigbinary/neetoui/Typography';
|
|
16
16
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -216,7 +216,14 @@ var getCursorPosition = function getCursorPosition(_ref) {
|
|
|
216
216
|
};
|
|
217
217
|
|
|
218
218
|
var useSetInitialCountry = function useSetInitialCountry(initialCountryCode, initialValue) {
|
|
219
|
-
var
|
|
219
|
+
var _useCountryCodeStore = useCountryCodeStore(function (store) {
|
|
220
|
+
return {
|
|
221
|
+
countryCode: store["countryCode"],
|
|
222
|
+
setCountryCode: store["setCountryCode"]
|
|
223
|
+
};
|
|
224
|
+
}, shallow),
|
|
225
|
+
countryCode = _useCountryCodeStore.countryCode,
|
|
226
|
+
setCountryCode = _useCountryCodeStore.setCountryCode;
|
|
220
227
|
var _getPhoneData = getPhoneData(initialValue),
|
|
221
228
|
countryCodeFromInitialValue = _getPhoneData.countryCode;
|
|
222
229
|
var isFetchLocationEnabled = !initialCountryCode && !countryCodeFromInitialValue;
|
|
@@ -227,15 +234,23 @@ var useSetInitialCountry = function useSetInitialCountry(initialCountryCode, ini
|
|
|
227
234
|
},
|
|
228
235
|
enabled: isFetchLocationEnabled
|
|
229
236
|
}),
|
|
230
|
-
data = _useQuery.data
|
|
237
|
+
data = _useQuery.data,
|
|
238
|
+
isLoading = _useQuery.isLoading;
|
|
231
239
|
useEffect(function () {
|
|
232
240
|
if (isFetchLocationEnabled) return;
|
|
233
241
|
setCountryCode(countryCodeFromInitialValue || initialCountryCode);
|
|
234
242
|
}, []);
|
|
235
243
|
useEffect(function () {
|
|
236
|
-
if (!
|
|
237
|
-
|
|
238
|
-
|
|
244
|
+
if (isLoading || !isFetchLocationEnabled) return;
|
|
245
|
+
var newCountryCode = findBy({
|
|
246
|
+
value: data === null || data === void 0 ? void 0 : data.countryCode
|
|
247
|
+
}, COUNTRY_PICKER_OPTIONS) ? data === null || data === void 0 ? void 0 : data.countryCode : countryCode || "US";
|
|
248
|
+
|
|
249
|
+
// Only update state if the new country code is different from the current one
|
|
250
|
+
if (newCountryCode !== countryCode) {
|
|
251
|
+
setCountryCode(newCountryCode);
|
|
252
|
+
}
|
|
253
|
+
}, [data, isLoading, isFetchLocationEnabled, countryCode]);
|
|
239
254
|
};
|
|
240
255
|
|
|
241
256
|
var _excluded = ["value", "onChange", "className", "error", "selectProps", "initialCountryCode"];
|
|
@@ -319,4 +334,4 @@ var css = "@import url(\"https://fonts.googleapis.com/css2?family=Noto+Color+Emo
|
|
|
319
334
|
n(css,{});
|
|
320
335
|
|
|
321
336
|
export { PhoneNumberInput as P, SingleValue$1 as S, getPhoneData as g, isPhoneNumberValid as i, validation as v };
|
|
322
|
-
//# sourceMappingURL=phone-number-
|
|
337
|
+
//# sourceMappingURL=phone-number-1d33eea1.js.map
|