@imerss/inat-components 1.1.2 → 2.0.1

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/PUBLISH.md ADDED
@@ -0,0 +1,13 @@
1
+ ### Publishing new versions
2
+
3
+ Here's how to publish a new version of this package.
4
+
5
+ 1. Go to the root of the monorepo and run `yarn install`, then `yarn boot`
6
+ 2. Update the version in `packages/inat-component`'s package.json
7
+ 3. Run `yarn build` to generate a fresh `/dist` folder (you can clean first, but the clean command currently also
8
+ deletes __shared, so you'll need to rebuild from the root if you do that)
9
+
10
+ Step 3 actually generates + copies over the result from the inat-components-standalone package, so in the dist folder
11
+ you should see a standalone.min.js file. All is good!
12
+
13
+ Now you can `npm publish`.
package/README.md CHANGED
@@ -0,0 +1,12 @@
1
+ # @imerss/inat-components
2
+
3
+ The [inat-components repo](https://github.com/IMERSS/inat-components) contains some pre-built React components to
4
+ display iNaturalist data on your own sites. The original goal was to provide add an
5
+ [interactive page to the BC Lepidoptera website](https://bcleps.weebly.com/inat.html) so visitors could see some
6
+ high-level information about lepidoptera (butterflies and moths) spotted in British Columbia. But the code
7
+ was written to allow it to be re-used by any website and for any taxon or place.
8
+
9
+ This specific package is only the React components, plus a standalone.min.js file for
10
+
11
+ Please see the [main documentation](https://github.com/IMERSS/inat-components) for more information on the script,
12
+ including the standalone version.
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ declare type CommonTaxaCallProps = {
2
2
  year: string | number;
3
3
  taxonId: string | number;
4
4
  placeId: string | number;
5
- perPage: number;
5
+ numResults: number;
6
6
  };
7
7
  declare type CommonTaxData = {
8
8
  id: number;
@@ -15,13 +15,13 @@ declare type CommonTaxaRespData = {
15
15
  totalResults: number;
16
16
  results: [CommonTaxData];
17
17
  };
18
- declare const getCommonTaxa: ({ year, taxonId, placeId, perPage }: CommonTaxaCallProps) => Promise<CommonTaxaRespData>;
18
+ declare const getCommonTaxa: ({ year, taxonId, placeId, numResults }: CommonTaxaCallProps) => Promise<CommonTaxaRespData>;
19
19
 
20
20
  declare type FavouritesCallProps = {
21
21
  year: string | number;
22
22
  taxonId: string | number;
23
23
  placeId: string | number;
24
- perPage: number;
24
+ numResults: number;
25
25
  };
26
26
  declare type FavouritesData = {
27
27
  id: number;
@@ -37,12 +37,12 @@ declare type FavouritesRespData = {
37
37
  totalResults: number;
38
38
  results: [FavouritesData];
39
39
  };
40
- declare const getFavourites: ({ year, taxonId, placeId, perPage }: FavouritesCallProps) => Promise<FavouritesRespData>;
40
+ declare const getFavourites: ({ year, taxonId, placeId, numResults }: FavouritesCallProps) => Promise<FavouritesRespData>;
41
41
 
42
42
  declare type RecentObservationsCallProps = {
43
43
  taxonId: string | number;
44
44
  placeId: string | number;
45
- perPage: number;
45
+ numResults: number;
46
46
  };
47
47
  declare type RecentObservationData = {
48
48
  id: number;
@@ -57,7 +57,7 @@ declare type RecentObservationsRespData = {
57
57
  totalResults: number;
58
58
  results: [RecentObservationData];
59
59
  };
60
- declare const getRecentObservations: ({ taxonId, placeId, perPage }: RecentObservationsCallProps) => Promise<RecentObservationsRespData>;
60
+ declare const getRecentObservations: ({ taxonId, placeId, numResults }: RecentObservationsCallProps) => Promise<RecentObservationsRespData>;
61
61
 
62
62
  declare type SummaryApiProps = {
63
63
  taxonId: number;
@@ -86,61 +86,36 @@ declare type SeasonalityData = {
86
86
  };
87
87
  declare const getSeasonalityData: (taxonId: number, placeId: number, year: string | number) => Promise<SeasonalityData>;
88
88
 
89
- declare type ConfigFile = {
90
- taxa: TaxaConfig[];
91
- places: PlaceConfig[];
92
- features: {
93
- [Feature.commonTaxa]?: {
94
- numResults?: number;
95
- };
96
- [Feature.favourites]?: {
97
- numResults?: number;
98
- numYears?: number;
99
- };
100
- [Feature.recentObservations]?: {
101
- numResults?: number;
102
- numYears?: number;
103
- };
104
- [Feature.stats]?: {
105
- numTopObservers?: number;
106
- };
107
- };
108
- };
109
- declare enum DataSource {
110
- autoLoad = "autoLoad",
111
- dataProp = "dataProp",
112
- url = "url"
113
- }
114
89
  declare enum Feature {
115
90
  commonTaxa = "commonTaxa",
116
91
  favourites = "favourites",
117
92
  recentObservations = "recentObservations",
118
93
  stats = "stats"
119
94
  }
120
- declare enum Tab {
121
- recent = "recent",
122
- commonTaxa = "commonTaxa",
123
- favourites = "favourites",
124
- stats = "stats"
95
+ declare enum DataSourceEnum {
96
+ autoLoad = "autoLoad",
97
+ url = "url"
125
98
  }
126
- declare type BaseClasses = {
127
- tabs?: string;
99
+ declare type DataSource = `${DataSourceEnum}`;
100
+ declare type ItemConfig = {
101
+ id: number;
102
+ str: string;
103
+ };
104
+ declare type GeneralClasses = {
105
+ tabsElement?: string;
128
106
  yearsDropdown?: string;
129
107
  pageHeadings?: string;
108
+ tabDesc?: string;
130
109
  observationLabelTitle?: string;
131
110
  observationLabelDate?: string;
132
111
  observationLabelName?: string;
133
- observersList?: string;
134
- statsCountSummary?: string;
135
- tabDesc?: string;
112
+ observationCount?: string;
136
113
  };
137
114
  declare type BaseComponentProps = {
138
115
  taxonId?: number;
139
116
  placeId?: number;
140
- filename?: string;
141
- perPage?: number;
117
+ numResults?: number;
142
118
  source?: DataSource;
143
- data?: any;
144
119
  dataUrl?: string;
145
120
  className?: string;
146
121
  itemWidth?: number;
@@ -149,27 +124,45 @@ declare type BaseComponentProps = {
149
124
  error?: any;
150
125
  loader?: any;
151
126
  };
152
- classes?: BaseClasses;
127
+ generalClasses?: GeneralClasses;
153
128
  tabDesc?: string;
154
129
  };
155
- declare type TaxaConfig = {
156
- label: string;
157
- short: string;
158
- taxonId: number;
130
+ declare type RecentObservationsConfig = {
131
+ feature: Feature.recentObservations;
132
+ title?: string;
133
+ numResults?: number;
134
+ desc?: string;
135
+ className?: string;
159
136
  };
160
- declare type PlaceConfig = {
161
- label: string;
162
- short: string;
163
- placeId: number;
137
+ declare type CommonTaxaConfig = {
138
+ feature: Feature.commonTaxa;
139
+ title?: string;
140
+ numResults?: number;
141
+ numYears?: number;
142
+ desc?: string;
143
+ className?: string;
144
+ };
145
+ declare type FavouritesConfig = {
146
+ feature: Feature.favourites;
147
+ title?: string;
148
+ numResults?: number;
149
+ numYears?: number;
150
+ desc?: string;
151
+ className?: string;
164
152
  };
165
- declare type TabDescs = {
166
- recentDesc?: string;
167
- mostCommonDesc?: string;
168
- mostFavouritedDesc?: string;
169
- generalStatsDesc?: string;
153
+ declare type StatsConfig = {
154
+ feature: Feature.stats;
155
+ title?: string;
156
+ numTopObservers?: number;
157
+ numYears?: number;
158
+ desc?: string;
159
+ className?: string;
160
+ observersListClass?: string;
161
+ statsCountSummaryClass?: string;
170
162
  };
163
+ declare type TaxonPanelFeatures = (RecentObservationsConfig | CommonTaxaConfig | FavouritesConfig | StatsConfig)[];
171
164
 
172
- declare const getSourceFile: (api: Feature, taxonInfo?: TaxaConfig, placeInfo?: PlaceConfig, year?: string | number) => string;
165
+ declare const getSourceFile: (api: Feature, taxon: ItemConfig, place: ItemConfig, year?: string | number) => string;
173
166
 
174
167
  declare const getCurrentYear: () => number;
175
168
  declare const formatDate: (date: string, dateFormat?: string) => any;
@@ -177,20 +170,23 @@ declare const formatDate: (date: string, dateFormat?: string) => any;
177
170
  declare const numberWithCommas: (x: number) => string;
178
171
 
179
172
  declare const BASE_API_URL = "https://api.inaturalist.org";
180
- declare const PER_PAGE = 100;
173
+ declare const NUM_RESULTS = 100;
174
+ declare const DEFAULT_NUM_YEARS = 10;
181
175
  declare const BASE_URL = "https://www.inaturalist.org";
182
176
  declare const ERROR_LOG_FILENAME = "inat-components-error.log";
183
177
  declare const DEFAULT_ITEM_WIDTH = 150;
184
178
 
185
179
  declare const constants_BASE_API_URL: typeof BASE_API_URL;
186
- declare const constants_PER_PAGE: typeof PER_PAGE;
180
+ declare const constants_NUM_RESULTS: typeof NUM_RESULTS;
181
+ declare const constants_DEFAULT_NUM_YEARS: typeof DEFAULT_NUM_YEARS;
187
182
  declare const constants_BASE_URL: typeof BASE_URL;
188
183
  declare const constants_ERROR_LOG_FILENAME: typeof ERROR_LOG_FILENAME;
189
184
  declare const constants_DEFAULT_ITEM_WIDTH: typeof DEFAULT_ITEM_WIDTH;
190
185
  declare namespace constants {
191
186
  export {
192
187
  constants_BASE_API_URL as BASE_API_URL,
193
- constants_PER_PAGE as PER_PAGE,
188
+ constants_NUM_RESULTS as NUM_RESULTS,
189
+ constants_DEFAULT_NUM_YEARS as DEFAULT_NUM_YEARS,
194
190
  constants_BASE_URL as BASE_URL,
195
191
  constants_ERROR_LOG_FILENAME as ERROR_LOG_FILENAME,
196
192
  constants_DEFAULT_ITEM_WIDTH as DEFAULT_ITEM_WIDTH,
@@ -198,16 +194,21 @@ declare namespace constants {
198
194
  }
199
195
 
200
196
  declare type TaxonPanelProps = {
201
- taxonId: number;
202
- placeId: number;
197
+ taxon: {
198
+ id: number;
199
+ str: string;
200
+ };
201
+ place: {
202
+ id: number;
203
+ str: string;
204
+ };
205
+ dataSourceBaseUrl: string;
203
206
  dataSource: DataSource;
204
- config: ConfigFile;
205
- baseUrl: string;
207
+ features: TaxonPanelFeatures;
208
+ generalClasses: GeneralClasses;
206
209
  itemWidth?: number;
207
- classes?: BaseClasses;
208
- tabDescs?: TabDescs;
209
210
  };
210
- declare const TaxonPanel: ({ taxonId, placeId, dataSource, config, baseUrl, itemWidth, classes, tabDescs }: TaxonPanelProps) => JSX.Element;
211
+ declare const TaxonPanel: ({ taxon, place, features, dataSource, dataSourceBaseUrl, itemWidth, generalClasses }: TaxonPanelProps) => JSX.Element;
211
212
 
212
213
  declare type ObservationProps = {
213
214
  imageUrl: string;
@@ -218,39 +219,41 @@ declare type ObservationProps = {
218
219
  declare const Observation: ({ imageUrl, linkUrl, itemWidth, children }: ObservationProps) => JSX.Element;
219
220
 
220
221
  declare type CommonTaxaProps = BaseComponentProps & {
221
- year: string | number;
222
+ year: number;
222
223
  };
223
224
  declare const CommonTaxaLabel: (data: CommonTaxData & {
224
- classes: BaseClasses;
225
+ classes: GeneralClasses;
225
226
  }) => JSX.Element;
226
- declare const CommonTaxa: ({ year, source, taxonId, placeId, perPage, itemWidth, data, dataUrl, components, classes, className, tabDesc }: CommonTaxaProps) => JSX.Element;
227
+ declare const CommonTaxa: ({ year, source, taxonId, placeId, numResults, itemWidth, dataUrl, components, generalClasses, className, tabDesc }: CommonTaxaProps) => JSX.Element;
227
228
 
228
229
  declare type RecentObservationsProps = BaseComponentProps;
229
230
  declare const RecentObservationLabel: (obs: RecentObservationData & {
230
- classes: BaseClasses;
231
+ classes: GeneralClasses;
231
232
  }) => JSX.Element;
232
- declare const RecentObservations: ({ taxonId, placeId, data, dataUrl, source, perPage, itemWidth, components, className, classes, tabDesc }: RecentObservationsProps) => JSX.Element;
233
+ declare const RecentObservations: ({ taxonId, placeId, dataUrl, components, className, generalClasses, tabDesc, source, numResults, itemWidth }: RecentObservationsProps) => JSX.Element;
233
234
 
234
235
  declare type FavouritesProps = BaseComponentProps & {
235
- year: string | number;
236
+ year: number | string;
236
237
  };
237
238
  declare const FavouritesLabel: (data: FavouritesData & {
238
- classes: BaseClasses;
239
+ classes: GeneralClasses;
239
240
  }) => JSX.Element;
240
- declare const Favourites: ({ year, source, taxonId, placeId, data, dataUrl, components, className, tabDesc, classes, itemWidth, perPage }: FavouritesProps) => JSX.Element;
241
+ declare const Favourites: ({ year, source, taxonId, placeId, dataUrl, components, className, tabDesc, generalClasses, itemWidth, numResults }: FavouritesProps) => JSX.Element;
241
242
 
242
243
  declare const SeasonalityGraph: ({ data }: any) => JSX.Element;
243
244
 
244
245
  declare type SummaryProps = {
245
- source: DataSource;
246
246
  taxonId: number;
247
247
  placeId: number;
248
- year: string | number;
249
- data?: FavouritesRespData;
248
+ year: number;
249
+ source: DataSource;
250
250
  dataUrl?: string;
251
- classes?: BaseClasses;
251
+ generalClasses?: GeneralClasses;
252
+ className?: string;
252
253
  tabDesc?: string;
254
+ observersListClass?: string;
255
+ statsCountSummaryClass?: string;
253
256
  };
254
- declare const Summary: ({ source, data, dataUrl, taxonId, placeId, year, classes, tabDesc }: SummaryProps) => JSX.Element;
257
+ declare const Summary: ({ source, dataUrl, taxonId, placeId, year, generalClasses, className, tabDesc, observersListClass, statsCountSummaryClass }: SummaryProps) => JSX.Element;
255
258
 
256
- export { BaseClasses, BaseComponentProps, constants as C, CommonTaxData, CommonTaxa, CommonTaxaCallProps, CommonTaxaLabel, CommonTaxaProps, CommonTaxaRespData, ConfigFile, DataSource, Favourites, FavouritesCallProps, FavouritesData, FavouritesLabel, FavouritesProps, FavouritesRespData, Feature, Observation, ObservationProps, Observer, PlaceConfig, RecentObservationData, RecentObservationLabel, RecentObservations, RecentObservationsCallProps, RecentObservationsProps, RecentObservationsRespData, SeasonalityData, SeasonalityGraph, Summary, SummaryApiProps, SummaryData, SummaryProps, Tab, TabDescs, TaxaConfig, TaxonPanelProps, TaxonPanel as default, formatDate, getCommonTaxa, getCurrentYear, getFavourites, getObservationSummary, getObserverSummary, getRecentObservations, getSeasonalityData, getSourceFile, getSummary, numberWithCommas };
259
+ export { BaseComponentProps, constants as C, CommonTaxData, CommonTaxa, CommonTaxaCallProps, CommonTaxaConfig, CommonTaxaLabel, CommonTaxaProps, CommonTaxaRespData, DataSource, DataSourceEnum, Favourites, FavouritesCallProps, FavouritesConfig, FavouritesData, FavouritesLabel, FavouritesProps, FavouritesRespData, Feature, GeneralClasses, ItemConfig, Observation, ObservationProps, Observer, RecentObservationData, RecentObservationLabel, RecentObservations, RecentObservationsCallProps, RecentObservationsConfig, RecentObservationsProps, RecentObservationsRespData, SeasonalityData, SeasonalityGraph, StatsConfig, Summary, SummaryApiProps, SummaryData, SummaryProps, TaxonPanelFeatures, TaxonPanelProps, TaxonPanel as default, formatDate, getCommonTaxa, getCurrentYear, getFavourites, getObservationSummary, getObserverSummary, getRecentObservations, getSeasonalityData, getSourceFile, getSummary, numberWithCommas };