@popsure/dirty-swan 0.28.0-beta.4 → 0.28.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3314,23 +3314,12 @@ var MAP_CONFIG_OBJ = {
3314
3314
  rotateControl: false,
3315
3315
  draggable: false,
3316
3316
  };
3317
- function GoogleMapsWrapper(_a) {
3317
+ var GoogleMapsWrapperComponent = function (_a) {
3318
3318
  var _b;
3319
- var mapId = _a.mapId, geometry = _a.geometry, hasLoadedGoogleAPI = _a.hasLoadedGoogleAPI, isLoading = _a.isLoading;
3319
+ var mapId = _a.mapId, markerLocation = _a.markerLocation, isLoading = _a.isLoading;
3320
3320
  var map = require$$0.useRef(null);
3321
3321
  var marker = require$$0.useRef(null);
3322
3322
  require$$0.useEffect(function () {
3323
- var _a, _b, _c;
3324
- if (geometry === null || geometry === void 0 ? void 0 : geometry.location) {
3325
- (_a = map.current) === null || _a === void 0 ? void 0 : _a.panTo(geometry.location);
3326
- (_b = map.current) === null || _b === void 0 ? void 0 : _b.setZoom(15);
3327
- (_c = marker.current) === null || _c === void 0 ? void 0 : _c.setPosition(geometry.location);
3328
- }
3329
- }, [geometry]);
3330
- require$$0.useEffect(function () {
3331
- if (!hasLoadedGoogleAPI) {
3332
- return;
3333
- }
3334
3323
  map.current = new google.maps.Map(document.getElementById(mapId), MAP_CONFIG_OBJ);
3335
3324
  Promise.resolve().then(function () { return require('./mapStyle-32849fbf.js'); }).then(function (_a) {
3336
3325
  var _b, _c;
@@ -3341,15 +3330,33 @@ function GoogleMapsWrapper(_a) {
3341
3330
  marker.current = new google.maps.Marker({
3342
3331
  map: map.current,
3343
3332
  });
3344
- }, [hasLoadedGoogleAPI, mapId]);
3333
+ }, [mapId]);
3334
+ require$$0.useEffect(function () {
3335
+ var _a, _b, _c;
3336
+ if (markerLocation) {
3337
+ (_a = map.current) === null || _a === void 0 ? void 0 : _a.panTo(markerLocation);
3338
+ (_b = map.current) === null || _b === void 0 ? void 0 : _b.setZoom(15);
3339
+ (_c = marker.current) === null || _c === void 0 ? void 0 : _c.setPosition(markerLocation);
3340
+ }
3341
+ }, [markerLocation]);
3345
3342
  if (document.querySelectorAll("[id='" + mapId + "']").length > 1) {
3346
3343
  throw Error("This MapId is already in use: " + mapId);
3347
3344
  }
3348
3345
  return (jsxRuntime.jsxs("div", __assign({ className: classNames("wmx8 bg-grey-500 " + styles$o['map-container'], (_b = {},
3349
- _b[styles$o['map-container--hidden']] = geometry === undefined,
3346
+ _b[styles$o['map-container--hidden']] = markerLocation === undefined,
3350
3347
  _b)) }, { children: [jsxRuntime.jsx("div", { className: styles$o.map, id: mapId }, void 0),
3351
3348
  isLoading && (jsxRuntime.jsx("div", __assign({ className: styles$o['loading-spinner'] }, { children: jsxRuntime.jsx("div", { className: "ds-spinner ds-spinner__m" }, void 0) }), void 0))] }), void 0));
3349
+ };
3350
+ function areEqual(prevProps, nextProps) {
3351
+ var _a;
3352
+ if (prevProps.isLoading === nextProps.isLoading && ((_a = prevProps.markerLocation) === null || _a === void 0 ? void 0 : _a.equals(nextProps.markerLocation))) {
3353
+ return true;
3354
+ }
3355
+ else {
3356
+ return false;
3357
+ }
3352
3358
  }
3359
+ var GoogleMapsWrapper = require$$0.memo(GoogleMapsWrapperComponent, areEqual);
3353
3360
 
3354
3361
  var css_248z$o = ".style-module_container__2L4SP {\n position: relative;\n}\n\n.style-module_prefix__3jAFZ {\n position: absolute;\n left: 16px;\n top: 50%;\n transform: translateY(-50%);\n color: var(--ds-grey-500);\n transition: 0.3s top;\n}\n.style-module_prefix--with-error__1yTTM {\n color: var(--ds-red-500);\n}\n.style-module_prefix--disabled__2-gcw {\n color: var(--ds-grey-600);\n}\n\n.style-module_input__1eJO5:not(:placeholder-shown) ~ .style-module_placeholder__1U2z0,\n.style-module_input__1eJO5:focus ~ .style-module_placeholder__1U2z0 {\n top: 7px;\n left: 16px;\n transform: translateY(0);\n font-size: 10px;\n line-height: 12px;\n opacity: 1;\n}\n\n.style-module_input__1eJO5:focus ~ .style-module_placeholder__1U2z0 {\n color: var(--ds-primary-500);\n}\n.style-module_input__1eJO5:focus ~ .style-module_placeholder--with-error__2ieRU {\n color: var(--ds-red-500);\n}\n\n.style-module_input__1eJO5:focus ~ .style-module_prefix__3jAFZ {\n color: var(--ds-primary-500);\n}\n.style-module_input__1eJO5:focus ~ .style-module_prefix--with-error__1yTTM {\n color: var(--ds-red-500);\n}\n\n.style-module_input__1eJO5:not(:placeholder-shown) ~ .style-module_prefix__3jAFZ,\n.style-module_input__1eJO5:focus ~ .style-module_prefix__3jAFZ {\n top: 28px;\n}\n\n.style-module_input__1eJO5 {\n box-sizing: border-box;\n padding-top: 9px;\n font-family: inherit;\n}\n.style-module_input--no-placeholder__3EGwh {\n padding-top: 0px;\n}\n.style-module_input--with-prefix__38e0j {\n padding-left: 32px !important;\n}\n\n.style-module_placeholder__1U2z0 {\n position: absolute;\n pointer-events: none;\n left: 16px;\n top: 50%;\n transform: translateY(-50%);\n transition: 0.3s ease all;\n color: var(--ds-grey-500);\n}\n.style-module_placeholder--with-prefix__2PquQ {\n left: 32px;\n}\n.style-module_placeholder--with-error__2ieRU {\n color: var(--ds-red-500);\n}\n\n.style-module_error__167Zc {\n margin-top: 4px;\n}";
3355
3362
  var styles$n = {"container":"style-module_container__2L4SP","prefix":"style-module_prefix__3jAFZ","prefix--with-error":"style-module_prefix--with-error__1yTTM","prefix--disabled":"style-module_prefix--disabled__2-gcw","input":"style-module_input__1eJO5","placeholder":"style-module_placeholder__1U2z0","placeholder--with-error":"style-module_placeholder--with-error__2ieRU","input--no-placeholder":"style-module_input--no-placeholder__3EGwh","input--with-prefix":"style-module_input--with-prefix__38e0j","placeholder--with-prefix":"style-module_placeholder--with-prefix__2PquQ","error":"style-module_error__167Zc"};
@@ -3366,20 +3373,20 @@ var Input = require$$0__default['default'].forwardRef(function (_a, ref) {
3366
3373
  error && (jsxRuntime.jsx("p", __assign({ className: "p-p--small tc-red-500 w100 " + styles$n.error }, { children: error }), void 0))] }), void 0));
