@popsure/dirty-swan 0.66.28 → 0.66.29
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/cjs/index.js +4 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/downloadButton/index.test.d.ts +1 -0
- package/dist/cjs/lib/components/input/autoSuggestInput/index.test.d.ts +1 -0
- package/dist/esm/components/autocompleteAddress/index.js +2 -2
- package/dist/esm/components/autocompleteAddress/index.js.map +1 -1
- package/dist/esm/components/autocompleteAddress/index.test.js +21 -12
- package/dist/esm/components/autocompleteAddress/index.test.js.map +1 -1
- package/dist/esm/components/downloadButton/index.js +1 -1
- package/dist/esm/components/downloadButton/index.js.map +1 -1
- package/dist/esm/components/downloadButton/index.test.js +25 -0
- package/dist/esm/components/downloadButton/index.test.js.map +1 -0
- package/dist/esm/components/input/autoSuggestInput/index.js +1 -1
- package/dist/esm/components/input/autoSuggestInput/index.js.map +1 -1
- package/dist/esm/components/input/autoSuggestInput/index.test.js +24 -0
- package/dist/esm/components/input/autoSuggestInput/index.test.js.map +1 -0
- package/dist/esm/lib/components/downloadButton/index.test.d.ts +1 -0
- package/dist/esm/lib/components/input/autoSuggestInput/index.test.d.ts +1 -0
- package/package.json +1 -1
- package/src/lib/components/autocompleteAddress/index.test.tsx +17 -11
- package/src/lib/components/autocompleteAddress/index.tsx +7 -0
- package/src/lib/components/downloadButton/index.test.tsx +22 -0
- package/src/lib/components/downloadButton/index.tsx +1 -0
- package/src/lib/components/input/autoSuggestInput/index.test.tsx +22 -0
- package/src/lib/components/input/autoSuggestInput/index.tsx +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -185,8 +185,8 @@ var AutocompleteAddress = function (_a) {
|
|
|
185
185
|
};
|
|
186
186
|
return (jsxs(Fragment, { children: [jsxs("div", { className: classNames("wmx8 bg-neutral-600 ".concat(styles['map-container']), (_b = {},
|
|
187
187
|
_b[styles['map-container--hidden']] = place === null,
|
|
188
|
-
_b)), children: [jsx("div", { className: styles.map, id: "map", "aria-hidden": "true" }), isLoading && (jsx("div", { className: styles['loading-spinner'], children: jsx("div", { className: "ds-spinner ds-spinner__m" }) }))] }), jsx("div", { className: "wmx8", children: manualAddressEntry === false ? (jsxs("div", { style: { position: 'relative' }, children: [jsx(Input, { className: "w100", id: "autocomplete", "data-cy": "autocomplete", type: "text", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.manualAddressEntry) || 'Search for address', ref: autocompleteElement, disabled: hasLoadedGoogleAPI === false }, "autocomplete-search"), hasLoadedGoogleAPI === false && (jsx("div", { "data-cy": "google-api-loader", className: styles['loading-spinner'], children: jsx("div", { className: "ds-spinner ds-spinner__m" }) }))] })) : (jsxs(Fragment, { children: [jsxs("div", { className: "d-flex c-gap16 ".concat(styles['input-line']), children: [jsx(Input, __assign({ className: "w100", "data-cy": "autocomplete", type: "text", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.street) || 'Street', value: (address === null || address === void 0 ? void 0 : address.street) || '', onChange: onManualAddressChange(), name: "street" }, inputProps === null || inputProps === void 0 ? void 0 : inputProps.street), "autocomplete-street"), jsx(Input, __assign({ className: "wmx2 ".concat(styles['house-number-input']), "data-cy": "autocomplete-house-number", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.houseNumber) || 'House number', value: (address === null || address === void 0 ? void 0 : address.houseNumber) || '', name: "houseNumber", onChange: onManualAddressChange() }, inputProps === null || inputProps === void 0 ? void 0 : inputProps.houseNumber), "autocomplete-house-number")] }), jsx(Input, __assign({ className: "mt16", "data-cy": "autocomplete-additional-info", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.additionalInformation) ||
|
|
189
|
-
'Additional information (C/O, apartment, etc.)', value: (address === null || address === void 0 ? void 0 : address.additionalInformation) || '', name: "additionalInformation", onChange: onManualAddressChange({ updatePlace: false }) }, inputProps === null || inputProps === void 0 ? void 0 : inputProps.additionalInformation), "autocomplete-additional-info"), jsxs("div", { className: "d-flex mt16 c-gap16 ".concat(styles['input-line']), children: [jsx(Input, __assign({ className: "w100", "data-cy": "autocomplete-postcode", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.postcode) || 'Postcode', value: (address === null || address === void 0 ? void 0 : address.postcode) || '', name: "postcode", onChange: onManualAddressChange() }, inputProps === null || inputProps === void 0 ? void 0 : inputProps.postcode), "autocomplete-postcode"), jsx(Input, __assign({ className: "w100", "data-cy": "autocomplete-city", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.city) || 'City', value: (address === null || address === void 0 ? void 0 : address.city) || '', name: "city", onChange: onManualAddressChange() }, inputProps === null || inputProps === void 0 ? void 0 : inputProps.city), "autocomplete-city")] })] })) }), manualAddressEntry === false && (jsxs("div", { className: "p-p mt8", children: [(manualAddressEntryTexts === null || manualAddressEntryTexts === void 0 ? void 0 : manualAddressEntryTexts.preText) || 'Or ', jsx("button", { className: 'p-a p-p fw-bold c-pointer bg-transparent', onClick: handleEnterAddressManually, type: "button", children: (manualAddressEntryTexts === null || manualAddressEntryTexts === void 0 ? void 0 : manualAddressEntryTexts.cta) || 'enter address manually' })] }))] }));
|
|
188
|
+
_b)), children: [jsx("div", { className: styles.map, id: "map", "aria-hidden": "true" }), isLoading && (jsx("div", { className: styles['loading-spinner'], children: jsx("div", { className: "ds-spinner ds-spinner__m" }) }))] }), jsx("div", { className: "wmx8", children: manualAddressEntry === false ? (jsxs("div", { style: { position: 'relative' }, children: [jsx(Input, { className: "w100", id: "autocomplete", "data-cy": "autocomplete", "data-testid": "autocomplete", type: "text", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.manualAddressEntry) || 'Search for address', ref: autocompleteElement, disabled: hasLoadedGoogleAPI === false }, "autocomplete-search"), hasLoadedGoogleAPI === false && (jsx("div", { "data-cy": "google-api-loader", "data-testid": "google-api-loader", className: styles['loading-spinner'], children: jsx("div", { className: "ds-spinner ds-spinner__m" }) }))] })) : (jsxs(Fragment, { children: [jsxs("div", { className: "d-flex c-gap16 ".concat(styles['input-line']), children: [jsx(Input, __assign({ className: "w100", "data-cy": "autocomplete", "data-testid": "autocomplete", type: "text", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.street) || 'Street', value: (address === null || address === void 0 ? void 0 : address.street) || '', onChange: onManualAddressChange(), name: "street" }, inputProps === null || inputProps === void 0 ? void 0 : inputProps.street), "autocomplete-street"), jsx(Input, __assign({ className: "wmx2 ".concat(styles['house-number-input']), "data-cy": "autocomplete-house-number", "data-testid": "autocomplete-house-number", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.houseNumber) || 'House number', value: (address === null || address === void 0 ? void 0 : address.houseNumber) || '', name: "houseNumber", onChange: onManualAddressChange() }, inputProps === null || inputProps === void 0 ? void 0 : inputProps.houseNumber), "autocomplete-house-number")] }), jsx(Input, __assign({ className: "mt16", "data-cy": "autocomplete-additional-info", "data-testid": "autocomplete-additional-info", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.additionalInformation) ||
|
|
189
|
+
'Additional information (C/O, apartment, etc.)', value: (address === null || address === void 0 ? void 0 : address.additionalInformation) || '', name: "additionalInformation", onChange: onManualAddressChange({ updatePlace: false }) }, inputProps === null || inputProps === void 0 ? void 0 : inputProps.additionalInformation), "autocomplete-additional-info"), jsxs("div", { className: "d-flex mt16 c-gap16 ".concat(styles['input-line']), children: [jsx(Input, __assign({ className: "w100", "data-cy": "autocomplete-postcode", "data-testid": "autocomplete-postcode", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.postcode) || 'Postcode', value: (address === null || address === void 0 ? void 0 : address.postcode) || '', name: "postcode", onChange: onManualAddressChange() }, inputProps === null || inputProps === void 0 ? void 0 : inputProps.postcode), "autocomplete-postcode"), jsx(Input, __assign({ className: "w100", "data-cy": "autocomplete-city", "data-testid": "autocomplete-city", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.city) || 'City', value: (address === null || address === void 0 ? void 0 : address.city) || '', name: "city", onChange: onManualAddressChange() }, inputProps === null || inputProps === void 0 ? void 0 : inputProps.city), "autocomplete-city")] })] })) }), manualAddressEntry === false && (jsxs("div", { className: "p-p mt8", children: [(manualAddressEntryTexts === null || manualAddressEntryTexts === void 0 ? void 0 : manualAddressEntryTexts.preText) || 'Or ', jsx("button", { className: 'p-a p-p fw-bold c-pointer bg-transparent', onClick: handleEnterAddressManually, type: "button", children: (manualAddressEntryTexts === null || manualAddressEntryTexts === void 0 ? void 0 : manualAddressEntryTexts.cta) || 'enter address manually' })] }))] }));
|
|
190
190
|
};
|
|
191
191
|
|
|
192
192
|
export { AutocompleteAddress };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/lib/components/autocompleteAddress/util/index.ts","../../../../../src/lib/components/autocompleteAddress/index.tsx"],"sourcesContent":["import {\n Address,\n countryNameFromAlphaCode,\n Alpha2CountryCode,\n} from '@popsure/public-models';\n\nexport const geocoderAddressComponentToPartialAddress = (\n input: google.maps.GeocoderAddressComponent[]\n): Partial<Address> => {\n interface MappedType {\n key: keyof Address;\n value: 'long_name' | 'short_name';\n }\n\n const mapping: {\n route: MappedType;\n street_number: MappedType;\n postal_code: MappedType;\n locality: MappedType;\n country: MappedType;\n } = {\n route: {\n key: 'street',\n value: 'long_name',\n },\n street_number: {\n key: 'houseNumber',\n value: 'long_name',\n },\n postal_code: {\n key: 'postcode',\n value: 'long_name',\n },\n locality: {\n key: 'city',\n value: 'long_name',\n },\n country: {\n key: 'country',\n value: 'short_name',\n },\n };\n\n const toReturn: Partial<Address> = {};\n input.forEach((value) => {\n const type = value.types[0] as keyof typeof mapping;\n const mappedValue = mapping[type];\n if (mappedValue) {\n const isPostalCodePrefix = value.types.includes(\n 'postal_code_prefix' as string\n );\n if (mappedValue.key === 'postcode' && isPostalCodePrefix) {\n return;\n }\n toReturn[mappedValue.key] = value[mappedValue.value];\n }\n });\n\n return toReturn;\n};\n\nexport const inlineAddress = (address: Address) =>\n `${address.street} ${address.houseNumber}, ${\n address.city\n }, ${countryNameFromAlphaCode(address.country as Alpha2CountryCode)}`;\n","import { ChangeEvent, useCallback, useEffect, useRef, useState } from 'react';\nimport classNames from 'classnames';\nimport debounce from 'lodash.debounce';\nimport { Input } from '../input';\nimport {\n Address,\n Alpha2CountryCode,\n countryNameFromAlphaCode,\n} from '@popsure/public-models';\n\nimport { geocoderAddressComponentToPartialAddress } from './util';\n\nimport styles from './style.module.scss';\n\nconst GERMANY_LAT_LNG = { lat: 51.54317, lng: 10.3181503 };\n\nconst GERMANY_ALPHA_CODE = 'DE';\n\nconst MAP_CONFIG_OBJ = {\n zoom: 6,\n center: GERMANY_LAT_LNG,\n fullscreenControl: false,\n mapTypeControl: false,\n panControl: false,\n zoomControl: false,\n streetViewControl: false,\n scrollwheel: false,\n scaleControl: false,\n rotateControl: false,\n draggable: false,\n};\n\nconst loadGoogleMapsApiDynamically = (callback: () => void, apiKey: string) => {\n const existingScript = document.getElementById('googleMapsImportScript');\n\n if (existingScript) {\n return;\n }\n\n const googleMapImportScript = document.createElement('script');\n googleMapImportScript.id = 'googleMapsImportScript';\n googleMapImportScript.type = 'text/javascript';\n googleMapImportScript.src = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=places`;\n document.head.appendChild(googleMapImportScript);\n\n googleMapImportScript.onload = () => {\n callback();\n };\n};\n\nexport interface AutocompleteAddressProps {\n apiKey: string;\n address?: Partial<Address>;\n onAddressChange: (address: Partial<Address>) => void;\n inputProps?: {\n street?: {\n name?: string;\n };\n houseNumber?: {\n name?: string;\n };\n additionalInformation?: {\n name?: string;\n };\n postcode?: {\n name?: string;\n };\n city?: {\n name?: string;\n };\n };\n placeholders?: {\n manualAddressEntry?: string;\n street?: string;\n houseNumber?: string;\n additionalInformation?: string;\n postcode?: string;\n city?: string;\n };\n manualAddressEntryTexts?: {\n preText?: string;\n cta?: string;\n };\n countryCode?: string;\n}\n\nconst AutocompleteAddress = ({\n apiKey,\n address: initialAddress,\n onAddressChange,\n placeholders,\n manualAddressEntryTexts,\n inputProps,\n countryCode = GERMANY_ALPHA_CODE\n}: AutocompleteAddressProps) => {\n const [manualAddressEntry, setManualAddressEntry] = useState(false);\n const [isLoading, setIsLoading] = useState(false);\n const autocomplete = useRef<google.maps.places.Autocomplete | null>(null);\n const autocompleteElement = useRef<HTMLInputElement | null>(null);\n const map = useRef<google.maps.Map | null>(null);\n const marker = useRef<google.maps.Marker | null>(null);\n const [address, setAddress] = useState(initialAddress);\n const [hasLoadedGoogleAPI, setHasLoadedGoogleAPI] = useState(\n window.google?.maps !== undefined\n );\n\n loadGoogleMapsApiDynamically(() => {\n setHasLoadedGoogleAPI(true);\n }, apiKey);\n\n const [place, setPlace] = useState<google.maps.places.PlaceResult | null>(\n null\n );\n\n useEffect(() => {\n if (address) {\n if (autocompleteElement.current && address.street) {\n autocompleteElement.current.value = address.street;\n }\n\n handleEnterAddressManually();\n }\n }, [address, onAddressChange, hasLoadedGoogleAPI]);\n\n useEffect(() => {\n if (!hasLoadedGoogleAPI) {\n return;\n }\n\n const reference = document.getElementById(\n 'autocomplete'\n ) as HTMLInputElement;\n\n autocomplete.current = new google.maps.places.Autocomplete(reference, {\n types: ['address'],\n componentRestrictions: { country: countryCode },\n });\n\n autocomplete.current.addListener('place_changed', onPlaceChanged);\n\n map.current = new google.maps.Map(\n document.getElementById('map')!,\n MAP_CONFIG_OBJ\n );\n\n import('./mapStyle').then(({ style }) => {\n map.current?.mapTypes.set('styled_map', style);\n map.current?.setMapTypeId('styled_map');\n });\n\n marker.current = new google.maps.Marker({\n map: map.current,\n });\n\n setPlaceFromAddress(address);\n }, [hasLoadedGoogleAPI, countryCode]); // eslint-disable-line\n\n const onPlaceChanged = (\n newPlace:\n | google.maps.places.PlaceResult\n | undefined = autocomplete.current?.getPlace(),\n updateAddress: boolean = true\n ) => {\n if (newPlace?.geometry?.location) {\n const geocoderAddress = geocoderAddressComponentToPartialAddress(\n newPlace.address_components!\n );\n\n setPlace(newPlace);\n if (updateAddress) {\n setAddress((oldValue) => ({\n ...geocoderAddress,\n additionalInformation: oldValue?.additionalInformation,\n }));\n onAddressChange?.(geocoderAddress);\n }\n\n map.current?.panTo(newPlace.geometry.location);\n map.current?.setZoom(15);\n\n marker.current?.setPosition(newPlace.geometry.location);\n }\n };\n\n const setPlaceFromAddress = useCallback(\n (address: Partial<Address> | undefined) => {\n if (!map.current) {\n return;\n }\n\n if (address) {\n const service = new google.maps.places.PlacesService(map.current);\n const query = `${address.street ?? ''} ${address.houseNumber ?? ''}, ${\n address.city ?? ''\n }, ${\n address.country\n ? countryNameFromAlphaCode(address.country as Alpha2CountryCode)\n : ''\n }`;\n setIsLoading(true);\n service.findPlaceFromQuery(\n {\n fields: ['place_id'],\n query,\n },\n (results) => {\n const firstResult = results && results[0];\n if (firstResult && firstResult.place_id) {\n service.getDetails(\n { placeId: firstResult.place_id },\n (newPlace) => {\n onPlaceChanged(newPlace ?? undefined, false);\n }\n );\n }\n setIsLoading(false);\n }\n );\n }\n },\n []\n );\n\n const debouncedSetPlace = debounce(setPlaceFromAddress, 2000);\n\n const handleEnterAddressManually = () => {\n setManualAddressEntry(true);\n };\n\n const onManualAddressChange =\n ({ updatePlace } = { updatePlace: true }) =>\n (e: ChangeEvent<HTMLInputElement>) => {\n const newAddress = {\n ...address,\n [e.target.name]: e.target.value,\n country: countryCode,\n };\n setAddress(newAddress);\n onAddressChange(newAddress);\n\n if (updatePlace) {\n debouncedSetPlace(newAddress);\n }\n };\n\n return (\n <>\n <div\n className={classNames(`wmx8 bg-neutral-600 ${styles['map-container']}`, {\n [styles['map-container--hidden']]: place === null,\n })}\n >\n <div className={styles.map} id=\"map\" aria-hidden=\"true\" />\n {isLoading && (\n <div className={styles['loading-spinner']}>\n <div className=\"ds-spinner ds-spinner__m\" />\n </div>\n )}\n </div>\n <div className={`wmx8`}>\n {manualAddressEntry === false ? (\n <div style={{ position: 'relative' }}>\n <Input\n className=\"w100\"\n id=\"autocomplete\"\n key=\"autocomplete-search\"\n data-cy=\"autocomplete\"\n type=\"text\"\n placeholder={\n placeholders?.manualAddressEntry || 'Search for address'\n }\n ref={autocompleteElement}\n disabled={hasLoadedGoogleAPI === false}\n />\n {hasLoadedGoogleAPI === false && (\n <div\n data-cy=\"google-api-loader\"\n className={styles['loading-spinner']}\n >\n <div className=\"ds-spinner ds-spinner__m\" />\n </div>\n )}\n </div>\n ) : (\n <>\n <div className={`d-flex c-gap16 ${styles['input-line']}`}>\n <Input\n className=\"w100\"\n data-cy=\"autocomplete\"\n key=\"autocomplete-street\"\n type=\"text\"\n placeholder={placeholders?.street || 'Street'}\n value={address?.street || ''}\n onChange={onManualAddressChange()}\n name=\"street\"\n {...inputProps?.street}\n />\n <Input\n className={`wmx2 ${styles['house-number-input']}`}\n data-cy=\"autocomplete-house-number\"\n key=\"autocomplete-house-number\"\n placeholder={placeholders?.houseNumber || 'House number'}\n value={address?.houseNumber || ''}\n name=\"houseNumber\"\n onChange={onManualAddressChange()}\n {...inputProps?.houseNumber}\n />\n </div>\n <Input\n className=\"mt16\"\n data-cy=\"autocomplete-additional-info\"\n key=\"autocomplete-additional-info\"\n placeholder={\n placeholders?.additionalInformation ||\n 'Additional information (C/O, apartment, etc.)'\n }\n value={address?.additionalInformation || ''}\n name=\"additionalInformation\"\n onChange={onManualAddressChange({ updatePlace: false })}\n {...inputProps?.additionalInformation}\n />\n <div className={`d-flex mt16 c-gap16 ${styles['input-line']}`}>\n <Input\n className=\"w100\"\n data-cy=\"autocomplete-postcode\"\n key=\"autocomplete-postcode\"\n placeholder={placeholders?.postcode || 'Postcode'}\n value={address?.postcode || ''}\n name=\"postcode\"\n onChange={onManualAddressChange()}\n {...inputProps?.postcode}\n />\n <Input\n className=\"w100\"\n data-cy=\"autocomplete-city\"\n key=\"autocomplete-city\"\n placeholder={placeholders?.city || 'City'}\n value={address?.city || ''}\n name=\"city\"\n onChange={onManualAddressChange()}\n {...inputProps?.city}\n />\n </div>\n </>\n )}\n </div>\n {manualAddressEntry === false && (\n <div className=\"p-p mt8\">\n {manualAddressEntryTexts?.preText || 'Or '}\n <button\n className={'p-a p-p fw-bold c-pointer bg-transparent'}\n onClick={handleEnterAddressManually}\n type=\"button\"\n >\n {manualAddressEntryTexts?.cta || 'enter address manually'}\n </button>\n </div>\n )}\n </>\n );\n};\n\nexport { AutocompleteAddress };\n"],"names":["countryNameFromAlphaCode","_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;;;;AAMO,IAAM,wCAAwC,GAAG,UACtD,KAA6C,EAAA;AAO7C,IAAA,IAAM,OAAO,GAMT;AACF,QAAA,KAAK,EAAE;AACL,YAAA,GAAG,EAAE,QAAQ;AACb,YAAA,KAAK,EAAE,WAAW;AACnB,SAAA;AACD,QAAA,aAAa,EAAE;AACb,YAAA,GAAG,EAAE,aAAa;AAClB,YAAA,KAAK,EAAE,WAAW;AACnB,SAAA;AACD,QAAA,WAAW,EAAE;AACX,YAAA,GAAG,EAAE,UAAU;AACf,YAAA,KAAK,EAAE,WAAW;AACnB,SAAA;AACD,QAAA,QAAQ,EAAE;AACR,YAAA,GAAG,EAAE,MAAM;AACX,YAAA,KAAK,EAAE,WAAW;AACnB,SAAA;AACD,QAAA,OAAO,EAAE;AACP,YAAA,GAAG,EAAE,SAAS;AACd,YAAA,KAAK,EAAE,YAAY;AACpB,SAAA;KACF;IAED,IAAM,QAAQ,GAAqB,EAAE;AACrC,IAAA,KAAK,CAAC,OAAO,CAAC,UAAC,KAAK,EAAA;QAClB,IAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAyB;AACnD,QAAA,IAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;QACjC,IAAI,WAAW,EAAE;YACf,IAAM,kBAAkB,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,CAC7C,oBAA8B,CAC/B;YACD,IAAI,WAAW,CAAC,GAAG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BAAuB,KAAA,MAAA,GAAA,MAAA,GAAvB,uBAAuB,CAAE,GAAG,KAAI,wBAAwB,GAClD,CAAA,EAAA,CACL,CACP,CAAA,EAAA,CACA;AAEP;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/lib/components/autocompleteAddress/util/index.ts","../../../../../src/lib/components/autocompleteAddress/index.tsx"],"sourcesContent":["import {\n Address,\n countryNameFromAlphaCode,\n Alpha2CountryCode,\n} from '@popsure/public-models';\n\nexport const geocoderAddressComponentToPartialAddress = (\n input: google.maps.GeocoderAddressComponent[]\n): Partial<Address> => {\n interface MappedType {\n key: keyof Address;\n value: 'long_name' | 'short_name';\n }\n\n const mapping: {\n route: MappedType;\n street_number: MappedType;\n postal_code: MappedType;\n locality: MappedType;\n country: MappedType;\n } = {\n route: {\n key: 'street',\n value: 'long_name',\n },\n street_number: {\n key: 'houseNumber',\n value: 'long_name',\n },\n postal_code: {\n key: 'postcode',\n value: 'long_name',\n },\n locality: {\n key: 'city',\n value: 'long_name',\n },\n country: {\n key: 'country',\n value: 'short_name',\n },\n };\n\n const toReturn: Partial<Address> = {};\n input.forEach((value) => {\n const type = value.types[0] as keyof typeof mapping;\n const mappedValue = mapping[type];\n if (mappedValue) {\n const isPostalCodePrefix = value.types.includes(\n 'postal_code_prefix' as string\n );\n if (mappedValue.key === 'postcode' && isPostalCodePrefix) {\n return;\n }\n toReturn[mappedValue.key] = value[mappedValue.value];\n }\n });\n\n return toReturn;\n};\n\nexport const inlineAddress = (address: Address) =>\n `${address.street} ${address.houseNumber}, ${\n address.city\n }, ${countryNameFromAlphaCode(address.country as Alpha2CountryCode)}`;\n","import { ChangeEvent, useCallback, useEffect, useRef, useState } from 'react';\nimport classNames from 'classnames';\nimport debounce from 'lodash.debounce';\nimport { Input } from '../input';\nimport {\n Address,\n Alpha2CountryCode,\n countryNameFromAlphaCode,\n} from '@popsure/public-models';\n\nimport { geocoderAddressComponentToPartialAddress } from './util';\n\nimport styles from './style.module.scss';\n\nconst GERMANY_LAT_LNG = { lat: 51.54317, lng: 10.3181503 };\n\nconst GERMANY_ALPHA_CODE = 'DE';\n\nconst MAP_CONFIG_OBJ = {\n zoom: 6,\n center: GERMANY_LAT_LNG,\n fullscreenControl: false,\n mapTypeControl: false,\n panControl: false,\n zoomControl: false,\n streetViewControl: false,\n scrollwheel: false,\n scaleControl: false,\n rotateControl: false,\n draggable: false,\n};\n\nconst loadGoogleMapsApiDynamically = (callback: () => void, apiKey: string) => {\n const existingScript = document.getElementById('googleMapsImportScript');\n\n if (existingScript) {\n return;\n }\n\n const googleMapImportScript = document.createElement('script');\n googleMapImportScript.id = 'googleMapsImportScript';\n googleMapImportScript.type = 'text/javascript';\n googleMapImportScript.src = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=places`;\n document.head.appendChild(googleMapImportScript);\n\n googleMapImportScript.onload = () => {\n callback();\n };\n};\n\nexport interface AutocompleteAddressProps {\n apiKey: string;\n address?: Partial<Address>;\n onAddressChange: (address: Partial<Address>) => void;\n inputProps?: {\n street?: {\n name?: string;\n };\n houseNumber?: {\n name?: string;\n };\n additionalInformation?: {\n name?: string;\n };\n postcode?: {\n name?: string;\n };\n city?: {\n name?: string;\n };\n };\n placeholders?: {\n manualAddressEntry?: string;\n street?: string;\n houseNumber?: string;\n additionalInformation?: string;\n postcode?: string;\n city?: string;\n };\n manualAddressEntryTexts?: {\n preText?: string;\n cta?: string;\n };\n countryCode?: string;\n}\n\nconst AutocompleteAddress = ({\n apiKey,\n address: initialAddress,\n onAddressChange,\n placeholders,\n manualAddressEntryTexts,\n inputProps,\n countryCode = GERMANY_ALPHA_CODE\n}: AutocompleteAddressProps) => {\n const [manualAddressEntry, setManualAddressEntry] = useState(false);\n const [isLoading, setIsLoading] = useState(false);\n const autocomplete = useRef<google.maps.places.Autocomplete | null>(null);\n const autocompleteElement = useRef<HTMLInputElement | null>(null);\n const map = useRef<google.maps.Map | null>(null);\n const marker = useRef<google.maps.Marker | null>(null);\n const [address, setAddress] = useState(initialAddress);\n const [hasLoadedGoogleAPI, setHasLoadedGoogleAPI] = useState(\n window.google?.maps !== undefined\n );\n\n loadGoogleMapsApiDynamically(() => {\n setHasLoadedGoogleAPI(true);\n }, apiKey);\n\n const [place, setPlace] = useState<google.maps.places.PlaceResult | null>(\n null\n );\n\n useEffect(() => {\n if (address) {\n if (autocompleteElement.current && address.street) {\n autocompleteElement.current.value = address.street;\n }\n\n handleEnterAddressManually();\n }\n }, [address, onAddressChange, hasLoadedGoogleAPI]);\n\n useEffect(() => {\n if (!hasLoadedGoogleAPI) {\n return;\n }\n\n const reference = document.getElementById(\n 'autocomplete'\n ) as HTMLInputElement;\n\n autocomplete.current = new google.maps.places.Autocomplete(reference, {\n types: ['address'],\n componentRestrictions: { country: countryCode },\n });\n\n autocomplete.current.addListener('place_changed', onPlaceChanged);\n\n map.current = new google.maps.Map(\n document.getElementById('map')!,\n MAP_CONFIG_OBJ\n );\n\n import('./mapStyle').then(({ style }) => {\n map.current?.mapTypes.set('styled_map', style);\n map.current?.setMapTypeId('styled_map');\n });\n\n marker.current = new google.maps.Marker({\n map: map.current,\n });\n\n setPlaceFromAddress(address);\n }, [hasLoadedGoogleAPI, countryCode]); // eslint-disable-line\n\n const onPlaceChanged = (\n newPlace:\n | google.maps.places.PlaceResult\n | undefined = autocomplete.current?.getPlace(),\n updateAddress: boolean = true\n ) => {\n if (newPlace?.geometry?.location) {\n const geocoderAddress = geocoderAddressComponentToPartialAddress(\n newPlace.address_components!\n );\n\n setPlace(newPlace);\n if (updateAddress) {\n setAddress((oldValue) => ({\n ...geocoderAddress,\n additionalInformation: oldValue?.additionalInformation,\n }));\n onAddressChange?.(geocoderAddress);\n }\n\n map.current?.panTo(newPlace.geometry.location);\n map.current?.setZoom(15);\n\n marker.current?.setPosition(newPlace.geometry.location);\n }\n };\n\n const setPlaceFromAddress = useCallback(\n (address: Partial<Address> | undefined) => {\n if (!map.current) {\n return;\n }\n\n if (address) {\n const service = new google.maps.places.PlacesService(map.current);\n const query = `${address.street ?? ''} ${address.houseNumber ?? ''}, ${\n address.city ?? ''\n }, ${\n address.country\n ? countryNameFromAlphaCode(address.country as Alpha2CountryCode)\n : ''\n }`;\n setIsLoading(true);\n service.findPlaceFromQuery(\n {\n fields: ['place_id'],\n query,\n },\n (results) => {\n const firstResult = results && results[0];\n if (firstResult && firstResult.place_id) {\n service.getDetails(\n { placeId: firstResult.place_id },\n (newPlace) => {\n onPlaceChanged(newPlace ?? undefined, false);\n }\n );\n }\n setIsLoading(false);\n }\n );\n }\n },\n []\n );\n\n const debouncedSetPlace = debounce(setPlaceFromAddress, 2000);\n\n const handleEnterAddressManually = () => {\n setManualAddressEntry(true);\n };\n\n const onManualAddressChange =\n ({ updatePlace } = { updatePlace: true }) =>\n (e: ChangeEvent<HTMLInputElement>) => {\n const newAddress = {\n ...address,\n [e.target.name]: e.target.value,\n country: countryCode,\n };\n setAddress(newAddress);\n onAddressChange(newAddress);\n\n if (updatePlace) {\n debouncedSetPlace(newAddress);\n }\n };\n\n return (\n <>\n <div\n className={classNames(`wmx8 bg-neutral-600 ${styles['map-container']}`, {\n [styles['map-container--hidden']]: place === null,\n })}\n >\n <div className={styles.map} id=\"map\" aria-hidden=\"true\" />\n {isLoading && (\n <div className={styles['loading-spinner']}>\n <div className=\"ds-spinner ds-spinner__m\" />\n </div>\n )}\n </div>\n <div className={`wmx8`}>\n {manualAddressEntry === false ? (\n <div style={{ position: 'relative' }}>\n <Input\n className=\"w100\"\n id=\"autocomplete\"\n key=\"autocomplete-search\"\n data-cy=\"autocomplete\"\n data-testid=\"autocomplete\"\n type=\"text\"\n placeholder={\n placeholders?.manualAddressEntry || 'Search for address'\n }\n ref={autocompleteElement}\n disabled={hasLoadedGoogleAPI === false}\n />\n {hasLoadedGoogleAPI === false && (\n <div\n data-cy=\"google-api-loader\"\n data-testid=\"google-api-loader\"\n className={styles['loading-spinner']}\n >\n <div className=\"ds-spinner ds-spinner__m\" />\n </div>\n )}\n </div>\n ) : (\n <>\n <div className={`d-flex c-gap16 ${styles['input-line']}`}>\n <Input\n className=\"w100\"\n data-cy=\"autocomplete\"\n data-testid=\"autocomplete\"\n key=\"autocomplete-street\"\n type=\"text\"\n placeholder={placeholders?.street || 'Street'}\n value={address?.street || ''}\n onChange={onManualAddressChange()}\n name=\"street\"\n {...inputProps?.street}\n />\n <Input\n className={`wmx2 ${styles['house-number-input']}`}\n data-cy=\"autocomplete-house-number\"\n data-testid=\"autocomplete-house-number\"\n key=\"autocomplete-house-number\"\n placeholder={placeholders?.houseNumber || 'House number'}\n value={address?.houseNumber || ''}\n name=\"houseNumber\"\n onChange={onManualAddressChange()}\n {...inputProps?.houseNumber}\n />\n </div>\n <Input\n className=\"mt16\"\n data-cy=\"autocomplete-additional-info\"\n data-testid=\"autocomplete-additional-info\"\n key=\"autocomplete-additional-info\"\n placeholder={\n placeholders?.additionalInformation ||\n 'Additional information (C/O, apartment, etc.)'\n }\n value={address?.additionalInformation || ''}\n name=\"additionalInformation\"\n onChange={onManualAddressChange({ updatePlace: false })}\n {...inputProps?.additionalInformation}\n />\n <div className={`d-flex mt16 c-gap16 ${styles['input-line']}`}>\n <Input\n className=\"w100\"\n data-cy=\"autocomplete-postcode\"\n data-testid=\"autocomplete-postcode\"\n key=\"autocomplete-postcode\"\n placeholder={placeholders?.postcode || 'Postcode'}\n value={address?.postcode || ''}\n name=\"postcode\"\n onChange={onManualAddressChange()}\n {...inputProps?.postcode}\n />\n <Input\n className=\"w100\"\n data-cy=\"autocomplete-city\"\n data-testid=\"autocomplete-city\"\n key=\"autocomplete-city\"\n placeholder={placeholders?.city || 'City'}\n value={address?.city || ''}\n name=\"city\"\n onChange={onManualAddressChange()}\n {...inputProps?.city}\n />\n </div>\n </>\n )}\n </div>\n {manualAddressEntry === false && (\n <div className=\"p-p mt8\">\n {manualAddressEntryTexts?.preText || 'Or '}\n <button\n className={'p-a p-p fw-bold c-pointer bg-transparent'}\n onClick={handleEnterAddressManually}\n type=\"button\"\n >\n {manualAddressEntryTexts?.cta || 'enter address manually'}\n </button>\n </div>\n )}\n </>\n );\n};\n\nexport { AutocompleteAddress };\n"],"names":["countryNameFromAlphaCode","_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;;;;AAMO,IAAM,wCAAwC,GAAG,UACtD,KAA6C,EAAA;AAO7C,IAAA,IAAM,OAAO,GAMT;AACF,QAAA,KAAK,EAAE;AACL,YAAA,GAAG,EAAE,QAAQ;AACb,YAAA,KAAK,EAAE,WAAW;AACnB,SAAA;AACD,QAAA,aAAa,EAAE;AACb,YAAA,GAAG,EAAE,aAAa;AAClB,YAAA,KAAK,EAAE,WAAW;AACnB,SAAA;AACD,QAAA,WAAW,EAAE;AACX,YAAA,GAAG,EAAE,UAAU;AACf,YAAA,KAAK,EAAE,WAAW;AACnB,SAAA;AACD,QAAA,QAAQ,EAAE;AACR,YAAA,GAAG,EAAE,MAAM;AACX,YAAA,KAAK,EAAE,WAAW;AACnB,SAAA;AACD,QAAA,OAAO,EAAE;AACP,YAAA,GAAG,EAAE,SAAS;AACd,YAAA,KAAK,EAAE,YAAY;AACpB,SAAA;KACF;IAED,IAAM,QAAQ,GAAqB,EAAE;AACrC,IAAA,KAAK,CAAC,OAAO,CAAC,UAAC,KAAK,EAAA;QAClB,IAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAyB;AACnD,QAAA,IAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;QACjC,IAAI,WAAW,EAAE;YACf,IAAM,kBAAkB,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,CAC7C,oBAA8B,CAC/B;YACD,IAAI,WAAW,CAAC,GAAG,KAAK,UAAU,IAAI,kBAAkB,EAAE;gBACxD;YACF;AACA,YAAA,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC;QACtD;AACF,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,QAAQ;AACjB,CA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,EAAA,CACL,CACP,CAAA,EAAA,CACA;AAEP;;;;"}
|
|
@@ -26,10 +26,16 @@ var setup = function (address, onAddressChange) {
|
|
|
26
26
|
if (onAddressChange === void 0) { onAddressChange = function () { }; }
|
|
27
27
|
return customRender(jsx(AutocompleteAddress, { address: address, apiKey: '', onAddressChange: onAddressChange }));
|
|
28
28
|
};
|
|
29
|
-
var
|
|
29
|
+
var addressFieldTestIds = [
|
|
30
|
+
'autocomplete',
|
|
31
|
+
'autocomplete-house-number',
|
|
32
|
+
'autocomplete-additional-info',
|
|
33
|
+
'autocomplete-postcode',
|
|
34
|
+
'autocomplete-city',
|
|
35
|
+
];
|
|
30
36
|
describe('AutocompleteAddress component', function () {
|
|
31
37
|
it('Should show all address fields once a search is completed', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
32
|
-
var _a,
|
|
38
|
+
var _a, getByDisplayValue, getByTestId;
|
|
33
39
|
return __generator(this, function (_b) {
|
|
34
40
|
// @ts-ignore
|
|
35
41
|
window.google.maps.places.Autocomplete = /** @class */ (function () {
|
|
@@ -61,39 +67,42 @@ describe('AutocompleteAddress component', function () {
|
|
|
61
67
|
};
|
|
62
68
|
return class_1;
|
|
63
69
|
}());
|
|
64
|
-
_a = setup(),
|
|
65
|
-
fireEvent.change(getByTestId(
|
|
70
|
+
_a = setup(), getByDisplayValue = _a.getByDisplayValue, getByTestId = _a.getByTestId;
|
|
71
|
+
fireEvent.change(getByTestId('autocomplete'), {
|
|
66
72
|
target: { value: 'Köpeniker' },
|
|
67
73
|
});
|
|
68
|
-
|
|
74
|
+
addressFieldTestIds.forEach(function (testId) {
|
|
75
|
+
return expect(getByTestId(testId)).toBeInTheDocument();
|
|
76
|
+
});
|
|
69
77
|
expect(getByDisplayValue('Köpeniker Strasse')).toBeVisible();
|
|
70
78
|
return [2 /*return*/];
|
|
71
79
|
});
|
|
72
80
|
}); });
|
|
73
81
|
it('Should enable to enter the address manually', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
74
|
-
var callback, _a, findByText,
|
|
82
|
+
var callback, _a, findByText, getByTestId, user, btn;
|
|
75
83
|
return __generator(this, function (_b) {
|
|
76
84
|
switch (_b.label) {
|
|
77
85
|
case 0:
|
|
78
86
|
callback = jest.fn();
|
|
79
|
-
_a = setup(undefined, callback), findByText = _a.findByText,
|
|
87
|
+
_a = setup(undefined, callback), findByText = _a.findByText, getByTestId = _a.getByTestId, user = _a.user;
|
|
80
88
|
return [4 /*yield*/, findByText('enter address manually')];
|
|
81
89
|
case 1:
|
|
82
90
|
btn = _b.sent();
|
|
83
91
|
return [4 /*yield*/, user.click(btn)];
|
|
84
92
|
case 2:
|
|
85
93
|
_b.sent();
|
|
86
|
-
|
|
87
|
-
return [4 /*yield*/, user.type(
|
|
94
|
+
// fill out all fields
|
|
95
|
+
return [4 /*yield*/, user.type(getByTestId('autocomplete'), 'Köpeniker Strasse')];
|
|
88
96
|
case 3:
|
|
97
|
+
// fill out all fields
|
|
89
98
|
_b.sent();
|
|
90
|
-
return [4 /*yield*/, user.type(
|
|
99
|
+
return [4 /*yield*/, user.type(getByTestId('autocomplete-house-number'), '4000')];
|
|
91
100
|
case 4:
|
|
92
101
|
_b.sent();
|
|
93
|
-
return [4 /*yield*/, user.type(
|
|
102
|
+
return [4 /*yield*/, user.type(getByTestId('autocomplete-postcode'), '10179')];
|
|
94
103
|
case 5:
|
|
95
104
|
_b.sent();
|
|
96
|
-
return [4 /*yield*/, user.type(
|
|
105
|
+
return [4 /*yield*/, user.type(getByTestId('autocomplete-city'), 'Berlin')];
|
|
97
106
|
case 6:
|
|
98
107
|
_b.sent();
|
|
99
108
|
// callback should be called with a complete address
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.js","sources":["../../../../../src/lib/components/autocompleteAddress/index.test.tsx"],"sourcesContent":["import { Address } from '@popsure/public-models';\nimport { fireEvent, render } from '../../util/testUtils';\n\nimport { AutocompleteAddress } from '.';\n\nconst address = {\n street: 'Köpeniker Strasse',\n houseNumber: '4000',\n postcode: '10179',\n city: 'Berlin',\n country: 'DE',\n};\n\nconst setup = (\n address: Partial<Address> | undefined = undefined,\n onAddressChange: (address: Partial<Address>) => void = () => {}\n) => {\n return render(\n <AutocompleteAddress\n address={address}\n apiKey={''}\n onAddressChange={onAddressChange}\n />\n );\n};\n\nconst
|
|
1
|
+
{"version":3,"file":"index.test.js","sources":["../../../../../src/lib/components/autocompleteAddress/index.test.tsx"],"sourcesContent":["import { Address } from '@popsure/public-models';\nimport { fireEvent, render } from '../../util/testUtils';\n\nimport { AutocompleteAddress } from '.';\n\nconst address = {\n street: 'Köpeniker Strasse',\n houseNumber: '4000',\n postcode: '10179',\n city: 'Berlin',\n country: 'DE',\n};\n\nconst setup = (\n address: Partial<Address> | undefined = undefined,\n onAddressChange: (address: Partial<Address>) => void = () => {}\n) => {\n return render(\n <AutocompleteAddress\n address={address}\n apiKey={''}\n onAddressChange={onAddressChange}\n />\n );\n};\n\nconst addressFieldTestIds = [\n 'autocomplete',\n 'autocomplete-house-number',\n 'autocomplete-additional-info',\n 'autocomplete-postcode',\n 'autocomplete-city',\n];\n\ndescribe('AutocompleteAddress component', () => {\n it('Should show all address fields once a search is completed', async () => {\n // @ts-ignore\n window.google.maps.places.Autocomplete = class {\n reference: HTMLElement;\n constructor(reference: HTMLElement) {\n this.reference = reference;\n }\n // @ts-ignore\n addListener(_action, callback) {\n this.reference.addEventListener('change', (e: Event) =>\n (e.target as HTMLInputElement).value !== ''\n ? callback({\n geometry: {\n location: class {},\n },\n address_components: [\n {\n long_name: 'Köpeniker Strasse',\n short_name: 'Köpeniker Strasse',\n types: ['route'],\n },\n ],\n })\n : null\n );\n }\n };\n\n const { getByDisplayValue, getByTestId } = setup();\n\n fireEvent.change(getByTestId('autocomplete'), {\n target: { value: 'Köpeniker' },\n });\n\n addressFieldTestIds.forEach((testId) =>\n expect(getByTestId(testId)).toBeInTheDocument()\n );\n expect(getByDisplayValue('Köpeniker Strasse')).toBeVisible();\n });\n\n it('Should enable to enter the address manually', async () => {\n const callback = jest.fn();\n const { findByText, getByTestId, user } = setup(undefined, callback);\n const btn = await findByText('enter address manually');\n\n await user.click(btn);\n\n // fill out all fields\n await user.type(getByTestId('autocomplete'), 'Köpeniker Strasse');\n await user.type(getByTestId('autocomplete-house-number'), '4000');\n await user.type(getByTestId('autocomplete-postcode'), '10179');\n await user.type(getByTestId('autocomplete-city'), 'Berlin');\n\n // callback should be called with a complete address\n expect(callback).toHaveBeenCalledWith(address);\n });\n\n it('Should prefill fields if an address is provided', async () => {\n const { getByDisplayValue } = setup(address);\n\n expect(getByDisplayValue('Köpeniker Strasse')).toBeVisible();\n expect(getByDisplayValue('4000')).toBeVisible();\n expect(getByDisplayValue('10179')).toBeVisible();\n expect(getByDisplayValue('Berlin')).toBeVisible();\n });\n});\n"],"names":["render","_jsx"],"mappings":";;;;;;;;;;;;;;;;AAKA,IAAM,OAAO,GAAG;AACd,IAAA,MAAM,EAAE,mBAAmB;AAC3B,IAAA,WAAW,EAAE,MAAM;AACnB,IAAA,QAAQ,EAAE,OAAO;AACjB,IAAA,IAAI,EAAE,QAAQ;AACd,IAAA,OAAO,EAAE,IAAI;CACd;AAED,IAAM,KAAK,GAAG,UACZ,OAAiD,EACjD,eAA+D,EAAA;AAD/D,IAAA,IAAA,OAAA,KAAA,MAAA,EAAA,EAAA,OAAA,GAAA,SAAiD,CAAA,CAAA;IACjD,IAAA,eAAA,KAAA,MAAA,EAAA,EAAA,gCAA8D,CAAC,CAAA,CAAA;AAE/D,IAAA,OAAOA,YAAM,CACXC,GAAA,CAAC,mBAAmB,EAAA,EAClB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,EAAE,EACV,eAAe,EAAE,eAAe,EAAA,CAChC,CACH;AACH,CAAC;AAED,IAAM,mBAAmB,GAAG;IAC1B,cAAc;IACd,2BAA2B;IAC3B,8BAA8B;IAC9B,uBAAuB;IACvB,mBAAmB;CACpB;AAED,QAAQ,CAAC,+BAA+B,EAAE,YAAA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AA,CAAA,CAAA,YAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,EAAE,QAAQ,CAAC,CAAA;;AAA3D,oBAAA,EAAA,CAAA,IAAA,EAA2D;;oBAG3D,MAAM,CAAC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC;;;;AAC/C,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAC;IAEF,EAAE,CAAC,iDAAiD,EAAE,YAAA,EAAA,OAAA,SAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,YAAA;;;AAC5C,YAAA,iBAAiB,GAAK,KAAK,CAAC,OAAO,CAAC,kBAAnB;YAEzB,MAAM,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAAC,CAAC,WAAW,EAAE;YAC5D,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,EAAE;YAC/C,MAAM,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,EAAE;YAChD,MAAM,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,EAAE;;;AAClD,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -15,7 +15,7 @@ styleInject(css_248z);
|
|
|
15
15
|
|
|
16
16
|
var InitialButton = function (_a) {
|
|
17
17
|
var onDownload = _a.onDownload;
|
|
18
|
-
return (jsx(Button, { className: "w100 ".concat(styles.button), leftIcon: jsx(DownloadIcon, {}), onClick: onDownload, "data-cy": "download-documents-button", children: "Download" }));
|
|
18
|
+
return (jsx(Button, { className: "w100 ".concat(styles.button), leftIcon: jsx(DownloadIcon, {}), onClick: onDownload, "data-cy": "download-documents-button", "data-testid": "download-documents-button", children: "Download" }));
|
|
19
19
|
};
|
|
20
20
|
// TODO: Allow setting loading to true to display text
|
|
21
21
|
var GeneratingButton = function () { return (jsx(Button, { className: "w100 ".concat(styles.button), loading: true, children: "Generating" })); };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/lib/components/downloadButton/index.tsx"],"sourcesContent":["import { Button } from '../button';\nimport { DownloadStatus } from '../../models/download';\nimport { CheckIcon, DownloadIcon } from '../icon/icons';\nimport styles from './style.module.scss';\n\nexport interface DownloadButtonProps {\n downloadStatus: DownloadStatus;\n onDownload: () => void;\n className?: string;\n customFail?: React.ReactNode;\n}\n\nconst InitialButton = ({ onDownload }: { onDownload: () => void }) => (\n <Button\n className={`w100 ${styles.button}`}\n leftIcon={<DownloadIcon />}\n onClick={onDownload}\n data-cy=\"download-documents-button\"\n >\n Download\n </Button>\n);\n\n// TODO: Allow setting loading to true to display text\nconst GeneratingButton = () => (\n <Button\n className={`w100 ${styles.button}`}\n loading={true}\n >\n Generating\n </Button>\n);\n\nconst CompletedChip = () => (\n <div className={styles['chip-complete']}>\n <CheckIcon color={'neutral-600'} size={16} />\n <div className=\"p-h4 tc-neutral-600 ml8\">Download complete</div>\n </div>\n);\n\nconst DownloadButton = ({\n downloadStatus,\n onDownload,\n className = '',\n customFail,\n}: DownloadButtonProps) => {\n const mapDownloadButton: { [K in DownloadStatus]: React.ReactNode } = {\n INITIAL: <InitialButton onDownload={onDownload} />,\n GENERATING: <GeneratingButton />,\n COMPLETED: <CompletedChip />,\n FAILED: <InitialButton onDownload={onDownload} />,\n };\n\n return (\n <div className={`d-flex fd-column ai-center ${className}`}>\n <div className=\"ws4\">{mapDownloadButton[downloadStatus]}</div>\n {downloadStatus === 'FAILED' && (\n <div className=\"p-notice p-notice--danger p-p mt40 wmx5\">\n {customFail ??\n 'An error occured when generating documents. Please try again or contact us.'}\n </div>\n )}\n </div>\n );\n};\n\nexport { DownloadButton };\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;AAYA,IAAM,aAAa,GAAG,UAAC,EAA0C,EAAA;AAAxC,IAAA,IAAA,UAAU,GAAA,EAAA,CAAA,UAAA;IAAmC,QACpEA,GAAA,CAAC,MAAM,EAAA,EACL,SAAS,EAAE,OAAA,CAAA,MAAA,CAAQ,MAAM,CAAC,MAAM,CAAE,EAClC,QAAQ,EAAEA,GAAA,CAAC,YAAY,EAAA,EAAA,CAAG,EAC1B,OAAO,EAAE,UAAU,EAAA,SAAA,EACX,2BAA2B,EAAA,QAAA,EAAA,UAAA,EAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/lib/components/downloadButton/index.tsx"],"sourcesContent":["import { Button } from '../button';\nimport { DownloadStatus } from '../../models/download';\nimport { CheckIcon, DownloadIcon } from '../icon/icons';\nimport styles from './style.module.scss';\n\nexport interface DownloadButtonProps {\n downloadStatus: DownloadStatus;\n onDownload: () => void;\n className?: string;\n customFail?: React.ReactNode;\n}\n\nconst InitialButton = ({ onDownload }: { onDownload: () => void }) => (\n <Button\n className={`w100 ${styles.button}`}\n leftIcon={<DownloadIcon />}\n onClick={onDownload}\n data-cy=\"download-documents-button\"\n data-testid=\"download-documents-button\"\n >\n Download\n </Button>\n);\n\n// TODO: Allow setting loading to true to display text\nconst GeneratingButton = () => (\n <Button\n className={`w100 ${styles.button}`}\n loading={true}\n >\n Generating\n </Button>\n);\n\nconst CompletedChip = () => (\n <div className={styles['chip-complete']}>\n <CheckIcon color={'neutral-600'} size={16} />\n <div className=\"p-h4 tc-neutral-600 ml8\">Download complete</div>\n </div>\n);\n\nconst DownloadButton = ({\n downloadStatus,\n onDownload,\n className = '',\n customFail,\n}: DownloadButtonProps) => {\n const mapDownloadButton: { [K in DownloadStatus]: React.ReactNode } = {\n INITIAL: <InitialButton onDownload={onDownload} />,\n GENERATING: <GeneratingButton />,\n COMPLETED: <CompletedChip />,\n FAILED: <InitialButton onDownload={onDownload} />,\n };\n\n return (\n <div className={`d-flex fd-column ai-center ${className}`}>\n <div className=\"ws4\">{mapDownloadButton[downloadStatus]}</div>\n {downloadStatus === 'FAILED' && (\n <div className=\"p-notice p-notice--danger p-p mt40 wmx5\">\n {customFail ??\n 'An error occured when generating documents. Please try again or contact us.'}\n </div>\n )}\n </div>\n );\n};\n\nexport { DownloadButton };\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;AAYA,IAAM,aAAa,GAAG,UAAC,EAA0C,EAAA;AAAxC,IAAA,IAAA,UAAU,GAAA,EAAA,CAAA,UAAA;IAAmC,QACpEA,GAAA,CAAC,MAAM,EAAA,EACL,SAAS,EAAE,OAAA,CAAA,MAAA,CAAQ,MAAM,CAAC,MAAM,CAAE,EAClC,QAAQ,EAAEA,GAAA,CAAC,YAAY,EAAA,EAAA,CAAG,EAC1B,OAAO,EAAE,UAAU,EAAA,SAAA,EACX,2BAA2B,EAAA,aAAA,EACvB,2BAA2B,EAAA,QAAA,EAAA,UAAA,EAAA,CAGhC;AAT2D,CAUrE;AAED;AACA,IAAM,gBAAgB,GAAG,YAAA,EAAM,QAC7BA,GAAA,CAAC,MAAM,EAAA,EACL,SAAS,EAAE,OAAA,CAAA,MAAA,CAAQ,MAAM,CAAC,MAAM,CAAE,EAClC,OAAO,EAAE,IAAI,EAAA,QAAA,EAAA,YAAA,EAAA,CAGN,EACV,CAP8B,CAO9B;AAED,IAAM,aAAa,GAAG,YAAA,EAAM,QAC1BC,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,eAAe,CAAC,EAAA,QAAA,EAAA,CACrCD,GAAA,CAAC,SAAS,EAAA,EAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,GAAI,EAC7CA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,yBAAyB,EAAA,QAAA,EAAA,mBAAA,EAAA,CAAwB,CAAA,EAAA,CAC5D,EACP,CAL2B,CAK3B;AAED,IAAM,cAAc,GAAG,UAAC,EAKF,EAAA;AAJpB,IAAA,IAAA,cAAc,GAAA,EAAA,CAAA,cAAA,EACd,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,EAAA,GAAA,EAAA,CAAA,SAAc,EAAd,SAAS,GAAA,EAAA,KAAA,MAAA,GAAG,EAAE,GAAA,EAAA,EACd,UAAU,GAAA,EAAA,CAAA,UAAA;AAEV,IAAA,IAAM,iBAAiB,GAA+C;AACpE,QAAA,OAAO,EAAEA,GAAA,CAAC,aAAa,IAAC,UAAU,EAAE,UAAU,EAAA,CAAI;QAClD,UAAU,EAAEA,GAAA,CAAC,gBAAgB,EAAA,EAAA,CAAG;QAChC,SAAS,EAAEA,GAAA,CAAC,aAAa,EAAA,EAAA,CAAG;AAC5B,QAAA,MAAM,EAAEA,GAAA,CAAC,aAAa,IAAC,UAAU,EAAE,UAAU,EAAA,CAAI;KAClD;AAED,IAAA,QACEC,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,6BAAA,CAAA,MAAA,CAA8B,SAAS,CAAE,EAAA,QAAA,EAAA,CACvDD,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,KAAK,EAAA,QAAA,EAAE,iBAAiB,CAAC,cAAc,CAAC,GAAO,EAC7D,cAAc,KAAK,QAAQ,KAC1BA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,yCAAyC,YACrD,UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,MAAA,GAAV,UAAU,GACT,6EAA6E,GAC3E,CACP,CAAA,EAAA,CACG;AAEV;;;;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { c as customRender, f as fireEvent, s as screen } from '../../customRender-DzdqZxUd.js';
|
|
3
|
+
import { DownloadButton } from './index.js';
|
|
4
|
+
import '../../tslib.es6-CVlKGIvp.js';
|
|
5
|
+
import '../../_commonjsHelpers-BFTU3MAI.js';
|
|
6
|
+
import 'react';
|
|
7
|
+
import 'react-dom';
|
|
8
|
+
import 'util';
|
|
9
|
+
import 'react-dom/test-utils';
|
|
10
|
+
import '../button/index.js';
|
|
11
|
+
import '../../index-DLQEsiym.js';
|
|
12
|
+
import '../icon/icons/Check.js';
|
|
13
|
+
import '../icon/IconWrapper/IconWrapper.js';
|
|
14
|
+
import '../../style-inject.es-tgCJW-Cu.js';
|
|
15
|
+
import '../icon/icons/Download.js';
|
|
16
|
+
|
|
17
|
+
describe('DownloadButton', function () {
|
|
18
|
+
it.each(['INITIAL', 'FAILED'])('exposes the %s download button as download-documents-button', function (downloadStatus) {
|
|
19
|
+
var onDownload = jest.fn();
|
|
20
|
+
customRender(jsx(DownloadButton, { downloadStatus: downloadStatus, onDownload: onDownload }));
|
|
21
|
+
fireEvent.click(screen.getByTestId('download-documents-button'));
|
|
22
|
+
expect(onDownload).toHaveBeenCalledTimes(1);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.js","sources":["../../../../../src/lib/components/downloadButton/index.test.tsx"],"sourcesContent":["import { fireEvent, render, screen } from '../../util/testUtils';\nimport { DownloadButton } from '.';\n\ndescribe('DownloadButton', () => {\n it.each(['INITIAL', 'FAILED'] as const)(\n 'exposes the %s download button as download-documents-button',\n (downloadStatus) => {\n const onDownload = jest.fn();\n\n render(\n <DownloadButton\n downloadStatus={downloadStatus}\n onDownload={onDownload}\n />\n );\n\n fireEvent.click(screen.getByTestId('download-documents-button'));\n\n expect(onDownload).toHaveBeenCalledTimes(1);\n }\n );\n});\n"],"names":["render","_jsx"],"mappings":";;;;;;;;;;;;;;;;AAGA,QAAQ,CAAC,gBAAgB,EAAE,YAAA;AACzB,IAAA,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAU,CAAC,CACrC,6DAA6D,EAC7D,UAAC,cAAc,EAAA;AACb,QAAA,IAAM,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE;AAE5B,QAAAA,YAAM,CACJC,GAAA,CAAC,cAAc,EAAA,EACb,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,UAAU,EAAA,CACtB,CACH;QAED,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,2BAA2B,CAAC,CAAC;QAEhE,MAAM,CAAC,UAAU,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC;AAC7C,IAAA,CAAC,CACF;AACH,CAAC,CAAC"}
|
|
@@ -23,7 +23,7 @@ var AutoSuggestInput = function (_a) {
|
|
|
23
23
|
_a)), children: suggestion.value })] }));
|
|
24
24
|
};
|
|
25
25
|
var getSuggestionValue = function (suggestion) { return suggestion.value; };
|
|
26
|
-
var renderInputComponent = function (autoSuggestInputProps) { return (jsx(Input, __assign({}, autoSuggestInputProps, { placeholder: placeholder, "data-cy": "suggest-multi-select-input" }))); };
|
|
26
|
+
var renderInputComponent = function (autoSuggestInputProps) { return (jsx(Input, __assign({}, autoSuggestInputProps, { placeholder: placeholder, "data-cy": "suggest-multi-select-input", "data-testid": "suggest-multi-select-input" }))); };
|
|
27
27
|
return (jsx("div", { className: className, children: jsx(Autosuggest, { theme: styles, suggestions: suggestions, onSuggestionsFetchRequested: handleSuggestionFetchRequest, onSuggestionsClearRequested: handleSuggestionClearRequest, getSuggestionValue: getSuggestionValue, renderSuggestion: renderSuggestion, highlightFirstSuggestion: true, inputProps: __assign(__assign({}, inputProps), { value: currentOption, onChange: function (_, _a) {
|
|
28
28
|
var newValue = _a.newValue;
|
|
29
29
|
onChange(newValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../src/lib/components/input/autoSuggestInput/index.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport Autosuggest, { RenderInputComponentProps } from 'react-autosuggest';\n\nimport styles from './style.module.scss';\nimport { Option } from '../../../models/autoSuggestInput';\nimport { Input, InputProps } from '../index';\n\nexport interface AutoSuggestInputProps {\n currentOption: string;\n suggestions: Option[];\n handleSuggestionSelected: (value: Option) => void;\n onChange: (value: string) => void;\n handleSuggestionFetchRequest: (value: Option) => void;\n handleSuggestionClearRequest: () => void;\n placeholder: string;\n className?: string;\n wrapText?: boolean;\n inputProps?: Omit<RenderInputComponentProps, 'value' | 'onChange'>;\n}\n\nexport const AutoSuggestInput = ({\n currentOption,\n suggestions,\n handleSuggestionSelected,\n onChange,\n handleSuggestionFetchRequest,\n handleSuggestionClearRequest,\n placeholder,\n className,\n wrapText,\n inputProps\n}: AutoSuggestInputProps) => {\n const renderSuggestion = (suggestion: Option) => (\n <div className={`${styles['suggestion-option']}`}>\n {suggestion.leftIcon && (\n <img\n className={`mr16 ${styles['suggestion-img']}`}\n src={suggestion.leftIcon}\n alt={suggestion.value}\n />\n )}\n <div\n className={classNames(styles['suggestion-text'], {\n [styles.nowrap]: !wrapText,\n })}\n >\n {suggestion.value}\n </div>\n </div>\n );\n\n const getSuggestionValue = (suggestion: Option) => suggestion.value;\n\n const renderInputComponent = (autoSuggestInputProps: Omit<InputProps, 'ref'>) => (\n <Input\n {...autoSuggestInputProps}\n placeholder={placeholder}\n data-cy=\"suggest-multi-select-input\"\n />\n );\n\n return (\n <div className={className}>\n <Autosuggest\n theme={styles}\n suggestions={suggestions}\n onSuggestionsFetchRequested={handleSuggestionFetchRequest}\n onSuggestionsClearRequested={handleSuggestionClearRequest}\n getSuggestionValue={getSuggestionValue}\n renderSuggestion={renderSuggestion}\n highlightFirstSuggestion={true}\n inputProps={{\n ...inputProps,\n value: currentOption,\n onChange: (_, { newValue }) => {\n onChange(newValue);\n },\n }}\n onSuggestionSelected={(_, { suggestion }) => {\n handleSuggestionSelected(suggestion);\n }}\n renderInputComponent={renderInputComponent}\n />\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;AAoBO,IAAM,gBAAgB,GAAG,UAAC,EAWT,EAAA;QAVtB,aAAa,GAAA,EAAA,CAAA,aAAA,EACb,WAAW,GAAA,EAAA,CAAA,WAAA,EACX,wBAAwB,GAAA,EAAA,CAAA,wBAAA,EACxB,QAAQ,GAAA,EAAA,CAAA,QAAA,EACR,4BAA4B,GAAA,EAAA,CAAA,4BAAA,EAC5B,4BAA4B,GAAA,EAAA,CAAA,4BAAA,EAC5B,WAAW,GAAA,EAAA,CAAA,WAAA,EACX,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,QAAQ,GAAA,EAAA,CAAA,QAAA,EACR,UAAU,GAAA,EAAA,CAAA,UAAA;IAEV,IAAM,gBAAgB,GAAG,UAAC,UAAkB,EAAA;;QAAK,QAC/CA,cAAK,SAAS,EAAE,UAAG,MAAM,CAAC,mBAAmB,CAAC,CAAE,EAAA,QAAA,EAAA,CAC7C,UAAU,CAAC,QAAQ,KAClBC,GAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAE,OAAA,CAAA,MAAA,CAAQ,MAAM,CAAC,gBAAgB,CAAC,CAAE,EAC7C,GAAG,EAAE,UAAU,CAAC,QAAQ,EACxB,GAAG,EAAE,UAAU,CAAC,KAAK,GACrB,CACH,EACDA,aACE,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,iBAAiB,CAAC,GAAA,EAAA,GAAA,EAAA;AAC7C,wBAAA,EAAA,CAAC,MAAM,CAAC,MAAM,CAAA,GAAG,CAAC,QAAQ;AAC1B,wBAAA,EAAA,EAAA,EAAA,QAAA,EAED,UAAU,CAAC,KAAK,EAAA,CACb,IACF;AAhByC,IAAA,CAiBhD;IAED,IAAM,kBAAkB,GAAG,UAAC,UAAkB,EAAA,EAAK,OAAA,UAAU,CAAC,KAAK,CAAA,CAAhB,CAAgB;IAEnE,IAAM,oBAAoB,GAAG,UAAC,qBAA8C,IAAK,QAC/EA,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/lib/components/input/autoSuggestInput/index.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport Autosuggest, { RenderInputComponentProps } from 'react-autosuggest';\n\nimport styles from './style.module.scss';\nimport { Option } from '../../../models/autoSuggestInput';\nimport { Input, InputProps } from '../index';\n\nexport interface AutoSuggestInputProps {\n currentOption: string;\n suggestions: Option[];\n handleSuggestionSelected: (value: Option) => void;\n onChange: (value: string) => void;\n handleSuggestionFetchRequest: (value: Option) => void;\n handleSuggestionClearRequest: () => void;\n placeholder: string;\n className?: string;\n wrapText?: boolean;\n inputProps?: Omit<RenderInputComponentProps, 'value' | 'onChange'>;\n}\n\nexport const AutoSuggestInput = ({\n currentOption,\n suggestions,\n handleSuggestionSelected,\n onChange,\n handleSuggestionFetchRequest,\n handleSuggestionClearRequest,\n placeholder,\n className,\n wrapText,\n inputProps\n}: AutoSuggestInputProps) => {\n const renderSuggestion = (suggestion: Option) => (\n <div className={`${styles['suggestion-option']}`}>\n {suggestion.leftIcon && (\n <img\n className={`mr16 ${styles['suggestion-img']}`}\n src={suggestion.leftIcon}\n alt={suggestion.value}\n />\n )}\n <div\n className={classNames(styles['suggestion-text'], {\n [styles.nowrap]: !wrapText,\n })}\n >\n {suggestion.value}\n </div>\n </div>\n );\n\n const getSuggestionValue = (suggestion: Option) => suggestion.value;\n\n const renderInputComponent = (autoSuggestInputProps: Omit<InputProps, 'ref'>) => (\n <Input\n {...autoSuggestInputProps}\n placeholder={placeholder}\n data-cy=\"suggest-multi-select-input\"\n data-testid=\"suggest-multi-select-input\"\n />\n );\n\n return (\n <div className={className}>\n <Autosuggest\n theme={styles}\n suggestions={suggestions}\n onSuggestionsFetchRequested={handleSuggestionFetchRequest}\n onSuggestionsClearRequested={handleSuggestionClearRequest}\n getSuggestionValue={getSuggestionValue}\n renderSuggestion={renderSuggestion}\n highlightFirstSuggestion={true}\n inputProps={{\n ...inputProps,\n value: currentOption,\n onChange: (_, { newValue }) => {\n onChange(newValue);\n },\n }}\n onSuggestionSelected={(_, { suggestion }) => {\n handleSuggestionSelected(suggestion);\n }}\n renderInputComponent={renderInputComponent}\n />\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;AAoBO,IAAM,gBAAgB,GAAG,UAAC,EAWT,EAAA;QAVtB,aAAa,GAAA,EAAA,CAAA,aAAA,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AAA,CACxC,EACH,CAPgF,CAOhF;IAED,QACEA,aAAK,SAAS,EAAE,SAAS,EAAA,QAAA,EACvBA,GAAA,CAAC,WAAW,EAAA,EACV,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,WAAW,EACxB,2BAA2B,EAAE,4BAA4B,EACzD,2BAA2B,EAAE,4BAA4B,EACzD,kBAAkB,EAAE,kBAAkB,EACtC,gBAAgB,EAAE,gBAAgB,EAClC,wBAAwB,EAAE,IAAI,EAC9B,UAAU,wBACL,UAAU,CAAA,EAAA,EACb,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,UAAC,CAAC,EAAE,EAAY,EAAA;AAAV,oBAAA,IAAA,QAAQ,GAAA,EAAA,CAAA,QAAA;oBACtB,QAAQ,CAAC,QAAQ,CAAC;AACpB,gBAAA,CAAC,KAEH,oBAAoB,EAAE,UAAC,CAAC,EAAE,EAAc,EAAA;AAAZ,gBAAA,IAAA,UAAU,GAAA,EAAA,CAAA,UAAA;gBACpC,wBAAwB,CAAC,UAAU,CAAC;AACtC,YAAA,CAAC,EACD,oBAAoB,EAAE,oBAAoB,EAAA,CAC1C,EAAA,CACE;AAEV;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { c as customRender, s as screen } from '../../../customRender-DzdqZxUd.js';
|
|
3
|
+
import { AutoSuggestInput } from './index.js';
|
|
4
|
+
import '../../../tslib.es6-CVlKGIvp.js';
|
|
5
|
+
import '../../../_commonjsHelpers-BFTU3MAI.js';
|
|
6
|
+
import 'react';
|
|
7
|
+
import 'react-dom';
|
|
8
|
+
import 'util';
|
|
9
|
+
import 'react-dom/test-utils';
|
|
10
|
+
import '../../../index-DLQEsiym.js';
|
|
11
|
+
import '../../../index-BraF21Ae.js';
|
|
12
|
+
import '../../../index-DuaJiEiT.js';
|
|
13
|
+
import '../../../index-hWqCLhoS.js';
|
|
14
|
+
import '../../../style-inject.es-tgCJW-Cu.js';
|
|
15
|
+
import '../index.js';
|
|
16
|
+
import '../../../index-CNcEE5dn.js';
|
|
17
|
+
|
|
18
|
+
describe('AutoSuggestInput', function () {
|
|
19
|
+
it('exposes its input as suggest-multi-select-input', function () {
|
|
20
|
+
customRender(jsx(AutoSuggestInput, { currentOption: "", suggestions: [], handleSuggestionSelected: jest.fn(), onChange: jest.fn(), handleSuggestionFetchRequest: jest.fn(), handleSuggestionClearRequest: jest.fn(), placeholder: "Search countries" }));
|
|
21
|
+
expect(screen.getByTestId('suggest-multi-select-input').tagName).toBe('INPUT');
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.js","sources":["../../../../../../src/lib/components/input/autoSuggestInput/index.test.tsx"],"sourcesContent":["import { render, screen } from '../../../util/testUtils';\nimport { AutoSuggestInput } from '.';\n\ndescribe('AutoSuggestInput', () => {\n it('exposes its input as suggest-multi-select-input', () => {\n render(\n <AutoSuggestInput\n currentOption=\"\"\n suggestions={[]}\n handleSuggestionSelected={jest.fn()}\n onChange={jest.fn()}\n handleSuggestionFetchRequest={jest.fn()}\n handleSuggestionClearRequest={jest.fn()}\n placeholder=\"Search countries\"\n />\n );\n\n expect(screen.getByTestId('suggest-multi-select-input').tagName).toBe(\n 'INPUT'\n );\n });\n});\n"],"names":["render","_jsx"],"mappings":";;;;;;;;;;;;;;;;;AAGA,QAAQ,CAAC,kBAAkB,EAAE,YAAA;IAC3B,EAAE,CAAC,iDAAiD,EAAE,YAAA;QACpDA,YAAM,CACJC,IAAC,gBAAgB,EAAA,EACf,aAAa,EAAC,EAAE,EAChB,WAAW,EAAE,EAAE,EACf,wBAAwB,EAAE,IAAI,CAAC,EAAE,EAAE,EACnC,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,EACnB,4BAA4B,EAAE,IAAI,CAAC,EAAE,EAAE,EACvC,4BAA4B,EAAE,IAAI,CAAC,EAAE,EAAE,EACvC,WAAW,EAAC,kBAAkB,EAAA,CAC9B,CACH;AAED,QAAA,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,4BAA4B,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CACnE,OAAO,CACR;AACH,IAAA,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -24,7 +24,13 @@ const setup = (
|
|
|
24
24
|
);
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
const
|
|
27
|
+
const addressFieldTestIds = [
|
|
28
|
+
'autocomplete',
|
|
29
|
+
'autocomplete-house-number',
|
|
30
|
+
'autocomplete-additional-info',
|
|
31
|
+
'autocomplete-postcode',
|
|
32
|
+
'autocomplete-city',
|
|
33
|
+
];
|
|
28
34
|
|
|
29
35
|
describe('AutocompleteAddress component', () => {
|
|
30
36
|
it('Should show all address fields once a search is completed', async () => {
|
|
@@ -55,30 +61,30 @@ describe('AutocompleteAddress component', () => {
|
|
|
55
61
|
}
|
|
56
62
|
};
|
|
57
63
|
|
|
58
|
-
const {
|
|
64
|
+
const { getByDisplayValue, getByTestId } = setup();
|
|
59
65
|
|
|
60
|
-
fireEvent.change(getByTestId(
|
|
66
|
+
fireEvent.change(getByTestId('autocomplete'), {
|
|
61
67
|
target: { value: 'Köpeniker' },
|
|
62
68
|
});
|
|
63
69
|
|
|
64
|
-
|
|
70
|
+
addressFieldTestIds.forEach((testId) =>
|
|
71
|
+
expect(getByTestId(testId)).toBeInTheDocument()
|
|
72
|
+
);
|
|
65
73
|
expect(getByDisplayValue('Köpeniker Strasse')).toBeVisible();
|
|
66
74
|
});
|
|
67
75
|
|
|
68
76
|
it('Should enable to enter the address manually', async () => {
|
|
69
77
|
const callback = jest.fn();
|
|
70
|
-
const { findByText,
|
|
78
|
+
const { findByText, getByTestId, user } = setup(undefined, callback);
|
|
71
79
|
const btn = await findByText('enter address manually');
|
|
72
80
|
|
|
73
81
|
await user.click(btn);
|
|
74
82
|
|
|
75
83
|
// fill out all fields
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
await user.type(
|
|
79
|
-
await user.type(
|
|
80
|
-
await user.type(inputs[3], '10179');
|
|
81
|
-
await user.type(inputs[4], 'Berlin');
|
|
84
|
+
await user.type(getByTestId('autocomplete'), 'Köpeniker Strasse');
|
|
85
|
+
await user.type(getByTestId('autocomplete-house-number'), '4000');
|
|
86
|
+
await user.type(getByTestId('autocomplete-postcode'), '10179');
|
|
87
|
+
await user.type(getByTestId('autocomplete-city'), 'Berlin');
|
|
82
88
|
|
|
83
89
|
// callback should be called with a complete address
|
|
84
90
|
expect(callback).toHaveBeenCalledWith(address);
|
|
@@ -265,6 +265,7 @@ const AutocompleteAddress = ({
|
|
|
265
265
|
id="autocomplete"
|
|
266
266
|
key="autocomplete-search"
|
|
267
267
|
data-cy="autocomplete"
|
|
268
|
+
data-testid="autocomplete"
|
|
268
269
|
type="text"
|
|
269
270
|
placeholder={
|
|
270
271
|
placeholders?.manualAddressEntry || 'Search for address'
|
|
@@ -275,6 +276,7 @@ const AutocompleteAddress = ({
|
|
|
275
276
|
{hasLoadedGoogleAPI === false && (
|
|
276
277
|
<div
|
|
277
278
|
data-cy="google-api-loader"
|
|
279
|
+
data-testid="google-api-loader"
|
|
278
280
|
className={styles['loading-spinner']}
|
|
279
281
|
>
|
|
280
282
|
<div className="ds-spinner ds-spinner__m" />
|
|
@@ -287,6 +289,7 @@ const AutocompleteAddress = ({
|
|
|
287
289
|
<Input
|
|
288
290
|
className="w100"
|
|
289
291
|
data-cy="autocomplete"
|
|
292
|
+
data-testid="autocomplete"
|
|
290
293
|
key="autocomplete-street"
|
|
291
294
|
type="text"
|
|
292
295
|
placeholder={placeholders?.street || 'Street'}
|
|
@@ -298,6 +301,7 @@ const AutocompleteAddress = ({
|
|
|
298
301
|
<Input
|
|
299
302
|
className={`wmx2 ${styles['house-number-input']}`}
|
|
300
303
|
data-cy="autocomplete-house-number"
|
|
304
|
+
data-testid="autocomplete-house-number"
|
|
301
305
|
key="autocomplete-house-number"
|
|
302
306
|
placeholder={placeholders?.houseNumber || 'House number'}
|
|
303
307
|
value={address?.houseNumber || ''}
|
|
@@ -309,6 +313,7 @@ const AutocompleteAddress = ({
|
|
|
309
313
|
<Input
|
|
310
314
|
className="mt16"
|
|
311
315
|
data-cy="autocomplete-additional-info"
|
|
316
|
+
data-testid="autocomplete-additional-info"
|
|
312
317
|
key="autocomplete-additional-info"
|
|
313
318
|
placeholder={
|
|
314
319
|
placeholders?.additionalInformation ||
|
|
@@ -323,6 +328,7 @@ const AutocompleteAddress = ({
|
|
|
323
328
|
<Input
|
|
324
329
|
className="w100"
|
|
325
330
|
data-cy="autocomplete-postcode"
|
|
331
|
+
data-testid="autocomplete-postcode"
|
|
326
332
|
key="autocomplete-postcode"
|
|
327
333
|
placeholder={placeholders?.postcode || 'Postcode'}
|
|
328
334
|
value={address?.postcode || ''}
|
|
@@ -333,6 +339,7 @@ const AutocompleteAddress = ({
|
|
|
333
339
|
<Input
|
|
334
340
|
className="w100"
|
|
335
341
|
data-cy="autocomplete-city"
|
|
342
|
+
data-testid="autocomplete-city"
|
|
336
343
|
key="autocomplete-city"
|
|
337
344
|
placeholder={placeholders?.city || 'City'}
|
|
338
345
|
value={address?.city || ''}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { fireEvent, render, screen } from '../../util/testUtils';
|
|
2
|
+
import { DownloadButton } from '.';
|
|
3
|
+
|
|
4
|
+
describe('DownloadButton', () => {
|
|
5
|
+
it.each(['INITIAL', 'FAILED'] as const)(
|
|
6
|
+
'exposes the %s download button as download-documents-button',
|
|
7
|
+
(downloadStatus) => {
|
|
8
|
+
const onDownload = jest.fn();
|
|
9
|
+
|
|
10
|
+
render(
|
|
11
|
+
<DownloadButton
|
|
12
|
+
downloadStatus={downloadStatus}
|
|
13
|
+
onDownload={onDownload}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
fireEvent.click(screen.getByTestId('download-documents-button'));
|
|
18
|
+
|
|
19
|
+
expect(onDownload).toHaveBeenCalledTimes(1);
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { render, screen } from '../../../util/testUtils';
|
|
2
|
+
import { AutoSuggestInput } from '.';
|
|
3
|
+
|
|
4
|
+
describe('AutoSuggestInput', () => {
|
|
5
|
+
it('exposes its input as suggest-multi-select-input', () => {
|
|
6
|
+
render(
|
|
7
|
+
<AutoSuggestInput
|
|
8
|
+
currentOption=""
|
|
9
|
+
suggestions={[]}
|
|
10
|
+
handleSuggestionSelected={jest.fn()}
|
|
11
|
+
onChange={jest.fn()}
|
|
12
|
+
handleSuggestionFetchRequest={jest.fn()}
|
|
13
|
+
handleSuggestionClearRequest={jest.fn()}
|
|
14
|
+
placeholder="Search countries"
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
expect(screen.getByTestId('suggest-multi-select-input').tagName).toBe(
|
|
19
|
+
'INPUT'
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
});
|