@digitransit-component/digitransit-component-autosuggest 7.2.2 → 8.0.0

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.
@@ -0,0 +1,291 @@
1
+
2
+ European Union Public Licence
3
+ V. 1.2
4
+
5
+
6
+ EUPL © the European Union 2007, 2013
7
+
8
+
9
+ This European Union Public Licence (the “EUPL”) applies to the Work (as defined
10
+ below) which is provided under the terms of this Licence. Any use of the Work, other
11
+ than as authorised under this Licence is prohibited (to the extent such use is covered by
12
+ a right of the copyright holder of the Work).
13
+
14
+ The Original Work is provided under the terms of this Licence when the Licensor (as
15
+ defined below) has placed the following notice immediately following the copyright
16
+ notice for the Original Work:
17
+
18
+ Licensed under the EUPL
19
+
20
+ or has expressed by any other means his willingness to license under the EUPL.
21
+
22
+ 1. Definitions
23
+
24
+ In this Licence, the following terms have the following meaning:
25
+
26
+ - The Licence: this Licence.
27
+
28
+ - The Original Work: the work or software distributed and/or communicated by the
29
+ Licensor under this Licence, available as Source Code and also as Executable Code as
30
+ the case may be.
31
+
32
+ - Derivative Works: the works or software that could be created by the Licensee, based
33
+ upon the Original Work or modifications thereof. This Licence does not define the
34
+ extent of modification or dependence on the Original Work required in order to classify
35
+ a work as a Derivative Work; this extent is determined by copyright law applicable in
36
+ the country mentioned in Article 15.
37
+
38
+ - The Work: the Original Work and/or its Derivative Works.
39
+
40
+ - The Source Code: the human-readable form of the Work which is the most convenient
41
+ for people to study and modify.
42
+
43
+ - The Executable Code: any code which has generally been compiled and which is
44
+ meant to be interpreted by a computer as a program.
45
+
46
+ - The Licensor: the natural or legal person that distributes and/or communicates the
47
+ Work under the Licence.
48
+
49
+ - Contributor(s): any natural or legal person who modifies the Work under the Licence,
50
+ or otherwise contributes to the creation of a Derivative Work.
51
+
52
+ - The Licensee or “You”: any natural or legal person who makes any usage of the Work
53
+ under the terms of the Licence.
54
+
55
+ - Distribution and/or Communication: any act of selling, giving, lending, renting,
56
+ distributing, communicating, transmitting, or otherwise making available, on-line or
57
+ off-line, copies of the Work or providing access to its essential functionalities at the
58
+ disposal of any other natural or legal person.
59
+
60
+ 2. Scope of the rights granted by the Licence
61
+
62
+ The Licensor hereby grants You a world-wide, royalty-free, non-exclusive, sub-
63
+ licensable licence to do the following, for the duration of copyright vested in the
64
+ Original Work:
65
+
66
+ - use the Work in any circumstance and for all usage,
67
+ - reproduce the Work,
68
+ - modify the Original Work, and make Derivative Works based upon the Work,
69
+ - communicate to the public, including the right to make available or display the
70
+ Work or copies thereof to the public and perform publicly, as the case may be,
71
+ the Work,
72
+ - distribute the Work or copies thereof,
73
+ - lend and rent the Work or copies thereof,
74
+ - sub-license rights in the Work or copies thereof.
75
+
76
+ Those rights can be exercised on any media, supports and formats, whether now known
77
+ or later invented, as far as the applicable law permits so.
78
+
79
+ In the countries where moral rights apply, the Licensor waives his right to exercise his
80
+ moral right to the extent allowed by law in order to make effective the licence of the
81
+ economic rights here above listed.
82
+
83
+ The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to any
84
+ patents held by the Licensor, to the extent necessary to make use of the rights granted
85
+ on the Work under this Licence.
86
+
87
+ 3. Communication of the Source Code
88
+
89
+ The Licensor may provide the Work either in its Source Code form, or as Executable
90
+ Code. If the Work is provided as Executable Code, the Licensor provides in addition a
91
+ machine-readable copy of the Source Code of the Work along with each copy of the
92
+ Work that the Licensor distributes or indicates, in a notice following the copyright
93
+ notice attached to the Work, a repository where the Source Code is easily and freely
94
+ accessible for as long as the Licensor continues to distribute and/or communicate the
95
+ Work.
96
+
97
+ 4. Limitations on copyright
98
+
99
+ Nothing in this Licence is intended to deprive the Licensee of the benefits from any
100
+ exception or limitation to the exclusive rights of the rights owners in the Original Work,
101
+ of the exhaustion of those rights or of other applicable limitations thereto.
102
+
103
+ 5. Obligations of the Licensee
104
+
105
+ The grant of the rights mentioned above is subject to some restrictions and obligations
106
+ imposed on the Licensee. Those obligations are the following:
107
+
108
+ Attribution right: the Licensee shall keep intact all copyright, patent or trademarks
109
+ notices and all notices that refer to the Licence and to the disclaimer of warranties. The
110
+ Licensee must include a copy of such notices and a copy of the Licence with every copy
111
+ of the Work he/she distributes and/or communicates. The Licensee must cause any
112
+ Derivative Work to carry prominent notices stating that the Work has been modified
113
+ and the date of modification.
114
+
115
+ Copyleft clause: If the Licensee distributes or communicates copies of the Original
116
+ Works or Derivative Works, this Distribution or Communication will be done under the
117
+ terms of this Licence or of a later version of this Licence unless the Original Work is
118
+ expressly distributed only under this version of the Licence – for example by stating
119
+ “EUPL v. 1.2 only”. The Licensee (becoming Licensor) cannot offer or impose any
120
+ additional terms or conditions on the Work or Derivative Work that alter or restrict the
121
+ terms of the Licence.
122
+
123
+ Compatibility clause: If the Licensee Distributes or Communicates Derivative Works
124
+ or copies thereof based upon both the Original Work and another work licensed under
125
+ a Compatible Licence, this Distribution or Communication can be done under the terms
126
+ of this Compatible Licence. For the sake of this clause, “Compatible Licence” refers to
127
+ the licences listed in the appendix attached to this Licence. Should the Licensee’s
128
+ obligations under the Compatible Licence conflict with his/her obligations under this
129
+ Licence, the obligations of the Compatible Licence shall prevail.
130
+
131
+ Provision of Source Code: When distributing and/or communicating copies of the
132
+ Work, the Licensee will provide a machine-readable copy of the Source Code or
133
+ indicate a repository where this Source will be easily and freely available for as long as
134
+ the Licensee continues to distribute and/or communicate the Work.
135
+
136
+ Legal Protection: This Licence does not grant permission to use the trade names,
137
+ trademarks, service marks, or names of the Licensor, except as required for reasonable
138
+ and customary use in describing the origin of the Work and reproducing the content of
139
+ the copyright notice.
140
+
141
+ 6. Chain of Authorship
142
+
143
+ The original Licensor warrants that the copyright in the Original Work granted
144
+ hereunder is owned by him/her or licensed to him/her and that he/she has the power and
145
+ authority to grant the Licence.
146
+
147
+ Each Contributor warrants that the copyright in the modifications he/she brings to the
148
+ Work are owned by him/her or licensed to him/her and that he/she has the power and
149
+ authority to grant the Licence.
150
+
151
+ Each time You accept the Licence, the original Licensor and subsequent Contributors
152
+ grant You a licence to their contributions to the Work, under the terms of this Licence.
153
+
154
+ 7. Disclaimer of Warranty
155
+
156
+ The Work is a work in progress, which is continuously improved by numerous
157
+ Contributors. It is not a finished work and may therefore contain defects or “bugs”
158
+ inherent to this type of development.
159
+
160
+ For the above reason, the Work is provided under the Licence on an “as is” basis and
161
+ without warranties of any kind concerning the Work, including without limitation
162
+ merchantability, fitness for a particular purpose, absence of defects or errors, accuracy,
163
+ non-infringement of intellectual property rights other than copyright as stated in Article
164
+ 6 of this Licence.
165
+
166
+ This disclaimer of warranty is an essential part of the Licence and a condition for the
167
+ grant of any rights to the Work.
168
+
169
+ 8. Disclaimer of Liability
170
+
171
+ Except in the cases of wilful misconduct or damages directly caused to natural persons,
172
+ the Licensor will in no event be liable for any direct or indirect, material or moral,
173
+ damages of any kind, arising out of the Licence or of the use of the Work, including
174
+ without limitation, damages for loss of goodwill, work stoppage, computer failure or
175
+ malfunction, loss of data or any commercial damage, even if the Licensor has been
176
+ advised of the possibility of such damage. However, the Licensor will be liable under
177
+ statutory product liability laws as far such laws apply to the Work.
178
+
179
+ 9. Additional agreements
180
+
181
+ While distributing the Original Work or Derivative Works, You may choose to
182
+ conclude an additional agreement, defining obligations and/or services consistent with
183
+ this Licence. However, if accepting obligations, You may act only on your own behalf
184
+ and on your sole responsibility, not on behalf of the original Licensor or any other
185
+ Contributor, and only if You agree to indemnify, defend, and hold each Contributor
186
+ harmless for any liability incurred by, or claims asserted against such Contributor by
187
+ the fact You have accepted any warranty or additional liability.
188
+
189
+ 10. Acceptance of the Licence
190
+
191
+ The provisions of this Licence can be accepted by clicking on an icon “I agree” placed
192
+ under the bottom of a window displaying the text of this Licence or by affirming
193
+ consent in any other similar way, in accordance with the rules of applicable law.
194
+ Clicking on that icon indicates your clear and irrevocable acceptance of this Licence
195
+ and all of its terms and conditions.
196
+
197
+ Similarly, you irrevocably accept this Licence and all of its terms and conditions by
198
+ exercising any rights granted to You by Article 2 of this Licence, such as the use of the
199
+ Work, the creation by You of a Derivative Work or the Distribution or Communication
200
+ by You of the Work or copies thereof.
201
+
202
+ 11. Information to the public
203
+
204
+ In case of any Distribution and/or Communication of the Work by means of electronic
205
+ communication by You (for example, by offering to download the Work from a remote
206
+ location) the distribution channel or media (for example, a website) must at least
207
+ provide to the public the information requested by the applicable law regarding the
208
+ Licensor, the Licence and the way it may be accessible, concluded, stored and
209
+ reproduced by the Licensee.
210
+
211
+ 12. Termination of the Licence
212
+
213
+ The Licence and the rights granted hereunder will terminate automatically upon any
214
+ breach by the Licensee of the terms of the Licence.
215
+
216
+ Such a termination will not terminate the licences of any person who has received the
217
+ Work from the Licensee under the Licence, provided such persons remain in full
218
+ compliance with the Licence.
219
+
220
+ 13. Miscellaneous
221
+
222
+ Without prejudice of Article 9 above, the Licence represents the complete agreement
223
+ between the Parties as to the Work.
224
+
225
+ If any provision of the Licence is invalid or unenforceable under applicable law, this
226
+ will not affect the validity or enforceability of the Licence as a whole. Such provision
227
+ will be construed and/or reformed so as necessary to make it valid and enforceable.
228
+
229
+ The European Commission may publish other linguistic versions and/or new versions
230
+ of this Licence and/or updated versions of the Appendix, so far this is required and
231
+ reasonable, without reducing the scope of the rights granted by the Licence. New
232
+ versions of the Licence will be published with a unique version number.
233
+
234
+ All linguistic versions of this Licence, approved by the European Commission, have
235
+ identical value. Parties can take advantage of the linguistic version of their choice.
236
+
237
+ 14. Jurisdiction
238
+
239
+ Without prejudice to specific agreement between parties,
240
+ - any litigation resulting from the interpretation of this License, arising between the
241
+ European Union institutions, bodies, offices or agencies, as a Licensor, and any
242
+ Licensee, will be subject to the jurisdiction of the Court of Justice of the European
243
+ Union, as laid down in article 272 of the Treaty on the Functioning of the European
244
+ Union,
245
+ - any litigation arising between other parties and resulting from the interpretation of
246
+ this License, will be subject to the exclusive jurisdiction of the competent court
247
+ where the Licensor resides or conducts its primary business.
248
+
249
+ 15. Applicable Law
250
+
251
+ Without prejudice to specific agreement between parties,
252
+ - this Licence shall be governed by the law of the European Union Member State
253
+ where the Licensor has his seat, resides or has his registered office,
254
+ - this licence shall be governed by Belgian law if the Licensor has no seat, residence
255
+ or registered office inside a European Union Member State.
256
+
257
+ ===
258
+
259
+
260
+ Appendix
261
+
262
+
263
+
264
+ “Compatible Licences” according to Article 5 EUPL are:
265
+
266
+
267
+ - GNU General Public License (GPL) v. 2, v. 3
268
+
269
+ - GNU Affero General Public License (AGPL) v. 3
270
+
271
+ - Open Software License (OSL) v. 2.1, v. 3.0
272
+
273
+ - Eclipse Public License (EPL) v. 1.0
274
+
275
+ - Cecill v. 2.0, v. 2.1
276
+
277
+ - Mozilla Public Licence (MPL) v. 2
278
+
279
+ - GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
280
+
281
+ - Creative Commons Attribution-ShareAlike v. 3.0 Unported
282
+ (CC BY-SA 3.0) for works other than software
283
+
284
+ - European Union Public Licence (EUPL)v. 1.1, v. 1.2
285
+
286
+ - The European Commission may update this Appendix to later versions of
287
+ the above licences without producing a new version of the EUPL, as long
288
+ as they provide the rights granted in Article 2 of this Licence and protect
289
+ the covered Source Code from exclusive appropriation.
290
+ - All other changes or additions to this Appendix require the production of a
291
+ new EUPL version.
package/README.md CHANGED
@@ -2,35 +2,115 @@
2
2
 
