Giter Site home page Giter Site logo

ubilabs / react-geosuggest Goto Github PK

View Code? Open in Web Editor NEW
1.0K 1.0K 326.0 2.93 MB

A React autosuggest for the Google Maps Places API.

Home Page: http://ubilabs.github.io/react-geosuggest/

License: MIT License

CSS 3.73% JavaScript 4.39% HTML 1.66% TypeScript 90.22%

react-geosuggest's Introduction

React Geosuggest

A React autosuggest for the Google Maps Places API. You can also define your own suggests as defaults. Works with Preact, too.

Demo

Live demo: ubilabs.github.io/react-geosuggest

Installation

As this component uses the Google Maps Places API to get suggests, you must include the Google Maps Places API in the <head> of your HTML:

<!doctype html>
<html>
  <head><script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY_HERE&libraries=places"></script>
  </head>
  <body></body>
</html>

Visit the Google Developer Console to generate your API key. The API's that you have to enable in your Google API Manager Dashboard are Google Maps Geocoding API, Google Places API Web Service and Google Maps Javascript API.

The easiest way to use geosuggest is to install it from NPM and include it in your own React build process (using Webpack, Parcel, etc).

You can also use the standalone build by including dist/react-geosuggest.js in your page. If you use this, make sure you have already included React, and it is available as a global variable.

npm install @ubilabs/react-geosuggest --save

Usage

The Geosuggest works out of the box by just including it. However, you can customize the behaviour with the properties noted below.

ES6:

import Geosuggest from '@ubilabs/react-geosuggest';

<Geosuggest />;

ES5:

var Geosuggest = require('@ubilabs/react-geosuggest').default;

<Geosuggest />;

Properties

placeholder

Type: String Default: Search places

The input field will get this placeholder text.

initialValue

Type: String Default: ''

An initial value for the input, when you want to prefill the suggest.

id

Type: String Default: ''

Define an ID for the geosuggest. Needed when there are multiple instances on a page.

className

Type: String Default: ''

Add an additional class to the geosuggest container.

style

Type: Object Default: { 'input': {}, 'suggests': {}, 'suggestItem': {} }

Add an additional style to Geosuggest. This would support overriding/adding styles to the input suggestList and suggestItem.

inputClassName

Type: String Default: ''

Add an additional class to the input.

disabled

Type: Boolean Default: false

Defines whether the input is disabled.

location

Type: google.maps.LatLng Default: null

To get localized suggestions, define a location to bias the suggests.

radius

Type: Number Default: 0

The radius in meters defines the area around the location to use for biasing the suggests. It must be accompanied by a location parameter.

bounds

Type: LatLngBounds Default: null

The bounds to use for biasing the suggests. If this is set, location and radius are ignored.

country

Type: String or Array Default: null

Restricts predictions to the specified country (ISO 3166-1 Alpha-2 country code, case insensitive). E.g., us, br, au. You can provide a single one, or an array of up to 5 country code strings.

types

Type: Array Default: null

The types of predictions to be returned. Four types are supported: establishment for businesses, geocode for addresses, (regions) for administrative regions and (cities) for localities. If nothing is specified, all types are returned. Consult the Google Docs for up to date types.

fixtures

Type: Array Default: []

An array with fixtures (defaults). Each fixture has to be an object with a label key in it. Optionally provide a location, but the Geosuggest will geocode the label if no location is provided.

You can also add a className key to a fixture. This class will be applied to the fixture item.

maxFixtures

Type: Number Default: 10

Maximum number of fixtures to render.

placeDetailFields

Type: Array Default: null

By default Google returns all fields when getting place details which can impact billing. You can optionally pass an array of fields to include in place results to limit what is returned and potentially reduce billing impact. geometry will always be added as we depend on the location for the suggest selection.

googleMaps

Type: Object Default: google.maps

In case you want to provide your own Google Maps object, pass it in as googleMaps. The default is the global google maps object.

ignoreTab

