@imerss/inat-components 1.1.2 → 2.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.
- package/PUBLISH.md +13 -0
- package/README.md +20 -0
- package/dist/index.d.ts +86 -83
- package/dist/index.js +280 -395
- package/dist/standalone.min.js +3 -0
- package/package.json +17 -5
- package/public/standalone.html +55 -0
- package/rollup.config.js +15 -4
- package/src/__shared/api/common-taxa.ts +3 -3
- package/src/__shared/api/favourites.ts +3 -3
- package/src/__shared/api/recent-observations.ts +3 -3
- package/src/__shared/api/summary.ts +1 -0
- package/src/__shared/constants.ts +3 -2
- package/src/__shared/index.ts +1 -1
- package/src/__shared/typings.ts +49 -57
- package/src/__shared/utils/configUtils.ts +7 -7
- package/src/__shared/utils/dateUtils.ts +1 -1
- package/src/components/common-taxa/common-taxa.tsx +22 -57
- package/src/components/error/error.tsx +1 -1
- package/src/components/favourites/favourites.tsx +23 -58
- package/src/components/hooks/hooks.tsx +20 -10
- package/src/components/loader/loader.tsx +1 -1
- package/src/components/observation/observation.tsx +1 -1
- package/src/components/recent-observations/recent-observations.tsx +24 -58
- package/src/components/summary/ObserverList.tsx +3 -3
- package/src/components/summary/summary.tsx +53 -54
- package/src/components/tabs/tabs.tsx +41 -26
- package/src/components/taxon-panel/taxon-panel.tsx +75 -96
- package/src/components/year-dropdown/year-dropdown.tsx +11 -7
- package/src/hooks/useLoadSourceData.ts +81 -0
- package/src/index.ts +1 -1
- package/src/types/index.d.ts +17 -0
- package/src/types/standalone.d.ts +6 -0
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,20 @@
|
|
|
1
|
+
# inat-components
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Standalone app
|
|
6
|
+
|
|
7
|
+
From `@imerss/inat-components` 2.0.0 onwards, the package contains a `/dist/standalone.min.js` script which can be used
|
|
8
|
+
for any.
|
|
9
|
+
|
|
10
|
+
Usage:
|
|
11
|
+
|
|
12
|
+
1. Download the package from npmjs.org either manually, or via `npm install @imerss/inat-components`.
|
|
13
|
+
2. Copy the standalone.min.js file onto your site.
|
|
14
|
+
3. Add it to your page:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
<script src="./path/to/standalone.min.js"></script>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
4.
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
favourites = "favourites",
|
|
124
|
-
stats = "stats"
|
|
95
|
+
declare enum DataSourceEnum {
|
|
96
|
+
autoLoad = "autoLoad",
|
|
97
|
+
url = "url"
|
|
125
98
|
}
|
|
126
|
-
declare type
|
|
127
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
127
|
+
generalClasses?: GeneralClasses;
|
|
153
128
|
tabDesc?: string;
|
|
154
129
|
};
|
|
155
|
-
declare type
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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,
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
202
|
-
|
|
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
|
-
|
|
205
|
-
|
|
207
|
+
features: TaxonPanelFeatures;
|
|
208
|
+
generalClasses: GeneralClasses;
|
|
206
209
|
itemWidth?: number;
|
|
207
|
-
classes?: BaseClasses;
|
|
208
|
-
tabDescs?: TabDescs;
|
|
209
210
|
};
|
|
210
|
-
declare const TaxonPanel: ({
|
|
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:
|
|
222
|
+
year: number;
|
|
222
223
|
};
|
|
223
224
|
declare const CommonTaxaLabel: (data: CommonTaxData & {
|
|
224
|
-
classes:
|
|
225
|
+
classes: GeneralClasses;
|
|
225
226
|
}) => JSX.Element;
|
|
226
|
-
declare const CommonTaxa: ({ year, source, taxonId, placeId,
|
|
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:
|
|
231
|
+
classes: GeneralClasses;
|
|
231
232
|
}) => JSX.Element;
|
|
232
|
-
declare const RecentObservations: ({ taxonId, placeId,
|
|
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:
|
|
236
|
+
year: number | string;
|
|
236
237
|
};
|
|
237
238
|
declare const FavouritesLabel: (data: FavouritesData & {
|
|
238
|
-
classes:
|
|
239
|
+
classes: GeneralClasses;
|
|
239
240
|
}) => JSX.Element;
|
|
240
|
-
declare const Favourites: ({ year, source, taxonId, placeId,
|
|
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:
|
|
249
|
-
|
|
248
|
+
year: number;
|
|
249
|
+
source: DataSource;
|
|
250
250
|
dataUrl?: string;
|
|
251
|
-
|
|
251
|
+
generalClasses?: GeneralClasses;
|
|
252
|
+
className?: string;
|
|
252
253
|
tabDesc?: string;
|
|
254
|
+
observersListClass?: string;
|
|
255
|
+
statsCountSummaryClass?: string;
|
|
253
256
|
};
|
|
254
|
-
declare const Summary: ({ source,
|
|
257
|
+
declare const Summary: ({ source, dataUrl, taxonId, placeId, year, generalClasses, className, tabDesc, observersListClass, statsCountSummaryClass }: SummaryProps) => JSX.Element;
|
|
255
258
|
|
|
256
|
-
export {
|
|
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 };
|