react-google-geocoding
Advanced tools
Comparing version 0.2.7 to 0.2.8
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n,o,i=t(e),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var f=u(function(){if(o)return n;o=1;var e=/^\s+|\s+$/g,t=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,u=/^0o[0-7]+$/i,f=parseInt,c="object"==typeof r&&r&&r.Object===Object&&r,a="object"==typeof self&&self&&self.Object===Object&&self,s=c||a||Function("return this")(),l=Object.prototype.toString,d=Math.max,p=Math.min,v=function(){return s.Date.now()};function g(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function y(n){if("number"==typeof n)return n;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==l.call(e)}(n))return NaN;if(g(n)){var o="function"==typeof n.valueOf?n.valueOf():n;n=g(o)?o+"":o}if("string"!=typeof n)return 0===n?n:+n;n=n.replace(e,"");var r=i.test(n);return r||u.test(n)?f(n.slice(2),r?2:8):t.test(n)?NaN:+n}return n=function(e,t,n){var o,i,r,u,f,c,a=0,s=!1,l=!1,b=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function m(t){var n=o,r=i;return o=i=void 0,a=t,u=e.apply(r,n)}function w(e){var n=e-c;return void 0===c||n>=t||n<0||l&&e-a>=r}function h(){var e=v();if(w(e))return j(e);f=setTimeout(h,function(e){var n=t-(e-c);return l?p(n,r-(e-a)):n}(e))}function j(e){return f=void 0,b&&o?m(e):(o=i=void 0,u)}function O(){var e=v(),n=w(e);if(o=arguments,i=this,c=e,n){if(void 0===f)return function(e){return a=e,f=setTimeout(h,t),s?m(e):u}(c);if(l)return f=setTimeout(h,t),m(c)}return void 0===f&&(f=setTimeout(h,t)),u}return t=y(t)||0,g(n)&&(s=!!n.leading,r=(l="maxWait"in n)?d(y(n.maxWait)||0,t):r,b="trailing"in n?!!n.trailing:b),O.cancel=function(){void 0!==f&&clearTimeout(f),a=0,o=c=i=f=void 0},O.flush=function(){return void 0===f?u:j(v())},O}}());function c(t,n,o){void 0===n&&(n=500);var i=e.useRef();!function(t){var n=e.useRef(t);n.current=t,e.useEffect((function(){return function(){n.current()}}),[])}((function(){i.current&&i.current.cancel()}));var r=e.useMemo((function(){var e=f(t,n,o),r=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.apply(void 0,t)};return r.cancel=function(){e.cancel()},r.isPending=function(){return!!i.current},r.flush=function(){return e.flush()},r}),[t,n,o]);return e.useEffect((function(){i.current=f(t,n,o)}),[t,n,o]),r}exports.usePlacePredictions=function(t){var n=t.input,o=t.debounceMs,r=void 0===o?300:o,u=t.sessionToken,f=t.locationBias,a=t.locationRestriction,s=t.language,l=t.types,d=t.componentRestrictions,p=t.offset,v=t.origin,g=t.region,y=t.location,b=t.radius,m=t.bounds,w=i.default.useRef(null),h=i.default.useState([]),j=h[0],O=h[1],T=i.default.useState(!1),R=T[0],S=T[1],x=i.default.useState(null),E=x[0],P=x[1],M=function(t,n,o){var i,r=null!==(i=null==o?void 0:o.equalityFn)&&void 0!==i?i:function(e,t){return e===t},u=t instanceof Function?t():t,f=e.useState(u),a=f[0],s=f[1],l=e.useRef(u),d=c(s,n,o);return r(l.current,u)||(d(u),l.current=u),[a,d]}(n,r)[0];return i.default.useEffect((function(){void 0!==window&&window.google&&(w.current=new window.google.maps.places.AutocompleteService)}),[]),i.default.useEffect((function(){if(n){if(!w.current)throw new Error("Autocomplete Service not initialized");S(!0),w.current.getPlacePredictions({input:M,language:s,locationBias:f,region:g,offset:p,origin:v,locationRestriction:a,sessionToken:u,types:l,componentRestrictions:d,location:y,radius:b,bounds:m},(function(e,t){O(e||[]),P(t),S(!1)}))}}),[M]),{predictions:j,isLoading:R,status:E}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n,o,i=t(e),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var a=u(function(){if(o)return n;o=1;var e=/^\s+|\s+$/g,t=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,u=/^0o[0-7]+$/i,a=parseInt,c="object"==typeof r&&r&&r.Object===Object&&r,f="object"==typeof self&&self&&self.Object===Object&&self,s=c||f||Function("return this")(),l=Object.prototype.toString,d=Math.max,p=Math.min,v=function(){return s.Date.now()};function y(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function g(n){if("number"==typeof n)return n;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==l.call(e)}(n))return NaN;if(y(n)){var o="function"==typeof n.valueOf?n.valueOf():n;n=y(o)?o+"":o}if("string"!=typeof n)return 0===n?n:+n;n=n.replace(e,"");var r=i.test(n);return r||u.test(n)?a(n.slice(2),r?2:8):t.test(n)?NaN:+n}return n=function(e,t,n){var o,i,r,u,a,c,f=0,s=!1,l=!1,b=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function w(t){var n=o,r=i;return o=i=void 0,f=t,u=e.apply(r,n)}function h(e){var n=e-c;return void 0===c||n>=t||n<0||l&&e-f>=r}function m(){var e=v();if(h(e))return S(e);a=setTimeout(m,function(e){var n=t-(e-c);return l?p(n,r-(e-f)):n}(e))}function S(e){return a=void 0,b&&o?w(e):(o=i=void 0,u)}function O(){var e=v(),n=h(e);if(o=arguments,i=this,c=e,n){if(void 0===a)return function(e){return f=e,a=setTimeout(m,t),s?w(e):u}(c);if(l)return a=setTimeout(m,t),w(c)}return void 0===a&&(a=setTimeout(m,t)),u}return t=g(t)||0,y(n)&&(s=!!n.leading,r=(l="maxWait"in n)?d(g(n.maxWait)||0,t):r,b="trailing"in n?!!n.trailing:b),O.cancel=function(){void 0!==a&&clearTimeout(a),f=0,o=c=i=a=void 0},O.flush=function(){return void 0===a?u:S(v())},O}}());function c(t,n,o){void 0===n&&(n=500);var i=e.useRef();!function(t){var n=e.useRef(t);n.current=t,e.useEffect((function(){return function(){n.current()}}),[])}((function(){i.current&&i.current.cancel()}));var r=e.useMemo((function(){var e=a(t,n,o),r=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.apply(void 0,t)};return r.cancel=function(){e.cancel()},r.isPending=function(){return!!i.current},r.flush=function(){return e.flush()},r}),[t,n,o]);return e.useEffect((function(){i.current=a(t,n,o)}),[t,n,o]),r}function f(e,t,n,o){return new(n||(n=Promise))((function(i,r){function u(e){try{c(o.next(e))}catch(e){r(e)}}function a(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,a)}c((o=o.apply(e,t||[])).next())}))}function s(e,t){var n,o,i,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=a(0),u.throw=a(1),u.return=a(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,a[0]&&(r=0)),r;)try{if(n=1,o&&(i=2&a[0]?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,o=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(!(i=r.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){r=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){r.label=a[1];break}if(6===a[0]&&r.label<i[1]){r.label=i[1],i=a;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(a);break}i[2]&&r.ops.pop(),r.trys.pop();continue}a=t.call(e,r)}catch(e){a=[6,e],o=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}"function"==typeof SuppressedError&&SuppressedError;exports.useDirections=function(e){var t=e.origin,n=e.destination,o=e.language,r=e.region,u=e.avoidFerries,a=e.avoidHighways,c=e.avoidTolls,l=e.drivingOptions,d=e.optimizeWaypoints,p=e.provideRouteAlternatives,v=e.transitOptions,y=e.unitSystem,g=e.waypoints,b=e.travelMode,w=i.default.useRef(null),h=i.default.useState(null),m=h[0],S=h[1],O=i.default.useState(!1),j=O[0],x=O[1],E=i.default.useState(null),T=E[0],R=E[1];i.default.useEffect((function(){void 0!==window&&window.google&&(w.current=new window.google.maps.DirectionsService)}),[]);return i.default.useEffect((function(){if(t||n){if(!w.current)throw new Error("Directions Service not initialized");x(!0),f(void 0,void 0,void 0,(function(){var e;return s(this,(function(i){switch(i.label){case 0:return[4,null===(e=w.current)||void 0===e?void 0:e.route({origin:t,destination:n,language:o,region:r,avoidFerries:u,avoidHighways:a,avoidTolls:c,drivingOptions:l,optimizeWaypoints:d,provideRouteAlternatives:p,transitOptions:v,unitSystem:y,waypoints:g,travelMode:b},(function(e,t){S(e),R(t),x(!1)}))];case 1:return i.sent(),[2]}}))}))}}),[t,n]),{directions:m,isLoading:j,status:T}},exports.usePlacePredictions=function(t){var n=t.input,o=t.debounceMs,r=void 0===o?300:o,u=t.sessionToken,a=t.locationBias,f=t.locationRestriction,s=t.language,l=t.types,d=t.componentRestrictions,p=t.offset,v=t.origin,y=t.region,g=t.location,b=t.radius,w=t.bounds,h=i.default.useRef(null),m=i.default.useState([]),S=m[0],O=m[1],j=i.default.useState(!1),x=j[0],E=j[1],T=i.default.useState(null),R=T[0],M=T[1],P=function(t,n,o){var i,r=null!==(i=null==o?void 0:o.equalityFn)&&void 0!==i?i:function(e,t){return e===t},u=t instanceof Function?t():t,a=e.useState(u),f=a[0],s=a[1],l=e.useRef(u),d=c(s,n,o);return r(l.current,u)||(d(u),l.current=u),[f,d]}(n,r)[0];return i.default.useEffect((function(){void 0!==window&&window.google&&(h.current=new window.google.maps.places.AutocompleteService)}),[]),i.default.useEffect((function(){if(n){if(!h.current)throw new Error("Autocomplete Service not initialized");E(!0),h.current.getPlacePredictions({input:P,language:s,locationBias:a,region:y,offset:p,origin:v,locationRestriction:f,sessionToken:u,types:l,componentRestrictions:d,location:g,radius:b,bounds:w},(function(e,t){O(e||[]),M(t),E(!1)}))}}),[P]),{predictions:S,isLoading:x,status:R}}; |
export * from "./use-place-predictions"; | ||
export * from "./use-directions"; |
@@ -1,1 +0,1 @@ | ||
import n,{useRef as t,useEffect as e,useMemo as o,useState as i}from"react";var r,u,c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function f(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var a=f(function(){if(u)return r;u=1;var n=/^\s+|\s+$/g,t=/^[-+]0x[0-9a-f]+$/i,e=/^0b[01]+$/i,o=/^0o[0-7]+$/i,i=parseInt,f="object"==typeof c&&c&&c.Object===Object&&c,a="object"==typeof self&&self&&self.Object===Object&&self,s=f||a||Function("return this")(),l=Object.prototype.toString,d=Math.max,p=Math.min,v=function(){return s.Date.now()};function g(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function y(r){if("number"==typeof r)return r;if(function(n){return"symbol"==typeof n||function(n){return!!n&&"object"==typeof n}(n)&&"[object Symbol]"==l.call(n)}(r))return NaN;if(g(r)){var u="function"==typeof r.valueOf?r.valueOf():r;r=g(u)?u+"":u}if("string"!=typeof r)return 0===r?r:+r;r=r.replace(n,"");var c=e.test(r);return c||o.test(r)?i(r.slice(2),c?2:8):t.test(r)?NaN:+r}return r=function(n,t,e){var o,i,r,u,c,f,a=0,s=!1,l=!1,b=!0;if("function"!=typeof n)throw new TypeError("Expected a function");function m(t){var e=o,r=i;return o=i=void 0,a=t,u=n.apply(r,e)}function w(n){var e=n-f;return void 0===f||e>=t||e<0||l&&n-a>=r}function h(){var n=v();if(w(n))return j(n);c=setTimeout(h,function(n){var e=t-(n-f);return l?p(e,r-(n-a)):e}(n))}function j(n){return c=void 0,b&&o?m(n):(o=i=void 0,u)}function T(){var n=v(),e=w(n);if(o=arguments,i=this,f=n,e){if(void 0===c)return function(n){return a=n,c=setTimeout(h,t),s?m(n):u}(f);if(l)return c=setTimeout(h,t),m(f)}return void 0===c&&(c=setTimeout(h,t)),u}return t=y(t)||0,g(e)&&(s=!!e.leading,r=(l="maxWait"in e)?d(y(e.maxWait)||0,t):r,b="trailing"in e?!!e.trailing:b),T.cancel=function(){void 0!==c&&clearTimeout(c),a=0,o=f=i=c=void 0},T.flush=function(){return void 0===c?u:j(v())},T}}());function s(n,i,r){void 0===i&&(i=500);var u=t();!function(n){var o=t(n);o.current=n,e((function(){return function(){o.current()}}),[])}((function(){u.current&&u.current.cancel()}));var c=o((function(){var t=a(n,i,r),e=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return t.apply(void 0,n)};return e.cancel=function(){t.cancel()},e.isPending=function(){return!!u.current},e.flush=function(){return t.flush()},e}),[n,i,r]);return e((function(){u.current=a(n,i,r)}),[n,i,r]),c}var l=function(e){var o=e.input,r=e.debounceMs,u=void 0===r?300:r,c=e.sessionToken,f=e.locationBias,a=e.locationRestriction,l=e.language,d=e.types,p=e.componentRestrictions,v=e.offset,g=e.origin,y=e.region,b=e.location,m=e.radius,w=e.bounds,h=n.useRef(null),j=n.useState([]),T=j[0],O=j[1],S=n.useState(!1),x=S[0],E=S[1],R=n.useState(null),M=R[0],N=R[1],P=function(n,e,o){var r,u=null!==(r=null==o?void 0:o.equalityFn)&&void 0!==r?r:function(n,t){return n===t},c=n instanceof Function?n():n,f=i(c),a=f[0],l=f[1],d=t(c),p=s(l,e,o);return u(d.current,c)||(p(c),d.current=c),[a,p]}(o,u)[0];return n.useEffect((function(){void 0!==window&&window.google&&(h.current=new window.google.maps.places.AutocompleteService)}),[]),n.useEffect((function(){if(o){if(!h.current)throw new Error("Autocomplete Service not initialized");E(!0),h.current.getPlacePredictions({input:P,language:l,locationBias:f,region:y,offset:v,origin:g,locationRestriction:a,sessionToken:c,types:d,componentRestrictions:p,location:b,radius:m,bounds:w},(function(n,t){O(n||[]),N(t),E(!1)}))}}),[P]),{predictions:T,isLoading:x,status:M}};export{l as usePlacePredictions}; | ||
import n,{useRef as t,useEffect as e,useMemo as o,useState as i}from"react";var r,u,a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function c(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var f=c(function(){if(u)return r;u=1;var n=/^\s+|\s+$/g,t=/^[-+]0x[0-9a-f]+$/i,e=/^0b[01]+$/i,o=/^0o[0-7]+$/i,i=parseInt,c="object"==typeof a&&a&&a.Object===Object&&a,f="object"==typeof self&&self&&self.Object===Object&&self,s=c||f||Function("return this")(),l=Object.prototype.toString,d=Math.max,p=Math.min,v=function(){return s.Date.now()};function y(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function g(r){if("number"==typeof r)return r;if(function(n){return"symbol"==typeof n||function(n){return!!n&&"object"==typeof n}(n)&&"[object Symbol]"==l.call(n)}(r))return NaN;if(y(r)){var u="function"==typeof r.valueOf?r.valueOf():r;r=y(u)?u+"":u}if("string"!=typeof r)return 0===r?r:+r;r=r.replace(n,"");var a=e.test(r);return a||o.test(r)?i(r.slice(2),a?2:8):t.test(r)?NaN:+r}return r=function(n,t,e){var o,i,r,u,a,c,f=0,s=!1,l=!1,w=!0;if("function"!=typeof n)throw new TypeError("Expected a function");function b(t){var e=o,r=i;return o=i=void 0,f=t,u=n.apply(r,e)}function h(n){var e=n-c;return void 0===c||e>=t||e<0||l&&n-f>=r}function m(){var n=v();if(h(n))return S(n);a=setTimeout(m,function(n){var e=t-(n-c);return l?p(e,r-(n-f)):e}(n))}function S(n){return a=void 0,w&&o?b(n):(o=i=void 0,u)}function O(){var n=v(),e=h(n);if(o=arguments,i=this,c=n,e){if(void 0===a)return function(n){return f=n,a=setTimeout(m,t),s?b(n):u}(c);if(l)return a=setTimeout(m,t),b(c)}return void 0===a&&(a=setTimeout(m,t)),u}return t=g(t)||0,y(e)&&(s=!!e.leading,r=(l="maxWait"in e)?d(g(e.maxWait)||0,t):r,w="trailing"in e?!!e.trailing:w),O.cancel=function(){void 0!==a&&clearTimeout(a),f=0,o=c=i=a=void 0},O.flush=function(){return void 0===a?u:S(v())},O}}());function s(n,i,r){void 0===i&&(i=500);var u=t();!function(n){var o=t(n);o.current=n,e((function(){return function(){o.current()}}),[])}((function(){u.current&&u.current.cancel()}));var a=o((function(){var t=f(n,i,r),e=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return t.apply(void 0,n)};return e.cancel=function(){t.cancel()},e.isPending=function(){return!!u.current},e.flush=function(){return t.flush()},e}),[n,i,r]);return e((function(){u.current=f(n,i,r)}),[n,i,r]),a}var l=function(e){var o=e.input,r=e.debounceMs,u=void 0===r?300:r,a=e.sessionToken,c=e.locationBias,f=e.locationRestriction,l=e.language,d=e.types,p=e.componentRestrictions,v=e.offset,y=e.origin,g=e.region,w=e.location,b=e.radius,h=e.bounds,m=n.useRef(null),S=n.useState([]),O=S[0],j=S[1],T=n.useState(!1),x=T[0],E=T[1],R=n.useState(null),k=R[0],M=R[1],F=function(n,e,o){var r,u=null!==(r=null==o?void 0:o.equalityFn)&&void 0!==r?r:function(n,t){return n===t},a=n instanceof Function?n():n,c=i(a),f=c[0],l=c[1],d=t(a),p=s(l,e,o);return u(d.current,a)||(p(a),d.current=a),[f,p]}(o,u)[0];return n.useEffect((function(){void 0!==window&&window.google&&(m.current=new window.google.maps.places.AutocompleteService)}),[]),n.useEffect((function(){if(o){if(!m.current)throw new Error("Autocomplete Service not initialized");E(!0),m.current.getPlacePredictions({input:F,language:l,locationBias:c,region:g,offset:v,origin:y,locationRestriction:f,sessionToken:a,types:d,componentRestrictions:p,location:w,radius:b,bounds:h},(function(n,t){j(n||[]),M(t),E(!1)}))}}),[F]),{predictions:O,isLoading:x,status:k}};function d(n,t,e,o){return new(e||(e=Promise))((function(i,r){function u(n){try{c(o.next(n))}catch(n){r(n)}}function a(n){try{c(o.throw(n))}catch(n){r(n)}}function c(n){var t;n.done?i(n.value):(t=n.value,t instanceof e?t:new e((function(n){n(t)}))).then(u,a)}c((o=o.apply(n,t||[])).next())}))}function p(n,t){var e,o,i,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=a(0),u.throw=a(1),u.return=a(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function a(a){return function(c){return function(a){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,a[0]&&(r=0)),r;)try{if(e=1,o&&(i=2&a[0]?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,o=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(!(i=r.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){r=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){r.label=a[1];break}if(6===a[0]&&r.label<i[1]){r.label=i[1],i=a;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(a);break}i[2]&&r.ops.pop(),r.trys.pop();continue}a=t.call(n,r)}catch(n){a=[6,n],o=0}finally{e=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}"function"==typeof SuppressedError&&SuppressedError;var v=function(t){var e=t.origin,o=t.destination,i=t.language,r=t.region,u=t.avoidFerries,a=t.avoidHighways,c=t.avoidTolls,f=t.drivingOptions,s=t.optimizeWaypoints,l=t.provideRouteAlternatives,v=t.transitOptions,y=t.unitSystem,g=t.waypoints,w=t.travelMode,b=n.useRef(null),h=n.useState(null),m=h[0],S=h[1],O=n.useState(!1),j=O[0],T=O[1],x=n.useState(null),E=x[0],R=x[1];n.useEffect((function(){void 0!==window&&window.google&&(b.current=new window.google.maps.DirectionsService)}),[]);return n.useEffect((function(){if(e||o){if(!b.current)throw new Error("Directions Service not initialized");T(!0),d(void 0,void 0,void 0,(function(){var n;return p(this,(function(t){switch(t.label){case 0:return[4,null===(n=b.current)||void 0===n?void 0:n.route({origin:e,destination:o,language:i,region:r,avoidFerries:u,avoidHighways:a,avoidTolls:c,drivingOptions:f,optimizeWaypoints:s,provideRouteAlternatives:l,transitOptions:v,unitSystem:y,waypoints:g,travelMode:w},(function(n,t){S(n),R(t),T(!1)}))];case 1:return t.sent(),[2]}}))}))}}),[e,o]),{directions:m,isLoading:j,status:E}};export{v as useDirections,l as usePlacePredictions}; |
{ | ||
"name": "react-google-geocoding", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"main": "dist/index.cjs.js", | ||
@@ -39,3 +39,3 @@ "module": "dist/index.esm.js", | ||
"license": "MIT", | ||
"description": "A lightweight wrapper around Google Places Autocomplete and Geocoding APIs, with plans to support more Google services in the future.", | ||
"description": "A lightweight wrapper around Google Places Autocomplete and Directions APIs.", | ||
"devDependencies": { | ||
@@ -42,0 +42,0 @@ "@rollup/plugin-commonjs": "^28.0.1", |
@@ -33,2 +33,3 @@ # react-google-hooks | ||
1. **usePlacePredictions** - Fetches place predictions based on a query. | ||
2. **useDirections** - A service for computing directions between two or more places. | ||
@@ -35,0 +36,0 @@ ## `usePlacePredictions` Hook |
export * from "./use-place-predictions"; | ||
export * from "./use-directions"; |
Sorry, the diff of this file is not supported yet
70446
33
1112
139