Type: Boolean Default: false

When the tab key is pressed, the onSelect handler is invoked. Set to true to not invoke onSelect on tab press.

ignoreEnter

Type: Boolean Default: false

When the enter key is pressed, the onSelect handler is invoked. Set to true to not invoke onSelect on enter press.

queryDelay

Type: Number Default: 250

Sets the delay in milliseconds after typing before a request will be sent to find suggestions. Specify 0 if you wish to fetch suggestions after every keystroke.

minLength

Type: Number Default: 1

Sets a minimum length of characters before a request will be sent to find suggestions.

highlightMatch

Type: Boolean Default: true

Highlights matched text.

onFocus

Type: Function Default: function() {}

Gets triggered when the input field receives focus.

onBlur

Type: Function Default: function(value) {}

Gets triggered when input field loses focus.

onChange

Type: Function Default: function(value) {}

Gets triggered when input field changes the value.

onKeyDown

Type: Function Default: function(event) {}

Gets triggered when input field has a key pressed down. This event is triggered before onKeyPress.

onKeyPress

Type: Function Default: function(event) {}

Gets triggered when input field gets key press.

onSuggestSelect

Type: Function Default: function(suggest) {}

Gets triggered when a suggest got selected. Only parameter is an object with data of the selected suggest. This data is available:

  • label – Type String – The label name
  • placeId – Type String – If it is a preset, equals the label. Else it is the Google Maps placeID
  • location – Type Object – The location containing lat and lng
  • gmaps – Type Object – Optional! The complete response when there was a Google Maps geocode necessary (e.g. no location provided for presets). Check the Google Maps Reference for more information on it’s structure.

onUpdateSuggests

Type: Function Default: function(suggests, activeSuggest) {}

Gets triggered when the suggest list changes. Arguments include the suggest list and the current activeSuggest. Useful if you want to render the list of suggests outside of @ubilabs/react-geosuggest.

onActivateSuggest

Type: Function Default: function(suggest) {}

Gets triggered when a suggest is activated in the list. Only parameter is an object with data of the selected suggest. This data is available:

  • label – Type String – The label name
  • placeId – Type String – If it is a preset, equals the label. Else it is the Google Maps placeID

onSuggestNoResults

Type: Function Default: function(userInput) {}

Gets triggered when there are no suggest results found

getSuggestLabel

Type: Function Default: function(suggest) { return suggest.description; }

Used to generate a custom label for a suggest. Only parameter is a suggest (google.maps.places.AutocompletePrediction). Check the Google Maps Reference for more information on it’s structure.

renderSuggestItem

Type: Function Default: null

Used to customize the inner html of SuggestItem and allows for controlling what properties of the suggest object you want to render. Also a convenient way to add additional styling to different rendered elements within SuggestItem. The function is passed both the suggestion and the user input.

skipSuggest

Type: Function Default: function(suggest) {}

If the function returns true then the suggest will not be included in the displayed results. Only parameter is an object with data of the selected suggest. (See above)

autoActivateFirstSuggest

Type: Boolean Default: false

Automatically activate the first suggestion as you type. If false, the exact term(s) in the input will be used when searching and may return a result not in the list of suggestions.

label

Type: String Default: null

If the label and a id prop (see "Others") were supplied, a <label> tag with the passed label text will be rendered. The <label> element's for attribute will correctly point to the id of the <input> element.

suggestsClassName

Type: String Default: ''

Add an additional class to suggest list.

suggestsHiddenClassName

Type: String Default: null

Additional className to toggle as the list of suggestions changes visibility.

suggestItemClassName

Type: String Default: ''

Add an additional class to suggest item.

suggestItemActiveClassName

Type: String, Default: null

Additional className to add when a suggestion item is active.

autoComplete

Type: String, Default: off

Autocomplete input attribute.

inputType

Type: String, Default: text

The value for the type attribute on the html input element. Can be either text or search.

Others