3
3
  <!-- Generated by documentation.js. Update this documentation by updating the source code. -->
4
4
 
5
+ ## getNewTargets
6
+
7
+ Takes the targets and modifies them based on ownPlaces and isLocationSearch
8
+
9
+ ### Parameters
10
+
11
+ * `props` **[object][1]**
12
+
13
+ * `props.targets` **[Array][2]<[string][3]>**
14
+ * `props.isLocationSearch` **[boolean][4]**
15
+ * `props.isMobile` **[boolean][4]**
16
+ * `props.ownPlaces` **[boolean][4]**
17
+ * `props.sources` **[Array][2]<[string][3]>**
18
+
19
+ Returns **[Array][2]<[string][3]>** newTargets
20
+
5
21
  ## DTAutosuggest
6
22
 
7
- **Extends React.Component**
23
+ An autosuggest search input for finding locations, stops, stations, routes and vehicle rental stations.
8
24
 
9
25
  ### Parameters
10
26
 
11
- - `props`
27
+ * `props` **DTAutosuggestProps**
28
+
29
+ * `props.appElement`
30
+ * `props.id`
31
+ * `props.placeholder`
32
+ * `props.onSelect`
33
+ * `props.icon`
34
+ * `props.value`
35
+ * `props.onClear`
36
+ * `props.lang`
37
+ * `props.getAutoSuggestIcons`
38
+ * `props.handleViaPoints`
39
+ * `props.focusChange`
40
+ * `props.storeRef`
41
+ * `props.isMobile`
42
+ * `props.mobileLabel`
43
+ * `props.inputClassName`
44
+ * `props.translatedPlaceholder`
45
+ * `props.required`
46
+ * `props.ariaLabel`
47
+ * `props.fontWeights`
48
+ * `props.colors`
49
+ * `props.modeSet`
50
+ * `props.showScroll`
51
+ * `props.isEmbedded`
52
+ * `props.transportMode`
53
+ * `props.targets`
54
+ * `props.sources`
55
+ * `props.geocodingSize`
56
+ * `props.filterResults`
57
+ * `props.searchContext`
58
+ * `props.pathOpts`
59
+ * `props.refPoint`
60
+
61
+ ### Properties
62
+
63
+ * `appElement` **[string][3]**
64
+ * `id` **[string][3]**
65
+ * `placeholder` **[string][3]**
66
+ * `onSelect` **[function][5]**
67
+ * `icon` **[string][3]?**
68
+ * `value` **[string][3]?**
69
+ * `onClear` **[function][5]?**
70
+ * `lang` **[string][3]?**
71
+ * `getAutoSuggestIcons` **[Object][1]?**
72
+ * `handleViaPoints` **[function][5]?**
73
+ * `focusChange` **[function][5]?**
74
+ * `storeRef` **[function][5]?**
75
+ * `isMobile` **[boolean][4]?**
76
+ * `mobileLabel` **[string][3]?**
77
+ * `inputClassName` **[string][3]?**
78
+ * `translatedPlaceholder` **[string][3]?**
79
+ * `required` **[boolean][4]?**
80
+ * `fontWeights` **[Object][1]?**
81
+ * `colors` **[Object][1]?**
82
+ * `modeSet` **[string][3]?**
83
+ * `showScroll` **[boolean][4]?**
84
+ * `isEmbedded` **[boolean][4]?** Geocoding related props
85
+ * `searchContext` **[Object][1]**
86
+ * `transportMode` **[string][3]?**
87
+ * `targets` **[Array][2]<[string][3]>?**
88
+ * `sources` **[Array][2]<[string][3]>?**
89
+ * `geocodingSize` **[number][6]?**
90
+ * `filterResults` **[function][5]?**
91
+ * `pathOpts` **[Object][1]?**
92
+ * `refPoint` **[Object][1]?**
12
93
 