3367
3374
  });
3368
3375
 
3369
- var GERMANY_ALPHA_CODE = 'DE';
3376
+ var GERMANY_ALPHA_CODE$1 = 'DE'; // default country can be cumbersome for new country implementation
3370
3377
  var ManualAddressEntry = function (_a) {
3371
3378
  var address = _a.address, onAddressChange = _a.onAddressChange, placeholders = _a.placeholders;
3372
3379
  var handleInputChange = function (event) {
3373
3380
  var _a;
3374
3381
  onAddressChange(__assign(__assign(__assign({}, address), (_a = {}, _a[event.target.name] = event.target.value, _a)), ((address === null || address === void 0 ? void 0 : address.country)
3375
- ? { country: address.country }
3376
- : { country: GERMANY_ALPHA_CODE })));
3382
+ ? {}
3383
+ : { country: GERMANY_ALPHA_CODE$1 })));
3377
3384
  };
3378
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", __assign({ className: "d-flex c-gap16 " + styles$o['input-line'] }, { children: [jsxRuntime.jsx(Input, { className: "w100", "data-cy": "autocomplete", type: "text", placeholder: placeholders === null || placeholders === void 0 ? void 0 : placeholders.street, value: (address === null || address === void 0 ? void 0 : address.street) || '', name: "street", onChange: handleInputChange }, void 0),
3379
- jsxRuntime.jsx(Input, { className: "wmx2 " + styles$o['house-number-input'], "data-cy": "autocomplete-house-number", placeholder: placeholders === null || placeholders === void 0 ? void 0 : placeholders.houseNumber, value: (address === null || address === void 0 ? void 0 : address.houseNumber) || '', name: "houseNumber", onChange: handleInputChange }, void 0)] }), void 0),
3380
- jsxRuntime.jsx(Input, { className: "mt16", "data-cy": "autocomplete-additional-info", placeholder: placeholders === null || placeholders === void 0 ? void 0 : placeholders.additionalInformation, value: (address === null || address === void 0 ? void 0 : address.additionalInformation) || '', name: "additionalInformation", onChange: handleInputChange }, void 0),
3381
- jsxRuntime.jsxs("div", __assign({ className: "d-flex c-gap16 mt16 " + styles$o['input-line'] }, { children: [jsxRuntime.jsx(Input, { className: "w100", "data-cy": "autocomplete-postcode", placeholder: placeholders === null || placeholders === void 0 ? void 0 : placeholders.postcode, value: (address === null || address === void 0 ? void 0 : address.postcode) || '', name: "postcode", onChange: handleInputChange }, void 0),
3382
- jsxRuntime.jsx(Input, { className: "w100", "data-cy": "autocomplete-city", placeholder: placeholders === null || placeholders === void 0 ? void 0 : placeholders.city, value: (address === null || address === void 0 ? void 0 : address.city) || '', name: "city", onChange: handleInputChange }, void 0)] }), void 0)] }, void 0));
3385
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", __assign({ className: "d-flex c-gap16 " + styles$o['input-line'] }, { children: [jsxRuntime.jsx(Input, { className: "w100", "data-cy": "autocomplete", type: "text", placeholder: placeholders === null || placeholders === void 0 ? void 0 : placeholders.street, defaultValue: (address === null || address === void 0 ? void 0 : address.street) || '', name: "street", onChange: handleInputChange }, void 0),
3386
+ jsxRuntime.jsx(Input, { className: "wmx2 " + styles$o['house-number-input'], "data-cy": "autocomplete-house-number", placeholder: placeholders === null || placeholders === void 0 ? void 0 : placeholders.houseNumber, defaultValue: (address === null || address === void 0 ? void 0 : address.houseNumber) || '', name: "houseNumber", onChange: handleInputChange }, void 0)] }), void 0),
3387
+ jsxRuntime.jsx(Input, { className: "mt16", "data-cy": "autocomplete-additional-info", placeholder: placeholders === null || placeholders === void 0 ? void 0 : placeholders.additionalInformation, defaultValue: (address === null || address === void 0 ? void 0 : address.additionalInformation) || '', name: "additionalInformation", onChange: handleInputChange }, void 0),
3388
+ jsxRuntime.jsxs("div", __assign({ className: "d-flex c-gap16 mt16 " + styles$o['input-line'] }, { children: [jsxRuntime.jsx(Input, { className: "w100", "data-cy": "autocomplete-postcode", placeholder: placeholders === null || placeholders === void 0 ? void 0 : placeholders.postcode, defaultValue: (address === null || address === void 0 ? void 0 : address.postcode) || '', name: "postcode", onChange: handleInputChange }, void 0),
3389
+ jsxRuntime.jsx(Input, { className: "w100", "data-cy": "autocomplete-city", placeholder: placeholders === null || placeholders === void 0 ? void 0 : placeholders.city, defaultValue: (address === null || address === void 0 ? void 0 : address.city) || '', name: "city", onChange: handleInputChange }, void 0)] }), void 0)] }, void 0));
3383
3390
  };
