digitransit-ui/digitransit-component/packages/digitransit-component-favourite-modal/README.md
2020-10-16 11:41:12 +03:00

132 lines
2.7 KiB
Markdown

# @digitransit-component/digitransit-component-favourite-modal
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
## FavouriteModal
**Extends React.Component**
### Parameters
- `props`
### Examples
```javascript
<FavouriteModal
show={modalOpen}
handleClose={handleClose}
saveFavourite={onSaveFavourite}
location={selectedLocation}
favourite={favourite}
lang={lang}
autosuggestComponent={
<AutoSuggest
sources={['History', 'Datasource']}
targets={['Locations', 'CurrentPosition']}
id="favourite"
autoFocus={false}
placeholder="search-address-or-place"
value={selectedLocation.address || ''}
onFavouriteSelected={this.setLocationProperties}
lang={lang}
/>
}
/>
```
## handleClose
Required.
Type: [function][1]
## saveFavourite
Required.
Type: [function][1]
## cancelSelected
Required. Only used when editing favourite.
Type: [function][1]
## autosuggestComponent
Optional.
Autosuggest component for searching new favourites.
Type: [node][2]
## favourite
Optional.
Object to prefill input field for name and/or selected icon.
Type: [object][3]
### Properties
- `type` **[string][4]**
- `address` **[string][4]**
- `gtfsId` **[string][4]**
- `gid` **[string][4]**
- `lat` **[number][5]**
- `lon` **[number][5]**
- `name` **[string][4]**
- `selectedIconId` **[string][4]**
- `favouriteId` **[string][4]**
- `layer` **[string][4]**
- `defaultName` **[string][4]**
## addAnalyticsEvent
Optional.
Type: [function][1]
## lang
Optional. Language, fi, en or sv.
Type: [string][4]
## isMobile
Optional.
[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
[2]: https://developer.mozilla.org/docs/Web/API/Node/nextSibling
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
<!-- This file is automatically generated. Please don't edit it directly:
if you find an error, edit the source file (likely index.js), and re-run
./scripts/generate-readmes in the digitransit-component project. -->
---
This module is part of the Digitransit-ui project. It is maintained in the
[HSLdevcom/digitransit-ui](https://github.com/HSLdevcom/digitransit-ui) repository, where you can create
PRs and issues.
### Installation
Install this module individually:
```sh
$ npm install @digitransit-component/digitransit-component-favourite-modal
```
Or install the digitransit-component module that includes it as a class:
```sh
$ npm install @digitransit-component/digitransit-component
```