13
94
  ### Examples
14
95
 
15
96
  ```javascript
16
97
  const searchContext = {
17
- isPeliasLocationAware: false, // true / false does Let Pelias suggest based on current user location
18
- minimalRegexp: undefined, // used for testing min. regexp. For example: new RegExp('.{2,}'),
19
- lineRegexp: undefined, // identify searches for route numbers/labels: bus | train | metro. For example: new RegExp(
98
+ isPeliasLocationAware: false // true / false does Let Pelias suggest based on current user location
99
+ minimalRegexp: undefined // used for testing min. regexp. For example: new RegExp('.{2,}'),
100
+ lineRegexp: undefined // identify searches for route numbers/labels: bus | train | metro. For example: new RegExp(
20
101
  // '(^[0-9]+[a-z]?$|^[yuleapinkrtdz]$|(^m[12]?b?$))',
21
102
  // 'i',
22
103
  // ),
23
- URL_PELIAS: '', // url for pelias searches
24
- feedIDs: ['HSL', 'HSLLautta'], // FeedId's like [HSL, HSLLautta]
25
- geocodingSources: ['oa','osm','nlsfi'], // sources for geocoding
26
- geocodingSearchParams: {}, // Searchparmas fro geocoding
104
+ URL_PELIAS: '' // url for pelias searches
105
+ feedIDs: ['HSL', 'HSLLautta'] // FeedId's like [HSL, HSLLautta]
106
+ geocodingSources: ['oa','osm','nlsfi'] // sources for geocoding
107
+ geocodingSearchParams; {} // Searchparmas fro geocoding
27
108
  getFavouriteLocations: () => ({}), // Function that returns array of favourite locations.
28
109
  getFavouriteStops: () => ({}), // Function that returns array of favourite stops.
29
110
  getLanguage: () => ({}), // Function that returns current language.
30
111
  getFavouriteRoutes: () => ({}), // Function that returns array of favourite routes.
31
112
  getPositions: () => ({}), // Function that returns user's geolocation.
32
113
  getRoutesQuery: () => ({}), // Function that returns query for fetching routes.
33
- getAllBikeRentalStations: () => ({}), // Function that returns all bike rental stations from graphql API.
34
114
  getStopAndStationsQuery: () => ({}), // Function that fetches favourite stops and stations from graphql API.
35
115
  getFavouriteRoutesQuery: () => ({}), // Function that returns query for fetching favourite routes.
36
116
  getFavouriteVehicleRentalStations: () => ({}), // Function that returns favourite bike rental station.
@@ -52,7 +132,7 @@ const onClear = id => {
52
132
  return null;
53
133
  };
54
134
  const getAutoSuggestIcons: {
55
- // Called for every city bike station rendered as a search suggestion. Should return the icon and
135
+ // Called for every city bike station rendered as a search suggestion. Should return the icon and
56
136
  // color used for that station. Two icons are available, 'citybike-stop-digitransit' anditybike-stop-digitransit-secondary'.
57
137
  citybikes: station => {
58
138
  return ['citybike-stop-digitransit', '#f2b62d'];
@@ -60,7 +140,7 @@ const getAutoSuggestIcons: {
60
140
  }
61
141
  const transportMode = undefined;
62
142
  const placeholder = "stop-near-you";
63
- const targets = ['Locations', 'Stops', 'Routes']; // Defines what you are searching. all available options are Locations, Stops, Stations, Routes, VehicleRentalStation, FutureRoutes, MapPosition and CurrentPosition. Leave empty to search all targets.
143
+ const targets = ['Locations', 'Stops', 'Routes']; // Defines what you are searching. Options are Locations, Stops, Stations, Routes, VehicleRentalStations, FutureRoutes, MapPosition and CurrentPosition. Leave empty to search all targets.
64
144
  const sources = ['Favourite', 'History', 'Datasource'] // Defines where you are searching. all available are: Favourite, History (previously searched searches) and Datasource. Leave empty to use all sources.
65
145
  return (
66
146
  <DTAutosuggest
@@ -72,7 +152,6 @@ return (
72
152
  value="" // e.g. user typed string that is shown in search field
73
153
  onSelect={onSelect}
74
154
  onClear={onClear}
75
- autoFocus={false} // defines that should this field be automatically focused when page is loaded.
76
155
  lang={lang}
77
156
  getAutoSuggestIcons={getAutoSuggestIcons}
78
157
  transportMode={transportMode} // transportmode with which we filter the routes, e.g. route-BUS
@@ -89,10 +168,19 @@ return (
89
168
  translatedPlaceholder= // Optional. Custon translated placeholder text for autosuggest field.
90
169
  ```