3384
3391
 
3385
3392
  function _extends() {
@@ -3667,15 +3674,19 @@ var inlineAddress = function (address) {
3667
3674
  return address.street + " " + address.houseNumber + ", " + address.city + ", " + $5(address.country);
3668
3675
  };
3669
3676
 
3670
- var css_248z$n = "@keyframes dynamic-module_appear-in__2D3HS {\n from {\n opacity: 0;\n transform: translateY(10px);\n }\n to {\n opacity: 1;\n }\n}\n.dynamic-module_suggestionList__2YcUi {\n z-index: 9000;\n width: 100%;\n position: absolute;\n background-color: white;\n border: 1px solid var(--ds-grey-400);\n box-shadow: none;\n border-radius: 8px;\n margin-top: 8px;\n animation-name: dynamic-module_appear-in__2D3HS;\n animation-duration: 0.3s;\n animation-fill-mode: both;\n}\n.dynamic-module_suggestionList__2YcUi::after {\n content: \"\";\n display: none;\n}\n\n.dynamic-module_suggestionItem__2-eVX {\n display: flex;\n align-items: center;\n height: 48px;\n cursor: pointer;\n border-top: none;\n font-family: Lato, sans-serif;\n padding-left: 16px;\n}\n.dynamic-module_suggestionItem__2-eVX:hover {\n background-color: var(--ds-grey-200);\n}\n.dynamic-module_suggestionItem__2-eVX:first-child {\n border-top-left-radius: 8px;\n border-top-right-radius: 8px;\n}\n\n.dynamic-module_pac-matched__14uns,\n.dynamic-module_suggestionItem-query__Slroi,\n.dynamic-module_suggestionItem__2-eVX {\n font-size: 16px;\n}\n\n.dynamic-module_pac-icon__2RRIL {\n display: none;\n}";
3677
+ var css_248z$n = "@keyframes dynamic-module_appear-in__2D3HS {\n from {\n opacity: 0;\n transform: translateY(10px);\n }\n to {\n opacity: 1;\n }\n}\n.dynamic-module_suggestionList__2YcUi {\n z-index: 9000;\n width: 100%;\n position: absolute;\n background-color: white;\n border: 1px solid var(--ds-grey-400);\n box-shadow: none;\n border-radius: 8px;\n margin-top: 8px;\n animation-name: dynamic-module_appear-in__2D3HS;\n animation-duration: 0.3s;\n animation-fill-mode: both;\n}\n.dynamic-module_suggestionList__2YcUi::after {\n content: \"\";\n display: none;\n}\n\n.dynamic-module_suggestionItem__2-eVX {\n display: flex;\n align-items: center;\n height: 48px;\n cursor: pointer;\n border-top: none;\n font-family: Lato, sans-serif;\n padding-left: 16px;\n}\n.dynamic-module_suggestionItem__2-eVX:hover {\n background-color: var(--ds-grey-200);\n}\n.dynamic-module_suggestionItem__2-eVX:first-child {\n border-top-left-radius: 8px;\n border-top-right-radius: 8px;\n}\n.dynamic-module_suggestionItem__2-eVX:last-child {\n border-bottom-left-radius: 8px;\n border-bottom-right-radius: 8px;\n}\n\n.dynamic-module_pac-matched__14uns,\n.dynamic-module_suggestionItem-query__Slroi,\n.dynamic-module_suggestionItem__2-eVX {\n font-size: 16px;\n}\n\n.dynamic-module_pac-icon__2RRIL {\n display: none;\n}";
3671
3678
  var styles$m = {"suggestionList":"dynamic-module_suggestionList__2YcUi","appear-in":"dynamic-module_appear-in__2D3HS","suggestionItem":"dynamic-module_suggestionItem__2-eVX","pac-matched":"dynamic-module_pac-matched__14uns","suggestionItem-query":"dynamic-module_suggestionItem-query__Slroi","pac-icon":"dynamic-module_pac-icon__2RRIL"};
3672
3679
  styleInject(css_248z$n);
3673
3680
 
3681
+ var GERMANY_ALPHA_CODE = 'DE'; // default country can be cumbersome for new country implementation
3674
3682
  var DynamicAddressEntry = function (_a) {
3675
3683
  var isGeometryEnabled = _a.isGeometryEnabled, initialAddress = _a.address, onAddressChange = _a.onAddressChange, onGeometryChange = _a.onGeometryChange, _b = _a.manualAddressEntryText, manualAddressEntryText = _b === void 0 ? "Search for address" : _b;
3676
3684
  var _c = usePlacesAutocomplete({
3677
3685
  debounce: 400,
3678
- defaultValue: (initialAddress === null || initialAddress === void 0 ? void 0 : initialAddress.street) ? (initialAddress === null || initialAddress === void 0 ? void 0 : initialAddress.street) + " " + (initialAddress === null || initialAddress === void 0 ? void 0 : initialAddress.houseNumber) : '',
3686
+ defaultValue: (initialAddress === null || initialAddress === void 0 ? void 0 : initialAddress.street) ? (initialAddress === null || initialAddress === void 0 ? void 0 : initialAddress.street) + " " + initialAddress.houseNumber : '',
3687
+ requestOptions: {
3688
+ componentRestrictions: { country: GERMANY_ALPHA_CODE },
3689
+ }
3679
3690
  }), ready = _c.ready, value = _c.value, _d = _c.suggestions, status = _d.status, data = _d.data, setValue = _c.setValue, clearSuggestions = _c.clearSuggestions;
3680
3691
  var handleInput = function (e) {
3681
3692
  setValue(e.target.value);
@@ -3713,7 +3724,7 @@ var DynamicAddressEntry = function (_a) {
3713
3724
  return (jsxRuntime.jsxs("li", __assign({ onClick: handleSelect(suggestion), className: styles$m.suggestionItem }, { children: [jsxRuntime.jsx("span", __assign({ className: "fw-bold pr8" }, { children: main_text }), void 0), ' ', jsxRuntime.jsx("small", { children: secondary_text }, void 0)] }), place_id));
3714
3725
  });
3715
3726
  };
3716
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", __assign({ style: { position: 'relative' } }, { children: [jsxRuntime.jsx(Input, { className: "w100", id: "autocomplete", "data-cy": "autocomplete", type: "text", placeholder: manualAddressEntryText, disabled: !ready, onChange: handleInput, value: value }, void 0),
3727
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", __assign({ style: { position: 'relative' } }, { children: [jsxRuntime.jsx(Input, { className: "w100", id: "autocomplete", "data-cy": "autocomplete", type: "text", placeholder: manualAddressEntryText, disabled: !ready, onChange: handleInput, value: value, autoComplete: "nope" }, void 0),
3717
3728
  status === 'OK' && (jsxRuntime.jsx("ul", __assign({ className: styles$m.suggestionList }, { children: renderSuggestions() }), void 0))] }), void 0) }, void 0));
