UNPKG

10.1 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../src/types.js"],"names":["React","valueTypes"],"mappings":"AAAA;AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,OAAO,KAAKC,UAAZ,MAA4B,yBAA5B","sourcesContent":["// @flow\nimport * as React from 'react'\nimport * as valueTypes from './constants/value_types'\nimport type { Observation, Preset } from 'mapeo-schema'\n// import type { Properties as CSSProperties } from 'csstype'\n\nimport type {\n // FeatureCollectionTemplate,\n Bbox,\n Point2D,\n Point3D\n} from 'flow-geojson'\n\n/**\n * Observation Attachment\n */\nexport type Attachment = $ElementType<\n $NonMaybeType<$ElementType<Observation, 'attachments'>>,\n number\n>\n\n// export type StyleProp = CSSProperties<string | number>\n\n// Almost JSON value, but we can also have 'undefined' as a value\nexport type JSONValue =\n | void\n | null\n | number\n | string\n | boolean\n | JSONObject // eslint-disable-line no-use-before-define\n | JSONArray // eslint-disable-line no-use-before-define\nexport type JSONObject = { [key: string]: JSONValue }\ntype JSONArray = Array<JSONValue>\ntype Properties = JSONObject | null\n\ntype FlattenedProperties = {\n [key: string]: null | number | string | boolean\n} | null\n// type FlattenedPropertiesArray = {\n// [key: string]: null | number | string | boolean | JSONArray\n// } | null\n\ntype FeatureTemplate<G, P> = {\n id?: string | number,\n type: 'Feature',\n bbox?: Bbox,\n properties: P,\n geometry: G\n}\n\ntype FeatureTemplateWithId<G, Properties> = FeatureTemplate<G, Properties> & {\n id: string | number\n}\n\nexport type PointFeature = FeatureTemplate<Point2D | Point3D | null, Properties>\n\nexport type PointFeatureWithId = FeatureTemplateWithId<\n Point2D | Point3D | null,\n Properties\n>\n\nexport type FlattenedPointFeature = FeatureTemplate<\n Point2D | Point3D | null,\n FlattenedProperties\n>\n\n// export type FeatureCollection = FeatureCollectionTemplate<PointFeature>\n\nexport type PaperSize = 'a4' | 'letter'\n\n// Used to store state about field visibility in views\nexport type FieldState = Array<{|\n id: string,\n hidden: boolean,\n label: React.Node\n|}>\nexport type Filter = Array<number | string | boolean | null | Array<Filter>>\n\nexport type ValueTypes = { [fieldkey: string]: $Values<typeof valueTypes> }\n\nexport type FieldOrder = { [fieldkey: string]: number }\n\nexport type Classes<S> = { [className: $Keys<S>]: string }\n\nexport type StringStatistic = {|\n count: number,\n lengthMin?: number,\n lengthMax?: number,\n lengthVariance?: number,\n lengthMean?: number,\n wordsMin?: number,\n wordsMax?: number,\n wordsVariance?: number,\n wordsMean?: number,\n values: Map<string, number>\n|}\n\nexport type NumberStatistic = {|\n count: number,\n min?: number,\n max?: number,\n variance?: number,\n mean?: number,\n values: Map<number, number>\n|}\n\nexport type DateStatistic = {|\n count: number,\n min?: string,\n max?: string,\n mean?: string,\n values: Map<string, number>\n|}\n\nexport type NonArrayFieldStatistic = {|\n string: StringStatistic,\n boolean: {|\n count: number,\n values: Map<boolean, number>\n |},\n number: NumberStatistic,\n date: DateStatistic,\n datetime: DateStatistic,\n url: number,\n image: number,\n video: number,\n audio: number,\n null: number,\n undefined: number,\n location: number\n|}\n\nexport type FieldStatistic = {|\n ...$Exact<NonArrayFieldStatistic>,\n array?: {|\n count: number,\n lengthMin: number,\n lengthMax: number,\n valueStats: FieldStatistic\n |}\n|}\n\nexport type Statistics = { [fieldname: string]: FieldStatistic }\n\ntype MediaType =\n | typeof valueTypes.IMAGE_URL\n | typeof valueTypes.AUDIO_URL\n | typeof valueTypes.VIDEO_URL\nexport type MediaArray = Array<{ src: string, type: MediaType }>\n\nexport type Coordinates = {\n altitude?: number,\n heading?: number,\n longitude: number,\n speed?: number,\n latitude: number,\n accuracy?: number\n}\n\nexport type Key = string | Array<string | number>\n\ntype BaseField = {|\n // A unique id used to reference the field from presets\n id: string,\n // They key in a tags object that this field applies to. For nested\n // properties, key can be an array e.g. for tags = { foo: { bar: 1 } } the key\n // is ['foo', 'bar']\n key: Key,\n label?: string,\n // Displayed as a placeholder or hint for the field: use for additional\n // context or example responses for the user\n placeholder?: string,\n // If a field definition contains the property \"universal\": true, this field will appear in the \"Add Field\" list for all presets\n universal?: boolean,\n // Displayed, but cannot be edited\n readonly?: boolean\n|}\n\n// type FieldType =\n// | 'text'\n// | 'number'\n// | 'select_one'\n// | 'select_multiple'\n// | 'date'\n// | 'datetime'\n\nexport type TextField = {\n ...BaseField,\n type: 'text' | 'textarea' | 'localized',\n appearance?: 'singleline' | 'multiline',\n // Spaces are replaced with underscores\n snake_case?: boolean\n}\n\nexport type LinkField = {\n ...BaseField,\n type: 'link'\n}\n\nexport type NumberField = {\n ...BaseField,\n type: 'number',\n min_value?: number,\n max_value?: number\n}\n\nexport type SelectableFieldValue = number | string | boolean | null\n\nexport type LabeledSelectOption = {|\n value: SelectableFieldValue,\n label: string\n|}\n\nexport type SelectOptions = Array<SelectableFieldValue | LabeledSelectOption>\n\nexport type SelectOneField = {\n ...BaseField,\n type: 'select_one',\n options: SelectOptions,\n // User can enter their own reponse if not on the list (defaults to true on\n // desktop, false on mobile)\n other?: boolean,\n // Spaces are replaced with underscores\n snake_case?: boolean\n}\n\nexport type SelectMultipleField = {\n ...$Exact<SelectOneField>,\n type: 'select_multiple'\n}\n\nexport type DateField = {\n ...BaseField,\n type: 'date',\n min_value?: string,\n max_value?: string\n}\n\nexport type DateTimeField = {\n ...BaseField,\n type: 'datetime',\n min_value?: string,\n max_value?: string\n}\n\nexport type Field =\n | TextField\n | NumberField\n | SelectOneField\n | SelectMultipleField\n | DateField\n | DateTimeField\n | LinkField\n\nexport type MessageDescriptor = {\n id: string,\n description?: string | {},\n defaultMessage?: string\n}\n\ntype IntlConfig = {|\n locale?: string,\n timeZone?: string,\n textComponent?: any,\n messages?: { [key: string]: string },\n defaultLocale: string,\n onError?: (err: string) => void\n|}\n\ntype FormatDateOptions = {|\n localeMatcher?: 'lookup' | 'best fit',\n timeZone?: string,\n hour12?: boolean,\n hourCycle?: 'h11' | 'h12' | 'h23' | 'h24',\n formatMatcher?: 'basic' | 'best fit',\n weekday?: 'long' | 'short' | 'narrow',\n era?: 'long' | 'short' | 'narrow',\n year?: 'numeric' | '2-digit',\n month?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow',\n day?: 'numeric' | '2-digit',\n hour?: 'numeric' | '2-digit',\n minute?: 'numeric' | '2-digit',\n second?: 'numeric' | '2-digit',\n timeZoneName?: 'long' | 'short'\n|}\n\ntype oneToTwenty =\n | 1\n | 2\n | 3\n | 4\n | 5\n | 6\n | 7\n | 8\n | 9\n | 10\n | 11\n | 12\n | 13\n | 14\n | 15\n | 16\n | 17\n | 18\n | 19\n | 20\n\ntype FormatNumberOptions = {|\n localeMatcher?: 'lookup' | 'best fit',\n style?: 'decimal' | 'currency' | 'percent',\n currenty?: string,\n currencyDisplay?: 'symbol' | 'code' | 'name',\n useGrouping?: boolean,\n minimumIntegerDigits?: oneToTwenty | 21,\n minimumFractionDigits?: 0 | oneToTwenty,\n maximumFractionDigits?: 0 | oneToTwenty,\n minimumSignificantDigits?: oneToTwenty | 21,\n maximumSignificantDigits?: oneToTwenty | 21\n|}\n\ntype FormatRelativeOptions = {|\n localeMatcher?: 'lookup' | 'best fit',\n numeric?: 'always' | 'auto',\n type?: 'long' | 'short' | 'narrow'\n|}\n\ntype Unit =\n | 'second'\n | 'minute'\n | 'hour'\n | 'day'\n | 'week'\n | 'month'\n | 'quarter'\n | 'year'\n\ntype FormatPluralOptions = {\n type?: 'cardinal' | 'ordinal'\n}\n\nexport type Primitive = string | boolean | null | void | number\n\ntype MessageValues = { [key: string]: Primitive }\ntype IntlFormatters = {|\n formatDate: (value: number | Date, opts?: FormatDateOptions) => string,\n formatTime: (value: number | Date, opts?: FormatDateOptions) => string,\n formatRelativeTime: (\n value: number,\n unit: Unit,\n opts?: FormatRelativeOptions\n ) => string,\n formatNumber: (value: number, opts?: FormatNumberOptions) => string,\n formatPlural: (value: number, opts?: FormatPluralOptions) => string,\n formatMessage: (\n descriptor: MessageDescriptor,\n values?: MessageValues\n ) => string,\n formatHTMLMessage: (\n descriptor: MessageDescriptor,\n values?: MessageValues\n ) => string\n|}\n\nexport type IntlShape = {|\n ...IntlConfig,\n ...IntlFormatters\n|}\n\n/** A function that receives an observation attachment and should return a URL\n * to retrieve the attachment */\nexport type GetMedia = (\n attachment: Attachment,\n options?: { width: number, height: number }\n) => { src: string, type: 'image' | 'video' | 'audio' } | void\n\nexport type GetMediaUrl = (\n attachmentId: string,\n size: 'thumbnail' | 'preview' | 'original'\n) => string\n\nexport type GetIconUrl = (iconId: string) => string\n\nexport type PresetWithFields = {\n ...$Exact<Preset>,\n fields: Field[]\n}\n\nexport type PresetWithAdditionalFields = {\n ...$Exact<PresetWithFields>,\n additionalFields: Field[]\n}\n\nexport type CameraOptions = {\n center: [number, number],\n zoom: number,\n bearing: number,\n pitch: number\n}\n\nexport type CommonViewContentProps = {\n /** Array of observations to render */\n observations: Array<Observation>,\n /** Called with id of observation clicked, optionally with image index */\n onClick: (id: string, imageIndex?: number) => void,\n getPreset: Observation => PresetWithAdditionalFields,\n /**\n * For a given attachment, return `src` and `type`\n */\n getMedia: GetMedia\n}\n"],"file":"types.js"}
\No newline at end of file