UNPKG

9.18 kBJavaScriptView Raw
1// @flow
2import * as React from 'react';
3import * as valueTypes from './constants/value_types';
4/*:: import type { Observation, Preset } from 'mapeo-schema'*/
5
6/*:: import type {
7 // FeatureCollectionTemplate,
8 Bbox,
9 Point2D,
10 Point3D
11} from 'flow-geojson'*/
12
13/*:: export type Attachment = $ElementType<
14 $NonMaybeType<$ElementType<Observation, 'attachments'>>,
15 number
16>*/
17
18/*:: export type JSONValue =
19 | void
20 | null
21 | number
22 | string
23 | boolean
24 | JSONObject // eslint-disable-line no-use-before-define
25 | JSONArray*/
26
27/*:: export type JSONObject = { [key: string]: JSONValue }*/
28
29/*:: type JSONArray = Array<JSONValue>*/
30
31/*:: type Properties = JSONObject | null*/
32
33/*:: type FlattenedProperties = {
34 [key: string]: null | number | string | boolean
35} | null*/
36
37/*:: type FeatureTemplate<G, P> = {
38 id?: string | number,
39 type: 'Feature',
40 bbox?: Bbox,
41 properties: P,
42 geometry: G
43}*/
44
45/*:: type FeatureTemplateWithId<G, Properties> = FeatureTemplate<G, Properties> & {
46 id: string | number
47}*/
48
49/*:: export type PointFeature = FeatureTemplate<Point2D | Point3D | null, Properties>*/
50
51/*:: export type PointFeatureWithId = FeatureTemplateWithId<
52 Point2D | Point3D | null,
53 Properties
54>*/
55
56/*:: export type FlattenedPointFeature = FeatureTemplate<
57 Point2D | Point3D | null,
58 FlattenedProperties
59>*/
60
61/*:: export type PaperSize = 'a4' | 'letter'*/
62
63/*:: export type FieldState = Array<{|
64 id: string,
65 hidden: boolean,
66 label: React.Node
67|}>*/
68
69/*:: export type Filter = Array<number | string | boolean | null | Array<Filter>>*/
70
71/*:: export type ValueTypes = { [fieldkey: string]: $Values<typeof valueTypes> }*/
72
73/*:: export type FieldOrder = { [fieldkey: string]: number }*/
74
75/*:: export type Classes<S> = { [className: $Keys<S>]: string }*/
76
77/*:: export type StringStatistic = {|
78 count: number,
79 lengthMin?: number,
80 lengthMax?: number,
81 lengthVariance?: number,
82 lengthMean?: number,
83 wordsMin?: number,
84 wordsMax?: number,
85 wordsVariance?: number,
86 wordsMean?: number,
87 values: Map<string, number>
88|}*/
89
90/*:: export type NumberStatistic = {|
91 count: number,
92 min?: number,
93 max?: number,
94 variance?: number,
95 mean?: number,
96 values: Map<number, number>
97|}*/
98
99/*:: export type DateStatistic = {|
100 count: number,
101 min?: string,
102 max?: string,
103 mean?: string,
104 values: Map<string, number>
105|}*/
106
107/*:: export type NonArrayFieldStatistic = {|
108 string: StringStatistic,
109 boolean: {|
110 count: number,
111 values: Map<boolean, number>
112 |},
113 number: NumberStatistic,
114 date: DateStatistic,
115 datetime: DateStatistic,
116 url: number,
117 image: number,
118 video: number,
119 audio: number,
120 null: number,
121 undefined: number,
122 location: number
123|}*/
124
125/*:: export type FieldStatistic = {|
126 ...$Exact<NonArrayFieldStatistic>,
127 array?: {|
128 count: number,
129 lengthMin: number,
130 lengthMax: number,
131 valueStats: FieldStatistic
132 |}
133|}*/
134
135/*:: export type Statistics = { [fieldname: string]: FieldStatistic }*/
136
137/*:: type MediaType =
138 | typeof valueTypes.IMAGE_URL
139 | typeof valueTypes.AUDIO_URL
140 | typeof valueTypes.VIDEO_URL*/
141
142/*:: export type MediaArray = Array<{ src: string, type: MediaType }>*/
143
144/*:: export type Coordinates = {
145 altitude?: number,
146 heading?: number,
147 longitude: number,
148 speed?: number,
149 latitude: number,
150 accuracy?: number
151}*/
152
153/*:: export type Key = string | Array<string | number>*/
154
155/*:: type BaseField = {|
156 // A unique id used to reference the field from presets
157 id: string,
158 // They key in a tags object that this field applies to. For nested
159 // properties, key can be an array e.g. for tags = { foo: { bar: 1 } } the key
160 // is ['foo', 'bar']
161 key: Key,
162 label?: string,
163 // Displayed as a placeholder or hint for the field: use for additional
164 // context or example responses for the user
165 placeholder?: string,
166 // If a field definition contains the property "universal": true, this field will appear in the "Add Field" list for all presets
167 universal?: boolean,
168 // Displayed, but cannot be edited
169 readonly?: boolean
170|}*/
171
172/*:: export type TextField = {
173 ...BaseField,
174 type: 'text' | 'textarea' | 'localized',
175 appearance?: 'singleline' | 'multiline',
176 // Spaces are replaced with underscores
177 snake_case?: boolean
178}*/
179
180/*:: export type LinkField = {
181 ...BaseField,
182 type: 'link'
183}*/
184
185/*:: export type NumberField = {
186 ...BaseField,
187 type: 'number',
188 min_value?: number,
189 max_value?: number
190}*/
191
192/*:: export type SelectableFieldValue = number | string | boolean | null*/
193
194/*:: export type LabeledSelectOption = {|
195 value: SelectableFieldValue,
196 label: string
197|}*/
198
199/*:: export type SelectOptions = Array<SelectableFieldValue | LabeledSelectOption>*/
200
201/*:: export type SelectOneField = {
202 ...BaseField,
203 type: 'select_one',
204 options: SelectOptions,
205 // User can enter their own reponse if not on the list (defaults to true on
206 // desktop, false on mobile)
207 other?: boolean,
208 // Spaces are replaced with underscores
209 snake_case?: boolean
210}*/
211
212/*:: export type SelectMultipleField = {
213 ...$Exact<SelectOneField>,
214 type: 'select_multiple'
215}*/
216
217/*:: export type DateField = {
218 ...BaseField,
219 type: 'date',
220 min_value?: string,
221 max_value?: string
222}*/
223
224/*:: export type DateTimeField = {
225 ...BaseField,
226 type: 'datetime',
227 min_value?: string,
228 max_value?: string
229}*/
230
231/*:: export type Field =
232 | TextField
233 | NumberField
234 | SelectOneField
235 | SelectMultipleField
236 | DateField
237 | DateTimeField
238 | LinkField*/
239
240/*:: export type MessageDescriptor = {
241 id: string,
242 description?: string | {},
243 defaultMessage?: string
244}*/
245
246/*:: type IntlConfig = {|
247 locale?: string,
248 timeZone?: string,
249 textComponent?: any,
250 messages?: { [key: string]: string },
251 defaultLocale: string,
252 onError?: (err: string) => void
253|}*/
254
255/*:: type FormatDateOptions = {|
256 localeMatcher?: 'lookup' | 'best fit',
257 timeZone?: string,
258 hour12?: boolean,
259 hourCycle?: 'h11' | 'h12' | 'h23' | 'h24',
260 formatMatcher?: 'basic' | 'best fit',
261 weekday?: 'long' | 'short' | 'narrow',
262 era?: 'long' | 'short' | 'narrow',
263 year?: 'numeric' | '2-digit',
264 month?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow',
265 day?: 'numeric' | '2-digit',
266 hour?: 'numeric' | '2-digit',
267 minute?: 'numeric' | '2-digit',
268 second?: 'numeric' | '2-digit',
269 timeZoneName?: 'long' | 'short'
270|}*/
271
272/*:: type oneToTwenty =
273 | 1
274 | 2
275 | 3
276 | 4
277 | 5
278 | 6
279 | 7
280 | 8
281 | 9
282 | 10
283 | 11
284 | 12
285 | 13
286 | 14
287 | 15
288 | 16
289 | 17
290 | 18
291 | 19
292 | 20*/
293
294/*:: type FormatNumberOptions = {|
295 localeMatcher?: 'lookup' | 'best fit',
296 style?: 'decimal' | 'currency' | 'percent',
297 currenty?: string,
298 currencyDisplay?: 'symbol' | 'code' | 'name',
299 useGrouping?: boolean,
300 minimumIntegerDigits?: oneToTwenty | 21,
301 minimumFractionDigits?: 0 | oneToTwenty,
302 maximumFractionDigits?: 0 | oneToTwenty,
303 minimumSignificantDigits?: oneToTwenty | 21,
304 maximumSignificantDigits?: oneToTwenty | 21
305|}*/
306
307/*:: type FormatRelativeOptions = {|
308 localeMatcher?: 'lookup' | 'best fit',
309 numeric?: 'always' | 'auto',
310 type?: 'long' | 'short' | 'narrow'
311|}*/
312
313/*:: type Unit =
314 | 'second'
315 | 'minute'
316 | 'hour'
317 | 'day'
318 | 'week'
319 | 'month'
320 | 'quarter'
321 | 'year'*/
322
323/*:: type FormatPluralOptions = {
324 type?: 'cardinal' | 'ordinal'
325}*/
326
327/*:: export type Primitive = string | boolean | null | void | number*/
328
329/*:: type MessageValues = { [key: string]: Primitive }*/
330
331/*:: type IntlFormatters = {|
332 formatDate: (value: number | Date, opts?: FormatDateOptions) => string,
333 formatTime: (value: number | Date, opts?: FormatDateOptions) => string,
334 formatRelativeTime: (
335 value: number,
336 unit: Unit,
337 opts?: FormatRelativeOptions
338 ) => string,
339 formatNumber: (value: number, opts?: FormatNumberOptions) => string,
340 formatPlural: (value: number, opts?: FormatPluralOptions) => string,
341 formatMessage: (
342 descriptor: MessageDescriptor,
343 values?: MessageValues
344 ) => string,
345 formatHTMLMessage: (
346 descriptor: MessageDescriptor,
347 values?: MessageValues
348 ) => string
349|}*/
350
351/*:: export type IntlShape = {|
352 ...IntlConfig,
353 ...IntlFormatters
354|}*/
355
356/*:: export type GetMedia = (
357 attachment: Attachment,
358 options?: { width: number, height: number }
359) => { src: string, type: 'image' | 'video' | 'audio' } | void*/
360
361/*:: export type GetMediaUrl = (
362 attachmentId: string,
363 size: 'thumbnail' | 'preview' | 'original'
364) => string*/
365
366/*:: export type GetIconUrl = (iconId: string) => string*/
367
368/*:: export type PresetWithFields = {
369 ...$Exact<Preset>,
370 fields: Field[]
371}*/
372
373/*:: export type PresetWithAdditionalFields = {
374 ...$Exact<PresetWithFields>,
375 additionalFields: Field[]
376}*/
377
378/*:: export type CameraOptions = {
379 center: [number, number],
380 zoom: number,
381 bearing: number,
382 pitch: number
383}*/
384
385/*:: export type CommonViewContentProps = {
386 /** Array of observations to render *-/
387 observations: Array<Observation>,
388 /** Called with id of observation clicked, optionally with image index *-/
389 onClick: (id: string, imageIndex?: number) => void,
390 getPreset: Observation => PresetWithAdditionalFields,
391 /**
392 * For a given attachment, return `src` and `type`
393 *-/
394 getMedia: GetMedia
395}*/
396//# sourceMappingURL=types.js.map
\No newline at end of file