All allowed attributes for input[type="text"] All DOM clipboard events. All DOM mouse events except for drag & drop. All data attributes.

Exposed component functions

These functions are accessible by setting "ref" on the component (see example below)

focus()

Call focus to focus on the element. The suggest list will be expanded with the current suggestions.

blur()

Call blur to blur (unfocus) the element. The suggest list will be closed.

update(value)

It is possible to update the value of the input contained within the GeoSuggest component by calling the update function with a new desired value of the type String.

clear()

It is also possible to clear the value of the input contained within the GeoSuggest component by calling the clear function.

selectSuggest()

Same effect as hitting enter (will geocode the text inside of the input).

Example

import React, {useRef} from 'react';
import ReactDOM from 'react-dom/client';
import Geosuggest from '@ubilabs/react-geosuggest';

const App = () => {
  const geosuggestEl = useRef(null);

  const fixtures = [
    {label: 'New York', location: {lat: 40.7033127, lng: -73.979681}},
    {label: 'Rio', location: {lat: -22.066452, lng: -42.9232368}},
    {label: 'Tokyo', location: {lat: 35.673343, lng: 139.710388}}
  ];

  /**
   * When a suggest got selected
   */
  const onSuggestSelect = (suggest) => console.log(suggest);

  return (
    <div>
      <Geosuggest
        ref={geosuggestEl}
        placeholder="Start typing!"
        initialValue="Hamburg"
        fixtures={fixtures}
        onSuggestSelect={onSuggestSelect}
        location={new google.maps.LatLng(53.558572, 9.9278215)}
        radius="20" />

      {* Buttons to trigger exposed component functions *}
      <button onClick={()=>geosuggestEl.current.focus()}>Focus</button>
      <button onClick={()=>geosuggestEl.current.update('New Zealand')}>Update</button>
      <button onClick={()=>geosuggestEl.current.clear()}>Clear</button>
      <button onClick={()=>geosuggestEl.current.selectSuggest()}>Search</button>
    </div>
  );
};

const container = document.getElementById('app');
const root = ReactDOM.createRoot(container!);
root.render(<App />);

Styling

This component uses BEM for namespacing the CSS classes. So styling should be easy and without conflicts. See the geosuggest.css for an example styling.

Note:

The geosuggest__suggests--hidden class is added to hide the suggestion list. You should copy the style below into your CSS file.

.geosuggest__suggests--hidden {
  max-height: 0;
  overflow: hidden;
  border-width: 0;
}

The above class is added whenever the suggestion list needs to be hidden. This occurs when the user selects an item from the list or when the user triggers the blur event on the input.

Similarly, you need to have the class geosuggest__item--active similar to this:

.geosuggest__item--active {
  background: #267dc0;
  color: #fff;
}

to see what item is selected, f.ex. when using the arrow keys to navigate the suggestion list.

Contributing

Issues and pull requests are welcome! Please read the guidelines in CONTRIBUTING.md before starting to work on a PR.

License

See LICENSE.md

react-geosuggest's People

Contributors

alistairjcbrown avatar caerostris avatar cymen avatar davidfurlong avatar dimafeldman avatar glennreyes avatar idolize avatar joanrodriguez avatar joaogarin avatar joefiorini avatar jpage-godaddy avatar juliocanares avatar karanjthakkar avatar khanghoang avatar kovdimay avatar lpadier avatar lsanwick avatar manjumuthaiya avatar msalsas avatar mskec avatar narendrashetty avatar oyeanuj avatar petetnt avatar pheeria avatar plumdumpling avatar ro-ka avatar treyhuffine avatar vishwanatharondekar avatar willcaul avatar yfr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-geosuggest's Issues

The 'gmaps' object has functions instead of values (e.g. Lat/Lng)

Hi. I want to use the complete gmaps object as returned by the Google Maps API after I select a location. The other values are not enough for what I'm trying to do. The problem I'm facing is that the gmaps object is not the same as I would expect. For example, gmaps.geometry.location.lat is a function() instead of just being a number.

