@lmb-it/kitsconcerto-native 0.1.238 → 0.1.239
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/form/inputs/InputLocation/googlePlaces.cjs.map +1 -1
- package/form/inputs/InputLocation/googlePlaces.js.map +1 -1
- package/form/inputs/InputLocation/index.cjs +3 -3
- package/form/inputs/InputLocation/index.cjs.map +1 -1
- package/form/inputs/InputLocation/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"googlePlaces.cjs","sources":["../../../../../src/form/inputs/InputLocation/googlePlaces.ts"],"sourcesContent":["/**\n * Google Places transport — LEGACY Web Service endpoints (
|
|
1
|
+
{"version":3,"file":"googlePlaces.cjs","sources":["../../../../../src/form/inputs/InputLocation/googlePlaces.native.ts"],"sourcesContent":["/**\n * Google Places transport — LEGACY Web Service endpoints (NATIVE build).\n *\n * React Native has no CORS, so the legacy REST endpoints keep working there\n * unchanged. Browsers cannot call them (no ACAO header) — the web build\n * resolves `googlePlaces.web.ts` (Places API New) instead. Both files export\n * the SAME normalized contract (`googlePlaces.types.ts`) so `index.tsx` is\n * platform-agnostic. There is deliberately NO bare `googlePlaces.ts`: a bare\n * sibling wins module resolution over the platform-suffixed files and ships\n * the wrong transport (the v0.1.238 regression).\n */\nimport axios from \"axios\";\nimport type {ILocationDetailsResponse, ILocationResponse} from \"@lmb-it/kitsconcerto-types\";\nimport type {IGooglePlaceDetails, IGoogleSuggestion} from \"./googlePlaces.types\";\n\nconst GOOGLE_AUTOCOMPLETE =\n \"https://maps.googleapis.com/maps/api/place/autocomplete/json\";\nconst GOOGLE_DETAILS =\n \"https://maps.googleapis.com/maps/api/place/details/json\";\n\nexport type {IGoogleAddressComponent, IGooglePlaceDetails, IGoogleSuggestion} from \"./googlePlaces.types\";\n\nexport async function googleAutocomplete(\n query: string,\n apiKey: string,\n countryISO?: string\n): Promise<IGoogleSuggestion[]> {\n let url = `${GOOGLE_AUTOCOMPLETE}?input=${encodeURIComponent(query)}&key=${apiKey}`;\n if (countryISO) {\n url += `&components=country:${countryISO.toLowerCase().slice(0, 2)}`;\n }\n const {data} = await axios.get<ILocationResponse>(url);\n return (\n data.predictions?.map((p) => ({\n label: p.description,\n value: p.place_id,\n })) || []\n );\n}\n\nexport async function googleDetails(\n placeId: string,\n apiKey: string\n): Promise<IGooglePlaceDetails> {\n // Request address_components AND geometry so we get lat/lng too.\n const url = `${GOOGLE_DETAILS}?place_id=${placeId}&key=${apiKey}&fields=address_components,formatted_address,geometry`;\n const {data} = await axios.get<ILocationDetailsResponse>(url);\n return {\n formattedAddress: data.result.formatted_address,\n latitude: data.result.geometry?.location?.lat ?? null,\n longitude: data.result.geometry?.location?.lng ?? null,\n components: data.result.address_components.map((c) => ({\n type: c?.types?.[0],\n long: c.long_name,\n short: c.short_name,\n })),\n };\n}\n"],"names":[],"mappings":";;;;AAeA,MAAM,mBAAA,GACF,8DAAA;AACJ,MAAM,cAAA,GACF,yDAAA;AAIJ,eAAsB,kBAAA,CAClB,KAAA,EACA,MAAA,EACA,UAAA,EAC4B;AAC5B,EAAA,IAAI,GAAA,GAAM,GAAG,mBAAmB,CAAA,OAAA,EAAU,mBAAmB,KAAK,CAAC,QAAQ,MAAM,CAAA,CAAA;AACjF,EAAA,IAAI,UAAA,EAAY;AACZ,IAAA,GAAA,IAAO,uBAAuB,UAAA,CAAW,WAAA,GAAc,KAAA,CAAM,CAAA,EAAG,CAAC,CAAC,CAAA,CAAA;AAAA,EACtE;AACA,EAAA,MAAM,EAAC,IAAA,EAAI,GAAI,MAAM,KAAA,CAAM,IAAuB,GAAG,CAAA;AACrD,EAAA,OACI,IAAA,CAAK,WAAA,EAAa,GAAA,CAAI,CAAC,CAAA,MAAO;AAAA,IAC1B,OAAO,CAAA,CAAE,WAAA;AAAA,IACT,OAAO,CAAA,CAAE;AAAA,GACb,CAAE,KAAK,EAAC;AAEhB;AAEA,eAAsB,aAAA,CAClB,SACA,MAAA,EAC4B;AAE5B,EAAA,MAAM,MAAM,CAAA,EAAG,cAAc,CAAA,UAAA,EAAa,OAAO,QAAQ,MAAM,CAAA,qDAAA,CAAA;AAC/D,EAAA,MAAM,EAAC,IAAA,EAAI,GAAI,MAAM,KAAA,CAAM,IAA8B,GAAG,CAAA;AAC5D,EAAA,OAAO;AAAA,IACH,gBAAA,EAAkB,KAAK,MAAA,CAAO,iBAAA;AAAA,IAC9B,QAAA,EAAU,IAAA,CAAK,MAAA,CAAO,QAAA,EAAU,UAAU,GAAA,IAAO,IAAA;AAAA,IACjD,SAAA,EAAW,IAAA,CAAK,MAAA,CAAO,QAAA,EAAU,UAAU,GAAA,IAAO,IAAA;AAAA,IAClD,YAAY,IAAA,CAAK,MAAA,CAAO,kBAAA,CAAmB,GAAA,CAAI,CAAC,CAAA,MAAO;AAAA,MACnD,IAAA,EAAM,CAAA,EAAG,KAAA,GAAQ,CAAC,CAAA;AAAA,MAClB,MAAM,CAAA,CAAE,SAAA;AAAA,MACR,OAAO,CAAA,CAAE;AAAA,KACb,CAAE;AAAA,GACN;AACJ;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"googlePlaces.js","sources":["../../../../../src/form/inputs/InputLocation/googlePlaces.ts"],"sourcesContent":["/**\n * Google Places transport — LEGACY Web Service endpoints (
|
|
1
|
+
{"version":3,"file":"googlePlaces.js","sources":["../../../../../src/form/inputs/InputLocation/googlePlaces.native.ts"],"sourcesContent":["/**\n * Google Places transport — LEGACY Web Service endpoints (NATIVE build).\n *\n * React Native has no CORS, so the legacy REST endpoints keep working there\n * unchanged. Browsers cannot call them (no ACAO header) — the web build\n * resolves `googlePlaces.web.ts` (Places API New) instead. Both files export\n * the SAME normalized contract (`googlePlaces.types.ts`) so `index.tsx` is\n * platform-agnostic. There is deliberately NO bare `googlePlaces.ts`: a bare\n * sibling wins module resolution over the platform-suffixed files and ships\n * the wrong transport (the v0.1.238 regression).\n */\nimport axios from \"axios\";\nimport type {ILocationDetailsResponse, ILocationResponse} from \"@lmb-it/kitsconcerto-types\";\nimport type {IGooglePlaceDetails, IGoogleSuggestion} from \"./googlePlaces.types\";\n\nconst GOOGLE_AUTOCOMPLETE =\n \"https://maps.googleapis.com/maps/api/place/autocomplete/json\";\nconst GOOGLE_DETAILS =\n \"https://maps.googleapis.com/maps/api/place/details/json\";\n\nexport type {IGoogleAddressComponent, IGooglePlaceDetails, IGoogleSuggestion} from \"./googlePlaces.types\";\n\nexport async function googleAutocomplete(\n query: string,\n apiKey: string,\n countryISO?: string\n): Promise<IGoogleSuggestion[]> {\n let url = `${GOOGLE_AUTOCOMPLETE}?input=${encodeURIComponent(query)}&key=${apiKey}`;\n if (countryISO) {\n url += `&components=country:${countryISO.toLowerCase().slice(0, 2)}`;\n }\n const {data} = await axios.get<ILocationResponse>(url);\n return (\n data.predictions?.map((p) => ({\n label: p.description,\n value: p.place_id,\n })) || []\n );\n}\n\nexport async function googleDetails(\n placeId: string,\n apiKey: string\n): Promise<IGooglePlaceDetails> {\n // Request address_components AND geometry so we get lat/lng too.\n const url = `${GOOGLE_DETAILS}?place_id=${placeId}&key=${apiKey}&fields=address_components,formatted_address,geometry`;\n const {data} = await axios.get<ILocationDetailsResponse>(url);\n return {\n formattedAddress: data.result.formatted_address,\n latitude: data.result.geometry?.location?.lat ?? null,\n longitude: data.result.geometry?.location?.lng ?? null,\n components: data.result.address_components.map((c) => ({\n type: c?.types?.[0],\n long: c.long_name,\n short: c.short_name,\n })),\n };\n}\n"],"names":[],"mappings":";;AAeA,MAAM,mBAAA,GACF,8DAAA;AACJ,MAAM,cAAA,GACF,yDAAA;AAIJ,eAAsB,kBAAA,CAClB,KAAA,EACA,MAAA,EACA,UAAA,EAC4B;AAC5B,EAAA,IAAI,GAAA,GAAM,GAAG,mBAAmB,CAAA,OAAA,EAAU,mBAAmB,KAAK,CAAC,QAAQ,MAAM,CAAA,CAAA;AACjF,EAAA,IAAI,UAAA,EAAY;AACZ,IAAA,GAAA,IAAO,uBAAuB,UAAA,CAAW,WAAA,GAAc,KAAA,CAAM,CAAA,EAAG,CAAC,CAAC,CAAA,CAAA;AAAA,EACtE;AACA,EAAA,MAAM,EAAC,IAAA,EAAI,GAAI,MAAM,KAAA,CAAM,IAAuB,GAAG,CAAA;AACrD,EAAA,OACI,IAAA,CAAK,WAAA,EAAa,GAAA,CAAI,CAAC,CAAA,MAAO;AAAA,IAC1B,OAAO,CAAA,CAAE,WAAA;AAAA,IACT,OAAO,CAAA,CAAE;AAAA,GACb,CAAE,KAAK,EAAC;AAEhB;AAEA,eAAsB,aAAA,CAClB,SACA,MAAA,EAC4B;AAE5B,EAAA,MAAM,MAAM,CAAA,EAAG,cAAc,CAAA,UAAA,EAAa,OAAO,QAAQ,MAAM,CAAA,qDAAA,CAAA;AAC/D,EAAA,MAAM,EAAC,IAAA,EAAI,GAAI,MAAM,KAAA,CAAM,IAA8B,GAAG,CAAA;AAC5D,EAAA,OAAO;AAAA,IACH,gBAAA,EAAkB,KAAK,MAAA,CAAO,iBAAA;AAAA,IAC9B,QAAA,EAAU,IAAA,CAAK,MAAA,CAAO,QAAA,EAAU,UAAU,GAAA,IAAO,IAAA;AAAA,IACjD,SAAA,EAAW,IAAA,CAAK,MAAA,CAAO,QAAA,EAAU,UAAU,GAAA,IAAO,IAAA;AAAA,IAClD,YAAY,IAAA,CAAK,MAAA,CAAO,kBAAA,CAAmB,GAAA,CAAI,CAAC,CAAA,MAAO;AAAA,MACnD,IAAA,EAAM,CAAA,EAAG,KAAA,GAAQ,CAAC,CAAA;AAAA,MAClB,MAAM,CAAA,CAAE,SAAA;AAAA,MACR,OAAO,CAAA,CAAE;AAAA,KACb,CAAE;AAAA,GACN;AACJ;;;;"}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var Experian = require('./Experian.cjs');
|
|
8
|
-
var
|
|
8
|
+
var googlePlaces_native = require('./googlePlaces.cjs');
|
|
9
9
|
var SelectContext = require('../../selects/SelectContext.cjs');
|
|
10
10
|
require('../../../contexts/DialogContext.cjs');
|
|
11
11
|
|
|
@@ -41,7 +41,7 @@ const KitsInputLocation = ({
|
|
|
41
41
|
if (query.length < 4) return [];
|
|
42
42
|
try {
|
|
43
43
|
if (provider === "google") {
|
|
44
|
-
const mapped = await
|
|
44
|
+
const mapped = await googlePlaces_native.googleAutocomplete(query, api_key, countryISO);
|
|
45
45
|
setSuggestions(mapped);
|
|
46
46
|
return mapped;
|
|
47
47
|
} else {
|
|
@@ -71,7 +71,7 @@ const KitsInputLocation = ({
|
|
|
71
71
|
});
|
|
72
72
|
if (!onAddressClick || !placeId) return;
|
|
73
73
|
if (provider === "google") {
|
|
74
|
-
const details = await
|
|
74
|
+
const details = await googlePlaces_native.googleDetails(placeId, api_key);
|
|
75
75
|
const richAddress = {
|
|
76
76
|
formatted_address: details.formattedAddress,
|
|
77
77
|
place_id: placeId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../../src/form/inputs/InputLocation/index.tsx"],"sourcesContent":["import React, {useCallback, useMemo, useRef, useState} from \"react\";\nimport Experian from \"./Experian\";\nimport type {IKitsInputLocation, IRef} from \"@lmb-it/kitsconcerto-types\";\nimport {FormSelect} from \"../../../_compat\";\n// Platform-forked Google transport: legacy Web Service on native (no CORS
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../../src/form/inputs/InputLocation/index.tsx"],"sourcesContent":["import React, {useCallback, useMemo, useRef, useState} from \"react\";\nimport Experian from \"./Experian\";\nimport type {IKitsInputLocation, IRef} from \"@lmb-it/kitsconcerto-types\";\nimport {FormSelect} from \"../../../_compat\";\n// Platform-forked Google transport: legacy Web Service on native\n// (`googlePlaces.native.ts` — RN has no CORS), Places API (New) on web\n// (`googlePlaces.web.ts` — browsers block the legacy endpoints). Same\n// normalized contract on both sides (`googlePlaces.types.ts`), so the\n// Suggestion / IAddressFormat output is unchanged. There is deliberately NO\n// bare `googlePlaces.ts` — a bare sibling wins resolution over the platform\n// files and ships the wrong transport (the v0.1.238 regression).\nimport {googleAutocomplete, googleDetails} from \"./googlePlaces\";\n\ntype Suggestion = {\n label: string;\n value: string;\n format?: string;\n};\n\nconst KitsInputLocation = ({\n id,\n label,\n errors,\n invalid,\n value,\n hideError,\n onAddressClick,\n onChange,\n disabled,\n placeholder,\n countryISO = \"AUS\",\n helperText,\n provider,\n api_key,\n labelKey = \"label\",\n valueKey = \"value\",\n // list,\n ...rest\n }: IKitsInputLocation) => {\n if (!api_key) throw new Error(\"API KEY NOT PROVIDED\");\n\n const selectRef = useRef<IRef>(null);\n const [suggestions, setSuggestions] = useState<Suggestion[]>([]);\n\n const experian = useMemo(\n () => (provider !== \"google\" ? new Experian(api_key) : null),\n [provider, api_key]\n );\n\n const search = useCallback(\n async (query: string): Promise<Suggestion[]> => {\n if (query.length < 4) return [];\n\n try {\n if (provider === \"google\") {\n const mapped = await googleAutocomplete(query, api_key, countryISO);\n setSuggestions(mapped);\n return mapped;\n } else {\n const res = await experian?.searchAddress(query, countryISO);\n const mapped = res?.data?.result?.suggestions?.map((s: any) => ({\n label: s.text,\n value: s.global_address_key,\n format: s.format,\n })) || [];\n setSuggestions(mapped);\n return mapped;\n }\n } catch {\n setSuggestions([]);\n return [];\n }\n },\n [provider, api_key, countryISO, experian]\n );\n\n const onPickAddress = useCallback(\n async (event: any, rawItem?: any) => {\n // rawItem is the full suggestion { label, value } passed as second arg by the hook\n const selected = rawItem ?? event;\n\n if (!selected) return;\n\n const placeId = selected[valueKey];\n\n onChange?.({\n target: {value: selected[labelKey]},\n } as any);\n\n if (!onAddressClick || !placeId) return;\n\n if (provider === \"google\") {\n const details = await googleDetails(placeId, api_key);\n\n // Build rich address format: each component has a `long` and `short` value.\n const richAddress: Record<string, any> = {\n formatted_address: details.formattedAddress,\n place_id: placeId,\n latitude: details.latitude,\n longitude: details.longitude,\n };\n\n details.components.forEach((c) => {\n if (c.type && !(c.type in richAddress)) {\n richAddress[c.type] = {\n long: c.long,\n short: c.short,\n };\n }\n });\n\n onAddressClick(richAddress);\n } else {\n const res = await experian?.formatAddress(placeId);\n if (res?.data?.result) { // @ts-ignore\n onAddressClick(res.data.result);\n }\n }\n },\n [\n provider,\n api_key,\n valueKey,\n labelKey,\n onChange,\n onAddressClick,\n experian,\n ]\n );\n\n return (\n <FormSelect\n ref={selectRef}\n id={id}\n shape=\"autocomplete\"\n value={value}\n label={label}\n placeholder={placeholder}\n labelKey={labelKey}\n valueKey={valueKey}\n onChange={onPickAddress}\n isMultiple={false}\n forceSelection\n completeMethod={search}\n list={suggestions}\n helperText={helperText}\n hideError={hideError}\n disabled={disabled}\n invalid={invalid}\n errors={errors}\n {...rest}\n />\n );\n};\n\nexport default KitsInputLocation;\n"],"names":["useRef","useState","useMemo","Experian","useCallback","googleAutocomplete","googleDetails","jsx","FormSelect"],"mappings":";;;;;;;;;;;AAmBA,MAAM,oBAAoB,CAAC;AAAA,EACI,EAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;AAAA,EACA,SAAA;AAAA,EACA,cAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA,GAAa,KAAA;AAAA,EACb,UAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA,GAAW,OAAA;AAAA,EACX,QAAA,GAAW,OAAA;AAAA;AAAA,EAEX,GAAG;AACP,CAAA,KAA0B;AACjD,EAAA,IAAI,CAAC,OAAA,EAAS,MAAM,IAAI,MAAM,sBAAsB,CAAA;AAEpD,EAAA,MAAM,SAAA,GAAYA,aAAa,IAAI,CAAA;AACnC,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAIC,cAAA,CAAuB,EAAE,CAAA;AAE/D,EAAA,MAAM,QAAA,GA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,GACJ;AAEA,EAAA,uBACIC,cAAA;AAAA,IAACC,qBAAA;AAAA,IAAA;AAAA,MACG,GAAA,EAAK,SAAA;AAAA,MACL,EAAA;AAAA,MACA,KAAA,EAAM,cAAA;AAAA,MACN,KAAA;AAAA,MACA,KAAA;AAAA,MACA,WAAA;AAAA,MACA,QAAA;AAAA,MACA,QAAA;AAAA,MACA,QAAA,EAAU,aAAA;AAAA,MACV,UAAA,EAAY,KAAA;AAAA,MACZ,cAAA,EAAc,IAAA;AAAA,MACd,cAAA,EAAgB,MAAA;AAAA,MAChB,IAAA,EAAM,WAAA;AAAA,MACN,UAAA;AAAA,MACA,SAAA;AAAA,MACA,QAAA;AAAA,MACA,OAAA;AAAA,MACA,MAAA;AAAA,MACC,GAAG;AAAA;AAAA,GACR;AAER;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/form/inputs/InputLocation/index.tsx"],"sourcesContent":["import React, {useCallback, useMemo, useRef, useState} from \"react\";\nimport Experian from \"./Experian\";\nimport type {IKitsInputLocation, IRef} from \"@lmb-it/kitsconcerto-types\";\nimport {FormSelect} from \"../../../_compat\";\n// Platform-forked Google transport: legacy Web Service on native (no CORS
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/form/inputs/InputLocation/index.tsx"],"sourcesContent":["import React, {useCallback, useMemo, useRef, useState} from \"react\";\nimport Experian from \"./Experian\";\nimport type {IKitsInputLocation, IRef} from \"@lmb-it/kitsconcerto-types\";\nimport {FormSelect} from \"../../../_compat\";\n// Platform-forked Google transport: legacy Web Service on native\n// (`googlePlaces.native.ts` — RN has no CORS), Places API (New) on web\n// (`googlePlaces.web.ts` — browsers block the legacy endpoints). Same\n// normalized contract on both sides (`googlePlaces.types.ts`), so the\n// Suggestion / IAddressFormat output is unchanged. There is deliberately NO\n// bare `googlePlaces.ts` — a bare sibling wins resolution over the platform\n// files and ships the wrong transport (the v0.1.238 regression).\nimport {googleAutocomplete, googleDetails} from \"./googlePlaces\";\n\ntype Suggestion = {\n label: string;\n value: string;\n format?: string;\n};\n\nconst KitsInputLocation = ({\n id,\n label,\n errors,\n invalid,\n value,\n hideError,\n onAddressClick,\n onChange,\n disabled,\n placeholder,\n countryISO = \"AUS\",\n helperText,\n provider,\n api_key,\n labelKey = \"label\",\n valueKey = \"value\",\n // list,\n ...rest\n }: IKitsInputLocation) => {\n if (!api_key) throw new Error(\"API KEY NOT PROVIDED\");\n\n const selectRef = useRef<IRef>(null);\n const [suggestions, setSuggestions] = useState<Suggestion[]>([]);\n\n const experian = useMemo(\n () => (provider !== \"google\" ? new Experian(api_key) : null),\n [provider, api_key]\n );\n\n const search = useCallback(\n async (query: string): Promise<Suggestion[]> => {\n if (query.length < 4) return [];\n\n try {\n if (provider === \"google\") {\n const mapped = await googleAutocomplete(query, api_key, countryISO);\n setSuggestions(mapped);\n return mapped;\n } else {\n const res = await experian?.searchAddress(query, countryISO);\n const mapped = res?.data?.result?.suggestions?.map((s: any) => ({\n label: s.text,\n value: s.global_address_key,\n format: s.format,\n })) || [];\n setSuggestions(mapped);\n return mapped;\n }\n } catch {\n setSuggestions([]);\n return [];\n }\n },\n [provider, api_key, countryISO, experian]\n );\n\n const onPickAddress = useCallback(\n async (event: any, rawItem?: any) => {\n // rawItem is the full suggestion { label, value } passed as second arg by the hook\n const selected = rawItem ?? event;\n\n if (!selected) return;\n\n const placeId = selected[valueKey];\n\n onChange?.({\n target: {value: selected[labelKey]},\n } as any);\n\n if (!onAddressClick || !placeId) return;\n\n if (provider === \"google\") {\n const details = await googleDetails(placeId, api_key);\n\n // Build rich address format: each component has a `long` and `short` value.\n const richAddress: Record<string, any> = {\n formatted_address: details.formattedAddress,\n place_id: placeId,\n latitude: details.latitude,\n longitude: details.longitude,\n };\n\n details.components.forEach((c) => {\n if (c.type && !(c.type in richAddress)) {\n richAddress[c.type] = {\n long: c.long,\n short: c.short,\n };\n }\n });\n\n onAddressClick(richAddress);\n } else {\n const res = await experian?.formatAddress(placeId);\n if (res?.data?.result) { // @ts-ignore\n onAddressClick(res.data.result);\n }\n }\n },\n [\n provider,\n api_key,\n valueKey,\n labelKey,\n onChange,\n onAddressClick,\n experian,\n ]\n );\n\n return (\n <FormSelect\n ref={selectRef}\n id={id}\n shape=\"autocomplete\"\n value={value}\n label={label}\n placeholder={placeholder}\n labelKey={labelKey}\n valueKey={valueKey}\n onChange={onPickAddress}\n isMultiple={false}\n forceSelection\n completeMethod={search}\n list={suggestions}\n helperText={helperText}\n hideError={hideError}\n disabled={disabled}\n invalid={invalid}\n errors={errors}\n {...rest}\n />\n );\n};\n\nexport default KitsInputLocation;\n"],"names":[],"mappings":";;;;;;;AAmBA,MAAM,oBAAoB,CAAC;AAAA,EACI,EAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;AAAA,EACA,SAAA;AAAA,EACA,cAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA,GAAa,KAAA;AAAA,EACb,UAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA,GAAW,OAAA;AAAA,EACX,QAAA,GAAW,OAAA;AAAA;AAAA,EAEX,GAAG;AACP,CAAA,KAA0B;AACjD,EAAA,IAAI,CAAC,OAAA,EAAS,MAAM,IAAI,MAAM,sBAAsB,CAAA;AAEpD,EAAA,MAAM,SAAA,GAAY,OAAa,IAAI,CAAA;AACnC,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,QAAA,CAAuB,EAAE,CAAA;AAE/D,EAAA,MAAM,QAAA,GAAW,OAAA;AAAA,IACb,MAAO,QAAA,KAAa,QAAA,GAAW,IAAI,QAAA,CAAS,OAAO,CAAA,GAAI,IAAA;AAAA,IACvD,CAAC,UAAU,OAAO;AAAA,GACtB;AAEA,EAAA,MAAM,MAAA,GAAS,WAAA;AAAA,IACX,OAAO,KAAA,KAAyC;AAC5C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