strata-react 1.0.32 → 1.0.35
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/README.md +11 -1
- package/UPGRADING.md +2 -0
- package/dist/components/conversation.d.ts +67 -0
- package/dist/components/cursor.d.ts +44 -0
- package/dist/components/dialog.d.ts +1 -1
- package/dist/components/folder-picker.d.ts +42 -0
- package/dist/components/lightbox.d.ts +34 -0
- package/dist/components/line-chart.d.ts +92 -3
- package/dist/components/markable-text.d.ts +56 -0
- package/dist/components/media-group.d.ts +25 -0
- package/dist/components/media-player.d.ts +80 -2
- package/dist/components/media.d.ts +6 -1
- package/dist/components/region-editor.d.ts +55 -0
- package/dist/components/sequence-timeline.d.ts +50 -0
- package/dist/components/transcript-view.d.ts +36 -0
- package/dist/components/tree.d.ts +41 -0
- package/dist/components/waveform.d.ts +66 -0
- package/dist/cursor-DDGBPiTJ.js +290 -0
- package/dist/cursor-DDGBPiTJ.js.map +1 -0
- package/dist/field-7Z4N5r5g.js +178 -0
- package/dist/field-7Z4N5r5g.js.map +1 -0
- package/dist/{geo-C0jcFp4q.js → format-B32-PVi2.js} +2 -119
- package/dist/format-B32-PVi2.js.map +1 -0
- package/dist/hls/index.d.ts +19 -0
- package/dist/hls.js +84 -0
- package/dist/hls.js.map +1 -0
- package/dist/index.d.ts +19 -2
- package/dist/index.js +9511 -6296
- package/dist/index.js.map +1 -1
- package/dist/lib/geo.d.ts +17 -1
- package/dist/lib/marks.d.ts +6 -0
- package/dist/lib/region.d.ts +46 -0
- package/dist/lib/rich-text.d.ts +44 -0
- package/dist/lib/sequence.d.ts +34 -0
- package/dist/lib/transcript.d.ts +28 -0
- package/dist/lib/waveform.d.ts +36 -0
- package/dist/map/fan.d.ts +15 -0
- package/dist/map/index.d.ts +3 -1
- package/dist/map/markers.d.ts +60 -0
- package/dist/map/route-map.d.ts +53 -1
- package/dist/map.js +626 -40
- package/dist/map.js.map +1 -1
- package/dist/panorama/gl.d.ts +16 -0
- package/dist/panorama/index.d.ts +2 -0
- package/dist/panorama/panorama-viewer.d.ts +56 -0
- package/dist/panorama/projection.d.ts +45 -0
- package/dist/panorama.js +657 -0
- package/dist/panorama.js.map +1 -0
- package/dist/{query-DgJMyXTT.js → query-BJcxJLhh.js} +3 -2
- package/dist/{query-DgJMyXTT.js.map → query-BJcxJLhh.js.map} +1 -1
- package/dist/{run-BqZGKhW9.js → run-DzyLrZlA.js} +23 -5
- package/dist/run-DzyLrZlA.js.map +1 -0
- package/dist/testing.js +2 -2
- package/dist/{theme-BgTOESmN.js → theme-CFNi6WUO.js} +5 -175
- package/dist/theme-CFNi6WUO.js.map +1 -0
- package/dist/value-controls-D6O9TsM6.js +356 -0
- package/dist/value-controls-D6O9TsM6.js.map +1 -0
- package/dist/visual-cli.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +19 -4
- package/dist/geo-C0jcFp4q.js.map +0 -1
- package/dist/run-BqZGKhW9.js.map +0 -1
- package/dist/theme-BgTOESmN.js.map +0 -1
package/dist/lib/geo.d.ts
CHANGED
|
@@ -30,7 +30,21 @@ export declare function ends(points: readonly LatLng[], loopWithin?: number): {
|
|
|
30
30
|
} | null;
|
|
31
31
|
/** The index of the point nearest `position`, for "where on the route is this?". */
|
|
32
32
|
export declare function nearest(points: readonly LatLng[], position: LatLng): number;
|
|
33
|
-
/**
|
|
33
|
+
/** The part of a route between two distances along it (metres, clamped, either order): the cut ends and every point between. Empty for no route. */
|
|
34
|
+
export declare function slice(points: readonly LatLng[], from: number, to: number, along?: readonly number[]): LatLng[];
|
|
35
|
+
/**
|
|
36
|
+
* The nearest point on a route to `position`, not only its vertices: where it lies, how far along the
|
|
37
|
+
* route that is, and how far `position` is from the route. The inverse of `pointAlong` (a cursor on a
|
|
38
|
+
* map is a distance on a chart). Each leg is flattened around its own latitude, which is exact enough
|
|
39
|
+
* for any leg a recording has; `index` is the leg's first point. Null for fewer than one point.
|
|
40
|
+
*/
|
|
41
|
+
export declare function snap(points: readonly LatLng[], position: LatLng, along?: readonly number[]): {
|
|
42
|
+
position: LatLng;
|
|
43
|
+
metres: number;
|
|
44
|
+
offset: number;
|
|
45
|
+
index: number;
|
|
46
|
+
} | null;
|
|
47
|
+
/** Route geometry helpers: `geo.distance`, `bearing`, `length`, `cumulative`, `bounds`, `pointAlong`, `snap` (its inverse), `slice`, `arrows`, `ends`, `nearest`. */
|
|
34
48
|
export declare const geo: {
|
|
35
49
|
distance: typeof distance;
|
|
36
50
|
bearing: typeof bearing;
|
|
@@ -38,6 +52,8 @@ export declare const geo: {
|
|
|
38
52
|
length: typeof length;
|
|
39
53
|
bounds: typeof bounds;
|
|
40
54
|
pointAlong: typeof pointAlong;
|
|
55
|
+
snap: typeof snap;
|
|
56
|
+
slice: typeof slice;
|
|
41
57
|
arrows: typeof arrows;
|
|
42
58
|
ends: typeof ends;
|
|
43
59
|
nearest: typeof nearest;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** The ids from `a` to `b` inclusive, in document order whichever way round they are given. Empty when either is not in `ids`. */
|
|
2
|
+
export declare function rangeBetween(ids: readonly string[], a: string | null, b: string | null): string[];
|
|
3
|
+
/** How many ids carry each mark key. Ids with no mark are not counted. */
|
|
4
|
+
export declare function countMarks(marks: Readonly<Record<string, string | undefined>>, ids?: readonly string[]): Record<string, number>;
|
|
5
|
+
/** The id `by` places from `from` in `ids`, held to the ends; the first (or last) when `from` is not set. */
|
|
6
|
+
export declare function stepId(ids: readonly string[], from: string | null, by: number): string | null;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** A rectangle in the picture's coordinates: top-left corner and size. */
|
|
2
|
+
export type Rect = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
w: number;
|
|
6
|
+
h: number;
|
|
7
|
+
};
|
|
8
|
+
/** Which edge or corner is held: compass points. */
|
|
9
|
+
export type Handle = "n" | "s" | "e" | "w" | "ne" | "nw" | "se" | "sw";
|
|
10
|
+
/** Limits on a rectangle. `aspect` is width over height; `min` is the smallest size; `bounds` is where it may be. */
|
|
11
|
+
export type RectLimits = {
|
|
12
|
+
bounds: Rect;
|
|
13
|
+
min?: {
|
|
14
|
+
w: number;
|
|
15
|
+
h: number;
|
|
16
|
+
};
|
|
17
|
+
aspect?: number;
|
|
18
|
+
};
|
|
19
|
+
export declare const HANDLES: readonly Handle[];
|
|
20
|
+
/** Moves a rectangle by (dx, dy), stopping at the bounds (it keeps its size). */
|
|
21
|
+
export declare function moveRect(r: Rect, dx: number, dy: number, bounds: Rect): Rect;
|
|
22
|
+
/** Puts a rectangle inside the bounds and at least `min` size, keeping its aspect if one is set (shrinking it to fit). */
|
|
23
|
+
export declare function fitRect(r: Rect, { bounds, min, aspect }: RectLimits): Rect;
|
|
24
|
+
/**
|
|
25
|
+
* Drags `handle` of `r` by (dx, dy). The opposite edge or corner stays where it is. Without an
|
|
26
|
+
* aspect each edge stops at the bounds and at `min` from the edge opposite; with one the rectangle
|
|
27
|
+
* keeps its shape: a corner follows the larger of the two movements, an edge changes its own
|
|
28
|
+
* dimension and the other grows or shrinks about the middle. The result is always inside the bounds.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resizeRect(r: Rect, handle: Handle, dx: number, dy: number, { bounds, min, aspect }: RectLimits): Rect;
|
|
31
|
+
/** A rectangle drawn by dragging from one corner point to another, ordered and fitted to the limits. */
|
|
32
|
+
export declare function drawRect(start: {
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
}, b: {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
}, limits: RectLimits): Rect;
|
|
39
|
+
/** How a move between two rectangles is eased. */
|
|
40
|
+
export type Easing = "linear" | "ease-in-out";
|
|
41
|
+
/** The eased share of the way at time `t` (0 to 1). */
|
|
42
|
+
export declare function ease(t: number, easing?: Easing): number;
|
|
43
|
+
/** The rectangle part-way from `a` to `b` at time `t` (0 to 1), eased. Corner and size move together. */
|
|
44
|
+
export declare function lerpRect(a: Rect, b: Rect, t: number, easing?: Easing): Rect;
|
|
45
|
+
/** True when two rectangles are the same to the unit's thousandth. */
|
|
46
|
+
export declare const sameRect: (a: Rect, b: Rect) => boolean;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** One id found in a text: `[start, end)` into the text and the id to open. */
|
|
2
|
+
export type EntityMatch = {
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
5
|
+
id: string;
|
|
6
|
+
};
|
|
7
|
+
/** A way to find entities in a run of text: a list of known ids, or a function that reports matches. */
|
|
8
|
+
export type EntityMatcher = readonly string[] | ((text: string) => readonly EntityMatch[]);
|
|
9
|
+
export type Inline = {
|
|
10
|
+
type: "text";
|
|
11
|
+
text: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: "bold";
|
|
14
|
+
children: Inline[];
|
|
15
|
+
} | {
|
|
16
|
+
type: "code";
|
|
17
|
+
text: string;
|
|
18
|
+
} | {
|
|
19
|
+
type: "link";
|
|
20
|
+
href: string;
|
|
21
|
+
children: Inline[];
|
|
22
|
+
} | {
|
|
23
|
+
type: "entity";
|
|
24
|
+
id: string;
|
|
25
|
+
text: string;
|
|
26
|
+
};
|
|
27
|
+
export type Block = {
|
|
28
|
+
type: "paragraph";
|
|
29
|
+
children: Inline[];
|
|
30
|
+
} | {
|
|
31
|
+
type: "list";
|
|
32
|
+
ordered: boolean;
|
|
33
|
+
items: Inline[][];
|
|
34
|
+
};
|
|
35
|
+
/** Finds ids in `text`, longest first, never inside a longer word. Overlaps go to the earlier, longer match. */
|
|
36
|
+
export declare function matchEntities(text: string, matcher: EntityMatcher | undefined): EntityMatch[];
|
|
37
|
+
/** A link is safe when its scheme is http, https or mailto. */
|
|
38
|
+
export declare function safeHref(href: string): string | null;
|
|
39
|
+
/** Parses one line's inline marks. Unclosed marks stay as the text they were typed as. */
|
|
40
|
+
export declare function parseInline(text: string, matcher?: EntityMatcher): Inline[];
|
|
41
|
+
/** Parses blocks: blank-line separated paragraphs, and runs of `- ` or `1. ` lines as lists. */
|
|
42
|
+
export declare function parseRichText(text: string, matcher?: EntityMatcher): Block[];
|
|
43
|
+
/** The plain words of a text with the marks removed: what a live region announces. */
|
|
44
|
+
export declare function plainText(text: string): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** A grid: a step in seconds (a beat every 0.5 s from 0) or the exact times of the beats. */
|
|
2
|
+
export type Grid = number | readonly number[];
|
|
3
|
+
/** The grid point nearest to `time`, or `time` itself when there is no grid. */
|
|
4
|
+
export declare function snapToGrid(time: number, grid: Grid | undefined): number;
|
|
5
|
+
/** The next grid point after `time` in a direction (`1` later, `-1` earlier); `fallback` is the step when there is no grid. A point `time` is already on is stepped past. */
|
|
6
|
+
export declare function stepOnGrid(time: number, dir: 1 | -1, grid: Grid | undefined, fallback: number): number;
|
|
7
|
+
/** Grid points inside `[from, to]`, for drawing on a ruler. At most `limit`, so a fine grid on a long axis stays cheap. */
|
|
8
|
+
export declare function gridPoints(grid: Grid | undefined, from: number, to: number, limit?: number): number[];
|
|
9
|
+
/** What limited a cut: which side, and the reason the app gave. */
|
|
10
|
+
export type CutLimit = {
|
|
11
|
+
side: "min" | "max";
|
|
12
|
+
at: number;
|
|
13
|
+
reason?: string;
|
|
14
|
+
};
|
|
15
|
+
/** Puts `time` inside the room, and says which end held it (with the app's reason) when one did. */
|
|
16
|
+
export declare function clampToRoom(time: number, room: {
|
|
17
|
+
min: number;
|
|
18
|
+
max: number;
|
|
19
|
+
minReason?: string;
|
|
20
|
+
maxReason?: string;
|
|
21
|
+
}): {
|
|
22
|
+
time: number;
|
|
23
|
+
limit: CutLimit | null;
|
|
24
|
+
};
|
|
25
|
+
/** Where a dragged cut lands: held by the room (saying which end, if the pointer is beyond it), otherwise snapped to the grid, and never to a grid point outside the room. */
|
|
26
|
+
export declare function settleCut(wanted: number, grid: Grid | undefined, room: {
|
|
27
|
+
min: number;
|
|
28
|
+
max: number;
|
|
29
|
+
minReason?: string;
|
|
30
|
+
maxReason?: string;
|
|
31
|
+
}): {
|
|
32
|
+
time: number;
|
|
33
|
+
limit: CutLimit | null;
|
|
34
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** One word, with when it starts and ends (seconds). */
|
|
2
|
+
export type TranscriptWord = {
|
|
3
|
+
text: string;
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
};
|
|
7
|
+
/** A phrase: timed words, who said it, and its other texts (a translation) by mode. */
|
|
8
|
+
export type TranscriptPhrase = {
|
|
9
|
+
id: string;
|
|
10
|
+
start: number;
|
|
11
|
+
end: number;
|
|
12
|
+
words: readonly TranscriptWord[];
|
|
13
|
+
speaker?: string;
|
|
14
|
+
/** Other texts for the phrase by mode name: `{ translated: "…" }`. */
|
|
15
|
+
alt?: Readonly<Record<string, string>>;
|
|
16
|
+
};
|
|
17
|
+
/** Phrases that belong together (a clip), with a heading. */
|
|
18
|
+
export type TranscriptGroup = {
|
|
19
|
+
id: string;
|
|
20
|
+
title: string; /** Defaults to the first phrase's start. */
|
|
21
|
+
start?: number; /** Defaults to the last phrase's end. */
|
|
22
|
+
end?: number;
|
|
23
|
+
phrases: readonly TranscriptPhrase[];
|
|
24
|
+
};
|
|
25
|
+
/** The phrase being heard at `time`, as an index into `phrases` (sorted by start), or -1. A phrase is heard from its `start` up to, not including, its `end`. */
|
|
26
|
+
export declare function phraseAt(phrases: readonly Pick<TranscriptPhrase, "start" | "end">[], time: number): number;
|
|
27
|
+
/** The word being heard within a phrase at `time`: the last word that has started, until the phrase ends. -1 before the first word. */
|
|
28
|
+
export declare function wordAt(phrase: Pick<TranscriptPhrase, "words" | "end">, time: number): number;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Peaks as an app has them: a magnitude per slice (0 to 1), or the lowest and highest sample per slice (-1 to 1). */
|
|
2
|
+
export type WaveformPeaks = ArrayLike<number> | {
|
|
3
|
+
min: ArrayLike<number>;
|
|
4
|
+
max: ArrayLike<number>;
|
|
5
|
+
};
|
|
6
|
+
/** Peaks as the lowest and highest sample of each slice. */
|
|
7
|
+
export type PeakPair = {
|
|
8
|
+
min: Float32Array;
|
|
9
|
+
max: Float32Array;
|
|
10
|
+
};
|
|
11
|
+
/** Makes the lowest and highest sample of each slice from either form. A magnitude `m` is the pair `-m` to `m`. */
|
|
12
|
+
export declare function toPeakPair(peaks: WaveformPeaks): PeakPair;
|
|
13
|
+
/** The lowest and highest of `pair` over the fraction `from` to `to` of its length (0 to 1). A slice narrower than one entry takes the entry it falls in, so zooming past the data never leaves a gap. */
|
|
14
|
+
export declare function peaksBetween(pair: PeakPair, from: number, to: number): [number, number];
|
|
15
|
+
/** Resamples peaks to `buckets` entries: each is the lowest and highest of the entries it covers. Any length in, any length out. */
|
|
16
|
+
export declare function resamplePeaks(peaks: WaveformPeaks, buckets: number): PeakPair;
|
|
17
|
+
/** What a decoded file looks like to this code: the shape of the browser's `AudioBuffer`. */
|
|
18
|
+
export type DecodedAudio = {
|
|
19
|
+
duration: number;
|
|
20
|
+
numberOfChannels: number;
|
|
21
|
+
length: number;
|
|
22
|
+
getChannelData: (channel: number) => ArrayLike<number>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Reduces decoded audio to `buckets` peaks over all channels, in chunks, calling `progress` with
|
|
26
|
+
* the buckets done and awaiting between chunks so the page stays responsive and `signal` can stop it.
|
|
27
|
+
*/
|
|
28
|
+
export declare function peaksFromAudio(audio: DecodedAudio, buckets: number, options?: {
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
progress?: (done: number, total: number) => void;
|
|
31
|
+
chunk?: number;
|
|
32
|
+
}): Promise<PeakPair>;
|
|
33
|
+
/** The time at the pointer, given the visible range and the width. */
|
|
34
|
+
export declare const timeAt: (px: number, width: number, from: number, to: number) => number;
|
|
35
|
+
/** Keeps a visible range of `span` seconds inside `0` to `duration`. */
|
|
36
|
+
export declare function clampView(from: number, span: number, duration: number): [number, number];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** A marker's true place in world pixels. */
|
|
2
|
+
export type FanInput = {
|
|
3
|
+
id: string;
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
};
|
|
7
|
+
/** Where it is drawn; `fanned` is true when that is not its true place (draw a leader line back). */
|
|
8
|
+
export type FanOutput = {
|
|
9
|
+
id: string;
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
fanned: boolean;
|
|
13
|
+
};
|
|
14
|
+
/** Move apart markers closer than `gap` pixels. Output is in input order. */
|
|
15
|
+
export declare function fanOut(items: readonly FanInput[], gap?: number): FanOutput[];
|
package/dist/map/index.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export { RouteMap, type MapPosition, type MapRoute, type RouteMapProps, type TileSource } from './route-map';
|
|
1
|
+
export { RouteMap, type MapPosition, type MapRoute, type MapView, type PickNearest, type RouteMapProps, type TileSource } from './route-map';
|
|
2
|
+
export { type MapMarker, type MarkerKeyWords } from './markers';
|
|
3
|
+
export { fanOut, type FanInput, type FanOutput } from './fan';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { default as L } from 'leaflet';
|
|
2
|
+
import { LatLng } from '../lib/geo';
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
/** The words the key uses for each marker state. */
|
|
5
|
+
export type MarkerKeyWords = {
|
|
6
|
+
marker?: string;
|
|
7
|
+
selected?: string;
|
|
8
|
+
highlighted?: string;
|
|
9
|
+
};
|
|
10
|
+
/** An item on the map: a place, or a stretch of a route (drawn heavier, the marker at its middle). */
|
|
11
|
+
export type MapMarker = {
|
|
12
|
+
/** Stable between renders. */
|
|
13
|
+
id: string;
|
|
14
|
+
/** A place, or a stretch of a route between two distances along it (metres). */
|
|
15
|
+
at: LatLng | {
|
|
16
|
+
routeId: string;
|
|
17
|
+
from: number;
|
|
18
|
+
to: number;
|
|
19
|
+
};
|
|
20
|
+
/** Its name: the button's accessible name and the card's default words. */
|
|
21
|
+
label: string;
|
|
22
|
+
selected?: boolean;
|
|
23
|
+
/** Marked by the app (a diamond): the newest draft's choice, a flagged item. */
|
|
24
|
+
highlighted?: boolean;
|
|
25
|
+
/** Any CSS colour, normally a role; overrides the state's. */
|
|
26
|
+
colour?: string;
|
|
27
|
+
};
|
|
28
|
+
/** A marker with where it really is and where it is drawn. */
|
|
29
|
+
export type Placed = {
|
|
30
|
+
marker: MapMarker;
|
|
31
|
+
at: LatLng;
|
|
32
|
+
shown: LatLng;
|
|
33
|
+
fanned: boolean;
|
|
34
|
+
};
|
|
35
|
+
/** The running distance at each point of a route, kept per route array so a long route is walked once. */
|
|
36
|
+
export declare function alongOf(points: readonly LatLng[]): number[];
|
|
37
|
+
/** Where a marker really is: its place, or the middle of its stretch. Null when its route is not on the map. */
|
|
38
|
+
export declare function markerPlace(m: MapMarker, routes: readonly {
|
|
39
|
+
id: string;
|
|
40
|
+
points: readonly LatLng[];
|
|
41
|
+
}[]): LatLng | null;
|
|
42
|
+
/** The markers near the view, with the overlapping ones fanned apart for this zoom. */
|
|
43
|
+
export declare function placeMarkers(map: L.Map, markers: readonly MapMarker[], routes: readonly {
|
|
44
|
+
id: string;
|
|
45
|
+
points: readonly LatLng[];
|
|
46
|
+
}[]): Placed[];
|
|
47
|
+
type LayerProps = {
|
|
48
|
+
map: L.Map;
|
|
49
|
+
placed: readonly Placed[];
|
|
50
|
+
onSelect?: (id: string) => void;
|
|
51
|
+
card?: (m: MapMarker) => React.ReactNode;
|
|
52
|
+
};
|
|
53
|
+
/** The pins for the markers near the view, as one roving group: one tab stop, arrows between them. */
|
|
54
|
+
export declare function MarkerLayer({ map, placed, onSelect, card }: LayerProps): React.JSX.Element;
|
|
55
|
+
/** The key to the marker states that are on the map, each with its shape and its words. */
|
|
56
|
+
export declare function MarkerKey({ markers, words }: {
|
|
57
|
+
markers: readonly MapMarker[];
|
|
58
|
+
words?: MarkerKeyWords;
|
|
59
|
+
}): React.JSX.Element | null;
|
|
60
|
+
export {};
|
package/dist/map/route-map.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LatLng } from '../lib/geo';
|
|
2
|
+
import { MapMarker, MarkerKeyWords } from './markers';
|
|
2
3
|
import * as React from "react";
|
|
3
4
|
/** A source of map tiles: a URL template the app's provider documents, and the attribution it requires. */
|
|
4
5
|
export type TileSource = {
|
|
@@ -40,6 +41,24 @@ export type MapPosition = {
|
|
|
40
41
|
/** Any CSS colour, normally a role. Overrides the route's. Default: the route's colour, else the theme's primary. */
|
|
41
42
|
colour?: string;
|
|
42
43
|
};
|
|
44
|
+
/** The view the map settled on. */
|
|
45
|
+
export type MapView = {
|
|
46
|
+
bounds: [LatLng, LatLng];
|
|
47
|
+
zoom: number;
|
|
48
|
+
center: LatLng;
|
|
49
|
+
};
|
|
50
|
+
/** The route nearest a picked place. */
|
|
51
|
+
export type PickNearest = {
|
|
52
|
+
routeId: string;
|
|
53
|
+
/** The leg of the route (its first point's index) the place is nearest. */
|
|
54
|
+
index: number;
|
|
55
|
+
/** How far the place is from the route, in metres. */
|
|
56
|
+
distanceM: number;
|
|
57
|
+
/** How far along the route the nearest point is, in metres. */
|
|
58
|
+
alongM: number;
|
|
59
|
+
/** The nearest point on the route. */
|
|
60
|
+
position: LatLng;
|
|
61
|
+
};
|
|
43
62
|
export type RouteMapProps = {
|
|
44
63
|
/** Names the map ("Route of Wednesday's run"). */
|
|
45
64
|
label: string;
|
|
@@ -61,6 +80,39 @@ export type RouteMapProps = {
|
|
|
61
80
|
follow?: boolean | "centre";
|
|
62
81
|
/** The zoom level, any number (12, 14.5): it may change every frame without redrawing routes. Unset, the map fits its routes and the person zooms. */
|
|
63
82
|
zoom?: number;
|
|
83
|
+
/** Items on the map: places, or stretches of a route. Keep the array stable between renders. */
|
|
84
|
+
markers?: readonly MapMarker[];
|
|
85
|
+
/** A marker was pressed (click, Enter or Space). */
|
|
86
|
+
onMarkerSelect?: (id: string) => void;
|
|
87
|
+
/** The words shown beside a marker on hover and focus (as `Tooltip`; not interactive). Default its label. */
|
|
88
|
+
renderMarkerCard?: (marker: MapMarker) => React.ReactNode;
|
|
89
|
+
/** The words of the marker key; `false` leaves the key out. */
|
|
90
|
+
markerKey?: MarkerKeyWords | false;
|
|
91
|
+
/** Join the nearest `CursorScope`: a pointer near a route puts its distance along it in every member, and another member's distance shows as a ring on the route. `{ routeId }` picks the route (default the first). */
|
|
92
|
+
cursor?: boolean | {
|
|
93
|
+
routeId?: string;
|
|
94
|
+
};
|
|
95
|
+
/** The view settled after the person moved or zoomed it: bounds, zoom and centre. Not called for moves the app caused through props. */
|
|
96
|
+
onViewChange?: (view: MapView) => void;
|
|
97
|
+
/** Milliseconds the view must be still before `onViewChange`. Default 250. */
|
|
98
|
+
settle?: number;
|
|
99
|
+
/** Also call `onViewChange` for moves the app caused through props (the first fit, `zoom`, `view`, `follow`). */
|
|
100
|
+
reportAppMoves?: boolean;
|
|
101
|
+
/** A view to show: centre and zoom, as a saved view or the app's own. The person can still move away from it; set it again to go back. Wins over fitting the routes. */
|
|
102
|
+
view?: {
|
|
103
|
+
center: LatLng;
|
|
104
|
+
zoom: number;
|
|
105
|
+
};
|
|
106
|
+
/** Choose a place on the map. While set, a click or Enter picks and route lines do not take clicks. */
|
|
107
|
+
picking?: boolean;
|
|
108
|
+
/** A place was chosen, with the nearest route to it when there is one. */
|
|
109
|
+
onPick?: (at: LatLng, info: {
|
|
110
|
+
nearest: PickNearest | null;
|
|
111
|
+
}) => void;
|
|
112
|
+
/** Escape was pressed while picking: the app turns `picking` off. */
|
|
113
|
+
onPickCancel?: () => void;
|
|
114
|
+
/** The banner for pick mode ("Click the map to set the point; Escape cancels"), shown top centre. */
|
|
115
|
+
pickBanner?: React.ReactNode;
|
|
64
116
|
/** The route drawn heavier, with the others lighter. */
|
|
65
117
|
selectedId?: string | null;
|
|
66
118
|
/** A route line was pressed. Give the app's own list of routes the same action for the keyboard. */
|
|
@@ -88,4 +140,4 @@ export type RouteMapProps = {
|
|
|
88
140
|
className?: string;
|
|
89
141
|
};
|
|
90
142
|
/** A map of one or more routes with a position that moves along them, on tiles the app supplies, themed from its roles. Leaflet, behind `strata-react/map`. */
|
|
91
|
-
export declare function RouteMap({ label, routes, tiles, position, positionLabel, positions, followId, follow, zoom, selectedId, onSelect, colourScale, colourScaleLabel, formatValue, summary, units, scrollZoom, topEnd, bottomStart, className, }: RouteMapProps): React.JSX.Element;
|
|
143
|
+
export declare function RouteMap({ label, routes, tiles, position, positionLabel, positions, followId, follow, zoom, markers, onMarkerSelect, renderMarkerCard, markerKey, cursor: cursorProp, onViewChange, settle, reportAppMoves, view, picking, onPick, onPickCancel, pickBanner, selectedId, onSelect, colourScale, colourScaleLabel, formatValue, summary, units, scrollZoom, topEnd, bottomStart, className, }: RouteMapProps): React.JSX.Element;
|