3718
3729
  };
3719
3730
 
@@ -4117,10 +4128,13 @@ var AutoCompleteAddress = function (_a) {
4117
4128
  updateMapGeometry(address);
4118
4129
  }
4119
4130
  };
4120
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [isGeometryEnabled && address && (jsxRuntime.jsx(GoogleMapsWrapper, { mapId: mapId, hasLoadedGoogleAPI: hasLoadedGoogleAPI, geometry: geometry, isLoading: isLoading }, void 0) // this can be composable <AutocompleteAddress>{({geometry} ) => <GoogleMapsWrapper geometry={geometry}>}
4131
+ if (!hasLoadedGoogleAPI) {
4132
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {}, void 0);
4133
+ }
4134
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [isGeometryEnabled && address && (jsxRuntime.jsx(GoogleMapsWrapper, { mapId: mapId, markerLocation: geometry === null || geometry === void 0 ? void 0 : geometry.location, isLoading: isLoading }, void 0) // this can be composable <AutocompleteAddress>{({geometry} ) => <GoogleMapsWrapper geometry={geometry}>}
4121
4135
  ),
4122
4136
  loadGoogleAPIError && jsxRuntime.jsx("p", { children: "Google API is not responding." }, void 0),
4123
- hasLoadedGoogleAPI && (jsxRuntime.jsx("div", __assign({ className: "wmx8" }, { children: manualAddressEntry || loadGoogleAPIError ? (jsxRuntime.jsx(ManualAddressEntry, { address: address, onAddressChange: handleManualAddress, placeholders: placeholders }, void 0)) : (jsxRuntime.jsx(DynamicAddressEntry, { address: address, onAddressChange: handleDynamicAddress, isGeometryEnabled: isGeometryEnabled, onGeometryChange: setGeometry, manualAddressEntryText: placeholders === null || placeholders === void 0 ? void 0 : placeholders.manualAddressEntry }, void 0)) }), void 0)),
4137
+ jsxRuntime.jsx("div", __assign({ className: "wmx8" }, { children: manualAddressEntry || loadGoogleAPIError ? (jsxRuntime.jsx(ManualAddressEntry, { address: address, onAddressChange: handleManualAddress, placeholders: placeholders }, void 0)) : (jsxRuntime.jsx(DynamicAddressEntry, { address: address, onAddressChange: handleDynamicAddress, isGeometryEnabled: isGeometryEnabled, onGeometryChange: setGeometry, manualAddressEntryText: placeholders === null || placeholders === void 0 ? void 0 : placeholders.manualAddressEntry }, void 0)) }), void 0),
4124
4138
  manualAddressEntry ? (jsxRuntime.jsxs("div", __assign({ className: "p-p mt8" }, { children: [(manualAddressEntryTexts === null || manualAddressEntryTexts === void 0 ? void 0 : manualAddressEntryTexts.preText) || 'Or ',
4125
4139
  jsxRuntime.jsx("button", __assign({ className: "p-a bg-transparent fw-bold c-pointer", onClick: handleModeSwitch, "data-value": 'false', type: "button" }, { children: (manualAddressEntryTexts === null || manualAddressEntryTexts === void 0 ? void 0 : manualAddressEntryTexts.cta) || 'Enter address dynamically' }), void 0)] }), void 0)) : (jsxRuntime.jsxs("div", __assign({ className: "p-p mt8" }, { children: [(manualAddressEntryTexts === null || manualAddressEntryTexts === void 0 ? void 0 : manualAddressEntryTexts.preText) || 'Or ',
4126
4140
  jsxRuntime.jsx("button", __assign({ className: "p-a bg-transparent fw-bold c-pointer", onClick: handleModeSwitch, "data-value": 'true', type: "button" }, { children: (manualAddressEntryTexts === null || manualAddressEntryTexts === void 0 ? void 0 : manualAddressEntryTexts.cta) || 'Enter address manually' }), void 0)] }), void 0))] }, void 0));