chinalatlng

I checked this in both Firefox and Chrome on your example website.

React Component Not Found

Good day,

Having an issue with the module not found.

I call it in app.jsx

var Geosuggest = require('geosuggest')

In console I get the following error:

ERROR in ./components/app.jsx
Module not found: Error: Cannot resolve module 'geosuggest' in /Users/sergiopellegrini/Sites/recipes-flux/client/components
resolve module geosuggest in /Users/sergiopellegrini/Sites/recipes-flux/client/components
looking for modules in /Users/sergiopellegrini/Sites/recipes-flux/node_modules
/Users/sergiopellegrini/Sites/recipes-flux/node_modules/geosuggest doesn't exist (module as directory)
resolve 'file' geosuggest in /Users/sergiopellegrini/Sites/recipes-flux/node_modules
resolve file
/Users/sergiopellegrini/Sites/recipes-flux/node_modules/geosuggest doesn't exist
/Users/sergiopellegrini/Sites/recipes-flux/node_modules/geosuggest.js doesn't exist
/Users/sergiopellegrini/Sites/recipes-flux/node_modules/geosuggest.jsx doesn't exist
[/Users/sergiopellegrini/Sites/recipes-flux/node_modules/geosuggest]
[/Users/sergiopellegrini/Sites/recipes-flux/node_modules/geosuggest]
[/Users/sergiopellegrini/Sites/recipes-flux/node_modules/geosuggest.js]
[/Users/sergiopellegrini/Sites/recipes-flux/node_modules/geosuggest.jsx]
@ ./components/app.jsx 11:17-38

I then renamed the module to react-geosuggest but then get the following:

Uncaught TypeError: Cannot read property '__reactAutoBindMap' of null

Your assistance will be much appreciated.

Make it work with react 0.14.0-beta3

