@popsure/dirty-swan 0.28.0-beta.2 → 0.28.0-beta.4
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 +21 -25
- package/dist/index.js.map +1 -1
- package/dist/lib/components/autocompleteAddress/index.d.ts +3 -3
- package/dist/lib/components/autocompleteAddress/modes/dynamic.d.ts +2 -1
- package/dist/lib/components/autocompleteAddress/modes/manual.d.ts +3 -1
- package/package.json +1 -1
- package/src/lib/components/autocompleteAddress/demo.tsx +3 -3
- package/src/lib/components/autocompleteAddress/index.tsx +9 -12
- package/src/lib/components/autocompleteAddress/modes/dynamic.tsx +4 -2
- package/src/lib/components/autocompleteAddress/modes/manual.tsx +11 -7
- package/src/lib/components/autocompleteAddress/util/googleMapsLoader.tsx +1 -0
package/dist/index.js
CHANGED
|
@@ -3366,20 +3366,20 @@ var Input = require$$0__default['default'].forwardRef(function (_a, ref) {
|
|
|
3366
3366
|
error && (jsxRuntime.jsx("p", __assign({ className: "p-p--small tc-red-500 w100 " + styles$n.error }, { children: error }), void 0))] }), void 0));
|
|
3367
3367
|
});
|
|
3368
3368
|
|
|
3369
|
-
var GERMANY_ALPHA_CODE = 'DE';
|
|
3369
|
+
var GERMANY_ALPHA_CODE = 'DE';
|
|
3370
3370
|
var ManualAddressEntry = function (_a) {
|
|
3371
|
-
var address = _a.address, onAddressChange = _a.onAddressChange;
|
|
3371
|
+
var address = _a.address, onAddressChange = _a.onAddressChange, placeholders = _a.placeholders;
|
|
3372
3372
|
var handleInputChange = function (event) {
|
|
3373
3373
|
var _a;
|
|
3374
3374
|
onAddressChange(__assign(__assign(__assign({}, address), (_a = {}, _a[event.target.name] = event.target.value, _a)), ((address === null || address === void 0 ? void 0 : address.country)
|
|
3375
3375
|
? { country: address.country }
|
|
3376
3376
|
: { country: GERMANY_ALPHA_CODE })));
|
|
3377
3377
|
};
|
|
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:
|
|
3379
|
-
jsxRuntime.jsx(Input, { className: "wmx2 " + styles$o['house-number-input'], "data-cy": "autocomplete-house-number", placeholder:
|
|
3380
|
-
jsxRuntime.jsx(Input, { className: "mt16", "data-cy": "autocomplete-additional-info", placeholder:
|
|
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:
|
|
3382
|
-
jsxRuntime.jsx(Input, { className: "w100", "data-cy": "autocomplete-city", placeholder:
|
|
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));
|
|
3383
3383
|
};
|
|
3384
3384
|
|
|
3385
3385
|
function _extends() {
|
|
@@ -3672,11 +3672,11 @@ var styles$m = {"suggestionList":"dynamic-module_suggestionList__2YcUi","appear-
|
|
|
3672
3672
|
styleInject(css_248z$n);
|
|
3673
3673
|
|
|
3674
3674
|
var DynamicAddressEntry = function (_a) {
|
|
3675
|
-
var isGeometryEnabled = _a.isGeometryEnabled, initialAddress = _a.address, onAddressChange = _a.onAddressChange, onGeometryChange = _a.onGeometryChange;
|
|
3676
|
-
var
|
|
3675
|
+
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
|
+
var _c = usePlacesAutocomplete({
|
|
3677
3677
|
debounce: 400,
|
|
3678
|
-
defaultValue: initialAddress === null || initialAddress === void 0 ? void 0 : initialAddress.street,
|
|
3679
|
-
}), ready =
|
|
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) : '',
|
|
3679
|
+
}), ready = _c.ready, value = _c.value, _d = _c.suggestions, status = _d.status, data = _d.data, setValue = _c.setValue, clearSuggestions = _c.clearSuggestions;
|
|
3680
3680
|
var handleInput = function (e) {
|
|
3681
3681
|
setValue(e.target.value);
|
|
3682
3682
|
};
|
|
@@ -3713,7 +3713,7 @@ var DynamicAddressEntry = function (_a) {
|
|
|
3713
3713
|
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
3714
|
});
|
|
3715
3715
|
};
|
|
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:
|
|
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),
|
|
3717
3717
|
status === 'OK' && (jsxRuntime.jsx("ul", __assign({ className: styles$m.suggestionList }, { children: renderSuggestions() }), void 0))] }), void 0) }, void 0));
|
|
3718
3718
|
};
|
|
3719
3719
|
|
|
@@ -4073,31 +4073,27 @@ function useJsApiLoader(_a) {
|
|
|
4073
4073
|
setLoadError(error);
|
|
4074
4074
|
});
|
|
4075
4075
|
}
|
|
4076
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4076
4077
|
}, []);
|
|
4077
4078
|
return { isLoaded: isLoaded, loadError: loadError };
|
|
4078
4079
|
}
|
|
4079
4080
|
|
|
4080
4081
|
var AutoCompleteAddress = function (_a) {
|
|
4081
|
-
var _b = _a.mapId, mapId = _b === void 0 ? 'map' : _b, apiKey = _a.apiKey,
|
|
4082
|
+
var _b = _a.mapId, mapId = _b === void 0 ? 'map' : _b, apiKey = _a.apiKey, address = _a.address, _c = _a.staticVersion, staticVersion = _c === void 0 ? !!process.env.STORYBOOK_STATIC : _c, onAddressChange = _a.onAddressChange, manualAddressEntryTexts = _a.manualAddressEntryTexts, placeholders = _a.placeholders;
|
|
4082
4083
|
var _d = require$$0.useState(false), isLoading = _d[0], setIsLoading = _d[1];
|
|
4083
|
-
var _e = require$$0.useState(
|
|
4084
|
-
var _f = require$$0.useState(
|
|
4085
|
-
var _g = require$$0.useState(!!initialAddress), manualAddressEntry = _g[0], setManualAddressEntry = _g[1];
|
|
4084
|
+
var _e = require$$0.useState(undefined), geometry = _e[0], setGeometry = _e[1];
|
|
4085
|
+
var _f = require$$0.useState(!!address), manualAddressEntry = _f[0], setManualAddressEntry = _f[1];
|
|
4086
4086
|
// you can read more about it here:
|
|
4087
4087
|
// https://github.com/JustFly1984/react-google-maps-api/blob/develop/packages/react-google-maps-api/src/useJsApiLoader.md
|
|
4088
|
-
var
|
|
4088
|
+
var _g = useJsApiLoader({
|
|
4089
4089
|
googleMapsApiKey: apiKey,
|
|
4090
|
-
}), hasLoadedGoogleAPI =
|
|
4090
|
+
}), hasLoadedGoogleAPI = _g.isLoaded, loadGoogleAPIError = _g.loadError;
|
|
4091
4091
|
var isGeometryEnabled = !staticVersion;
|
|
4092
4092
|
var handleModeSwitch = function (event) {
|
|
4093
4093
|
setManualAddressEntry(event.currentTarget.dataset.value === 'true');
|
|
4094
4094
|
};
|
|
4095
|
-
var handleAddressChange = function (address) {
|
|
4096
|
-
setAddress(address);
|
|
4097
|
-
onAddressChange(address);
|
|
4098
|
-
};
|
|
4099
4095
|
var handleDynamicAddress = function (address) {
|
|
4100
|
-
|
|
4096
|
+
onAddressChange(address);
|
|
4101
4097
|
setManualAddressEntry(true);
|
|
4102
4098
|
};
|
|
4103
4099
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -4115,7 +4111,7 @@ var AutoCompleteAddress = function (_a) {
|
|
|
4115
4111
|
});
|
|
4116
4112
|
}, 1000), [lodash_debounce]);
|
|
4117
4113
|
var handleManualAddress = function (address) {
|
|
4118
|
-
|
|
4114
|
+
onAddressChange(address);
|
|
4119
4115
|
if (isGeometryEnabled) {
|
|
4120
4116
|
setIsLoading(true);
|
|
4121
4117
|
updateMapGeometry(address);
|
|
@@ -4124,7 +4120,7 @@ var AutoCompleteAddress = function (_a) {
|
|
|
4124
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}>}
|
|
4125
4121
|
),
|
|
4126
4122
|
loadGoogleAPIError && jsxRuntime.jsx("p", { children: "Google API is not responding." }, void 0),
|
|
4127
|
-
hasLoadedGoogleAPI && (jsxRuntime.jsx("div", __assign({ className: "wmx8" }, { children: manualAddressEntry || loadGoogleAPIError ? (jsxRuntime.jsx(ManualAddressEntry, { address: address, onAddressChange: handleManualAddress }, void 0)) : (jsxRuntime.jsx(DynamicAddressEntry, { address: address, onAddressChange: handleDynamicAddress, isGeometryEnabled: isGeometryEnabled, onGeometryChange: setGeometry }, void 0)) }), 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)),
|
|
4128
4124
|
manualAddressEntry ? (jsxRuntime.jsxs("div", __assign({ className: "p-p mt8" }, { children: [(manualAddressEntryTexts === null || manualAddressEntryTexts === void 0 ? void 0 : manualAddressEntryTexts.preText) || 'Or ',
|
|
4129
4125
|
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 ',
|
|
4130
4126
|
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));
|