91
170
 
92
- <!-- This file is automatically generated. Please don't edit it directly:
93
- if you find an error, edit the source file (likely index.js), and re-run
94
- ./scripts/generate-readmes in the digitransit-component project. -->
171
+ Returns **JSX.Element**
172
+
173
+ [1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
174
+
175
+ [2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
176
+
177
+ [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
178
+
179
+ [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
180
+
181
+ [5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
95
182
 
183
+ [6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
96
184
  ---
97
185
 
98
186
  This module is part of the Digitransit-ui project. It is maintained in the
@@ -107,7 +195,7 @@ Install this module individually:
107
195
  $ npm install @digitransit-component/digitransit-component-autosuggest
108
196
  ```
109
197
 
110
- Or install the digitransit-component module that includes it as a class:
198
+ Or install `@digitransit-component/digitransit-component`, which bundles every digitransit-component module:
111
199
 
112
200
  ```sh
113
201
  $ npm install @digitransit-component/digitransit-component
package/index.cjs ADDED
@@ -0,0 +1,7 @@
1
+ /* eslint-disable global-require */
2
+
3
+ if (process.env.NODE_ENV === 'development') {
4
+ module.exports = require('./lib/index.development.cjs');
5
+ } else {
6
+ module.exports = require('./lib/index.cjs');
7
+ }