Great library. I'd love to use it, but I'm a react noob. I can't get this to work with my project based on relay-starter-kit, which uses react 0.14.0-beta3. For some reason, I can't get anything useful to install when I fork and upgrade the dependency. When I install via npm (there's no actual source, just the meta files like package.json).

A fix (maybe an alternative branch) would be very helpful.

Thanks!

Enhancements

What are your thoughts on exposing focus state, and a method to clear the input state ?
This would allow the page UI to depend on suggest being open or not, and also allow a google maps like clear button

Out of Box: Unexpected token <

Tried this out of the box, and got this error:

node_modules/react-geosuggest/src/Geosuggest.jsx Line 222: Unexpected token <

I'm sure it's something with complaining on my end. Any suggestions?

Point package.json main to built file

It would be worth updating the main property in the package.json file to point to dist/react-geosuggest.js (or equivalent pure JS file if that's not suitable) so that using require to pull react-geosuggest doesn't first require a build step.

For me, as this component is JSX, I have to update my webpack config and jest preprocessor script to include react-geosuggest as an allowed node_modules library to be included as part of the build.

Powered by google?

Do you think it would be a good idea to have a "Powered by Google" at the bottom of the dropdown?

Removing United States from results

I'd like to remove Untied States from results. I did this which worked. Is there a more elegant way?

if(suggest.label.substr(suggest.label.length - 13) === "United States") {
    suggest.label = suggest.label.substring(0, suggest.label.length - 15);
}

In the getSuggestItems function on line 268

Place Details

If I made a PR for the below functionality, would you consider merging it?

  1. new boolean property -> lookupPlaceDetail
  2. if above property is true, lookup place details and add response to suggest data for use in the onSuggestSelect callback.

Thoughts?

Cache requests to google Api

From google doc

Geocoding is a time and resource intensive task. Whenever possible, pre-geocode known addresses (using the Google Maps Geocoding API described here or another geocoding service), and store your results in a temporary cache of your own design.

A basic implementation can be found on the PR I submitted #29

issue with assets/webpack (react best practices)

In current release we unable to apply styles from variable.
For standart "webpack way" we requires styles as module and apply to element. For example:

import myCss from './mycss-or-less-or-scss-or-other'
....

And now i need apply my styles to element, but i cannot do that:

For example ReactCSSTransitionGroup
accept class names as parameter

Support for 'no results found' case

Hi @ro-ka! Another n00b question:

How do you suggest we handle the case where no result is found in the auto-suggest? Is it possible for the input field to just take the string inputted and pass that as a value (or is that already being done?)

Using with redux-form

Im not sure if this really is this projects problem, but I have a form that uses this component as one of it's fields:

<Geosuggest onChange={this.onChange.bind(this)}

Form is validated using https://github.com/erikras/redux-form which seems to capture onChange events of this component somehow since my handler is not being called.

I guess this is because this project does not use prefixed onChange property?

Errors when bundling react-geosuggest with Browserify on node 0.10.x

I have a project that pulls in react-geosuggest via npm. The project is bundled with Browserify + Babelify.

When I bundle this on node 0.10.x, I run into the following error:

23:05:12 Error: Cannot find module 'classnames' from '/src/node_modules/react-geosuggest/module'
23:05:12     at /src/node_modules/browserify/node_modules/resolve/lib/async.js:46:17
23:05:12     at process (/src/node_modules/browserify/node_modules/resolve/lib/async.js:173:43)
23:05:12     at ondir (/src/node_modules/browserify/node_modules/resolve/lib/async.js:188:17)
23:05:12     at load (/src/node_modules/browserify/node_modules/resolve/lib/async.js:69:43)
23:05:12     at onex (/src/node_modules/browserify/node_modules/resolve/lib/async.js:92:31)
23:05:12     at /src/node_modules/browserify/node_modules/resolve/lib/async.js:22:47
23:05:12     at Object.oncomplete (fs.js:107:15)

Bundling works on node v5.1.0, however.

As a workaround on node 0.10.x, I included classnames in our own package.json dependencies and bundling worked.

Happy to provide more details if it would help!

reactify

Hi,

Great job you've done there. Thanks.
Just one question: why reactify is in dependencies and not devDependencies ?

Follow react best practice and improve the separation of concerns

Here there are some points I would like to highlight

  • props in getInitialState is an Anti-pattern https://github.com/ubilabs/react-geosuggest/blob/master/src/Geosuggest.jsx#L38 -> https://facebook.github.io/react/tips/props-in-getInitialState-as-anti-pattern.html
  • To respect Single Responsibility Principle the input should have its own component and the same the list. This helps maintaining the code, replacing parts of the component and it could also improve component customization... For example would be easier to integrate my PR if all components were split correctly from the start. Decoupling is always better.
  • Google api services should not be part of the state. Instead they should be members of the component. State is meant for mutable data not for third party libraries. If you never see setState({foo:"bar"}) but you have "foo" defined in your state you should start thinking you're doing something wrong ;)
  • As a convention I just prefer to have the render() method ALWAYS a the bottom, lifecycle methods at the start of the file in the order they are called, component methods that are exposed just after lifecycle methods and in the middle private methods prefixed with _. You'll notice that it's not just my convention but it's what most of the people use today. See for example how FB guys write their components https://github.com/facebook/fixed-data-table/tree/master/src

These stuff can be found in my PR #29

Submit Button

Is there an easy way to have a Submit button work the same as a onSuggestSelect?

Access Places Data

It's not clear from the Readme or Example.... does this return the Places API data (street_address, country, administrative_area_level_1, etc...) ?

For example i'm currently using a jQuery GeoComplete that returns these fields in the response.

I'm not terribly familiar with the Google API's, would that data require extra calls or does it just need to be exposed?

Thanks!

Async script load

Current "no-async" solution is too slow for mobile clients.
It posible to load library "async way" with callback?

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places&callback=initMap"
    async defer></script>

Input is a void element warning

Any solution to get rid of the following React warning: Warning: input is a void element tag and must not have children or use props.dangerouslySetInnerHTML. Check the render method of NewHaulPage.

1.16.0 module build requiring modules incorrectly

Our application pulled in 1.16.0 of this module, and we get an error when importing:

Cannot find module './input.jsx'

I ran prepublish on this module, and the transpiled /module/Geosuggest.js has the expression require('./index.jsx'), but the transpiled file is actually named index.js.

Add props validation

It's very common in the React world to use React.PropTypes not just for validation of component's props but also to have a clear picture of all the props that a component manage and for documentation.

In getDefaultProps is better to define just conditional props since mandatory props will be in any case overwritten.

An inspiration can be found on the PR I submitted #29

Using dist/react-geosuggest.js with global React fails.

E.g.

bower install react
bower install react-geosuggest

And a basic template

<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">

    <title>Index</title>
    <script src="bower_components/react/react.js" type="text/javascript" charset="utf-8"></script>
    <script src="bower_components/react-geosuggest/dist/react-geosuggest.js" type="text/javascript" charset="utf-8"></script>
</head>

</html>

I'm getting a.

Uncaught Error: Cannot find module 'react'

The README mentions that this usage should be possible.

window.React is exposed by react.js, but the requires in react-geosuggest.js can't find it, I might be missing a config option! I'm not sure if you can ask that webpack/browserify wrapper to do something to link those up.

Cheers!

We're looking into using the component in a ClojureScript/Reagent page which uses quite a different build system. It would be neat to avoid integrating a webpack/browserify step into the build for now but it might come to that anyway!

Add component tests

It would be great if this component had tests, and code coverage metrics. We can use mocha, sinon, jsdom, proxyquire and testUtils.

Thoughts?

Warning: setState(...): Can only update a mounted or mounting component.

When the Geosuggest input is in focus and the react route changes, the following warning pops in the console:

Warning: setState(...): Can only update a mounted or mounting component.
This usually means you called setState() on an unmounted component.
This is a no-op. Please check the code for the Geosuggest component.

Then it points to this part:

/**
 * When the input loses focused
 */
hideSuggests: function hideSuggests() {
  this.props.onBlur();
  setTimeout((function () {
    this.setState({ isSuggestsHidden: true });
  }).bind(this), 100);
},

Not sure if I am supposed to destroy the component somehow in my componentWillUnmount() ?


geo


    "history": "~1.13.x",
    "react": "^0.14.3",
    "react-dom": "^0.14.3",
    "react-geosuggest": "^1.13.0",
    "react-router": "^1.0.2",

Selecting an suggested item using Enter submits the form

When the component lives in a form and one of the suggested items is selected using keyboard (arrows + hitting enter), the form is submitted.

From the source code I see you didn't include event.preventDefault() probably on purpose? Could this be at least configurable by props? There's no other way how to prevent this as you don't pass the event to the onSuggestSelect method.

Item selection seems to be broken sometimes

We had a bug reported of a user not being able to select an item from the suggestions.

I traced the problem to GeosuggestItem.onClick and Geosuggest.hideSuggests functions. There's a 100ms timeout before the state in Geosuggest component changes to hide the suggestions. If user clicks on a GeosuggestItem, the hideSuggests function is executed at the same time (on blur). If user doesn't release the mouse button to actually trigger a click event, the list of suggestions is gone and nothing has been selected.

What would be the most correct solution to this problem? Increasing the timeout interval in hideSuggests or simply using onMouseDown event in the GeosuggestItem instead?

Browserify transform in package.json causes build errors

I am using Browserify to build my own project, but my build fails when I pull in this project as a dependency:

Cannot find module 'reactify' from '/node_modules/react-geosuggest'

This is because you have reactify in the browserify transforms section of your package.json (which means it is always executed when Browserify runs, even when it is required in by outside projects that install it via npm), but it isn't installed via dependencies. Thus, it crashes when Browserify can't find the missing dependency.

From the Browserify docs:

Now (that you have added a transform field to package.json) when somebody require()s your module, (the transform) will automatically be applied to the files in your module without explicit intervention by the person using your module.

I don't think this is a good practice for modules which are published for use on npm, because the compilation should have happened before publishing anyway (as you are already doing).

Since you are already using a Gulpfile, perhaps it would make more sense to just perform the JSX transformation as part of your Gulp task?

(FYI, this was working for me on version 1.2.1, but after the release of 1.2.3 it is now breaking)

Allowed Input Attributes don't match the ones from React

React documentation says

These standard attributes are supported:

accept acceptCharset accessKey action allowFullScreen allowTransparency alt
async autoComplete autoFocus autoPlay capture cellPadding cellSpacing challenge
charSet checked classID className colSpan cols content contentEditable
contextMenu controls coords crossOrigin data dateTime default defer dir
disabled download draggable encType form formAction formEncType formMethod
formNoValidate formTarget frameBorder headers height hidden high href hrefLang
htmlFor httpEquiv icon id inputMode integrity is keyParams keyType kind label
lang list loop low manifest marginHeight marginWidth max maxLength media
mediaGroup method min minLength multiple muted name noValidate nonce open
optimum pattern placeholder poster preload radioGroup readOnly rel required
reversed role rowSpan rows sandbox scope scoped scrolling seamless selected
shape size sizes span spellCheck src srcDoc srcLang srcSet start step style
summary tabIndex target title type useMap value width wmode wrapp```

your current list is :

autocapitalize autocomplete autocorrect autoFocus autosave disabled form formaction
formenctype formmethod formnovalidate formtarget height id inputmode maxlength maxlength
name pattern placeholder readonly required selectionDirection size spellcheck tabindex

Obviously, the React list is longer, but that is not a problem.
The problem is about stuff present in your list that are not handled by React.
For example autocapitalize.
Something else that you should be carefull, is the use of capital letter or not.
For example, React allows autoComplete, but you allow autocomplete.
This lead in stuff not being propagated.

Refs

After update the ref "geosuggestInput" does not work anymore. How can i get the input from outside to apply eg .focus().

Cannot find module './GeosuggestItem.jsx'

When I build my app with gulp and browserify, I get the error:

Cannot find module './GeosuggestItem.jsx' from /blahblah/node_modules/react-geosuggest/module

When I look at the directory specified in the error, there is a file "GeosuggestItem.js" (without the "x"). Why would it be looking for GeosuggestItem.jsx instead?

Required input attr

When I put required nothing happens

<Geosuggest
  placeholder="Start location"
  ref="start_location"
  required
/>

Styling place name separately from country and city

Hi @ro-ka! This library looks great, thank you! For my use-case, I need to style the country (and ideally, the city as well) separately from the place name.

In your demo, you have only one element in the li.geosuggest-item. I was wondering if it is possible today, or possible to add, the ability to distinguish country from the place name and render them with different css classes?

Event when input changes the value

Hi,

I used your component and it's great. But then i ran into a problem that i need to listen to the input changes event, for example, if the input value is empty, my "Action" button will be disabled.

Unfortunately, there's no exposed function for that event yet.

Broken demo

Hey, the component you've got here looks great, but visiting the demo results in an invariant violation:

Error: Invariant Violation: App.render(): A valid ReactComponent must be returned. You may have returned undefined, an array or some other invalid object. app.js:7:17671

google is not defined

Hallo,

I'm trying to use the package but I get the error:

google is not defined, it refers to the googleMaps default prop.

It is maybe due to the fact that my code is running server and client side. I tried to force:
var GoogleMaps = window.google.maps;

but it is not working!

Is there a way to solve this?

Move Google Places script into component

Hi there! This is a great component, I am building a Meteor app using this plugin, and it would be nice if the component handled the script internally, so that the component could be loaded at any time, and handle it's own dependency on the external script.

Is this something that is possible? Or should I fork and make the changes tailored to my own needs?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.