@fieldia/map 0.15.0 → 0.16.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/README.md +44 -11
- package/package.json +4 -4
- package/src/index.d.mts +2 -1
- package/src/index.d.ts +2 -1
- package/src/index.js +3 -1
- package/src/index.js.map +1 -1
- package/src/index.mjs +1 -0
- package/src/index.mjs.map +1 -1
- package/src/lib/answers.d.mts +17 -0
- package/src/lib/answers.d.ts +17 -0
- package/src/lib/answers.js +27 -0
- package/src/lib/answers.js.map +1 -0
- package/src/lib/answers.mjs +21 -0
- package/src/lib/answers.mjs.map +1 -0
- package/src/lib/card.d.mts +10 -2
- package/src/lib/card.d.ts +10 -2
- package/src/lib/card.js +13 -4
- package/src/lib/card.js.map +1 -1
- package/src/lib/card.mjs +13 -4
- package/src/lib/card.mjs.map +1 -1
- package/src/lib/form-map.d.mts +16 -0
- package/src/lib/form-map.d.ts +16 -0
- package/src/lib/form-map.js +525 -0
- package/src/lib/form-map.js.map +1 -0
- package/src/lib/form-map.mjs +522 -0
- package/src/lib/form-map.mjs.map +1 -0
- package/src/lib/labels.d.mts +13 -0
- package/src/lib/labels.d.ts +13 -0
- package/src/lib/labels.js +12 -1
- package/src/lib/labels.js.map +1 -1
- package/src/lib/labels.mjs +10 -0
- package/src/lib/labels.mjs.map +1 -1
- package/src/lib/list-view.js +48 -65
- package/src/lib/list-view.js.map +1 -1
- package/src/lib/list-view.mjs +42 -59
- package/src/lib/list-view.mjs.map +1 -1
- package/src/lib/map-core.js +22 -2
- package/src/lib/map-core.js.map +1 -1
- package/src/lib/map-core.mjs +22 -2
- package/src/lib/map-core.mjs.map +1 -1
- package/src/lib/marks.d.mts +34 -0
- package/src/lib/marks.d.ts +34 -0
- package/src/lib/marks.js +56 -0
- package/src/lib/marks.js.map +1 -0
- package/src/lib/marks.mjs +49 -0
- package/src/lib/marks.mjs.map +1 -0
- package/src/lib/pins.d.mts +2 -0
- package/src/lib/pins.d.ts +2 -0
- package/src/lib/pins.js +5 -1
- package/src/lib/pins.js.map +1 -1
- package/src/lib/pins.mjs +3 -1
- package/src/lib/pins.mjs.map +1 -1
- package/src/lib/providers.d.mts +27 -3
- package/src/lib/providers.d.ts +27 -3
- package/src/lib/providers.js +69 -67
- package/src/lib/providers.js.map +1 -1
- package/src/lib/providers.mjs +17 -15
- package/src/lib/providers.mjs.map +1 -1
- package/src/lib/route-line.d.mts +34 -0
- package/src/lib/route-line.d.ts +34 -0
- package/src/lib/route-line.js +53 -0
- package/src/lib/route-line.js.map +1 -0
- package/src/lib/route-line.mjs +47 -0
- package/src/lib/route-line.mjs.map +1 -0
- package/src/lib/routes.d.mts +28 -0
- package/src/lib/routes.d.ts +28 -0
- package/src/lib/routes.js +112 -0
- package/src/lib/routes.js.map +1 -0
- package/src/lib/routes.mjs +105 -0
- package/src/lib/routes.mjs.map +1 -0
- package/src/lib/settings.d.mts +5 -3
- package/src/lib/settings.d.ts +5 -3
- package/src/lib/styles.d.mts +9 -1
- package/src/lib/styles.d.ts +9 -1
- package/src/lib/styles.js +42 -3
- package/src/lib/styles.js.map +1 -1
- package/src/lib/styles.mjs +40 -2
- package/src/lib/styles.mjs.map +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# @fieldia/map
|
|
2
2
|
|
|
3
3
|
[Fieldia](https://fieldia.dev)'s maps: a **place** and an **area** as fields of a
|
|
4
|
-
form,
|
|
5
|
-
|
|
4
|
+
form, a **list's records on a map**, and a **map on a form** with its layers,
|
|
5
|
+
places that move and routes along the roads, on the map provider you choose.
|
|
6
|
+
Built on [Leaflet](https://leafletjs.com), loaded only when a map is shown.
|
|
6
7
|
|
|
7
8
|
```sh
|
|
8
9
|
npm install @fieldia/map
|
|
@@ -104,6 +105,37 @@ query.
|
|
|
104
105
|
A form with only a place or an area never carries the list map's code, its
|
|
105
106
|
styles or its words.
|
|
106
107
|
|
|
108
|
+
A card offers the list's own buttons too, each pressed for its record alone
|
|
109
|
+
("Assign", for this driver).
|
|
110
|
+
|
|
111
|
+
## A map on a form
|
|
112
|
+
|
|
113
|
+
A part of type `map` shows the record's places as layers: the record's own
|
|
114
|
+
place (`point`, or `latitude` and `longitude`), a place for each of its lines
|
|
115
|
+
(`lines`, read from the line's fields), a `route` between them, or the
|
|
116
|
+
reader's own place (`myLocation`). Give the viewer `maps: mapParts(settings)`.
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{ "type": "map", "id": "order-map", "label": "Where your order is", "layers": [
|
|
120
|
+
{ "id": "door", "label": "Your door", "point": "door", "pin": { "look": "icon", "icon": "home" } },
|
|
121
|
+
{ "id": "courier", "label": "Courier", "latitude": "courier_lat", "longitude": "courier_lng",
|
|
122
|
+
"pin": { "look": "photo", "image": "courier_photo", "label": "eta_text" },
|
|
123
|
+
"live": { "staleAfter": 60, "follow": true } },
|
|
124
|
+
{ "id": "way", "route": { "from": "courier", "to": "door", "progress": true,
|
|
125
|
+
"write": { "seconds": "eta_seconds", "metres": "distance_m", "line": "route_line" } } }
|
|
126
|
+
] }
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
A place that moves glides to each new place its fields are given (along its
|
|
130
|
+
route when on it), greys and says when it was last seen after `staleAfter`
|
|
131
|
+
seconds without news, and with `follow` is kept in view until the person moves
|
|
132
|
+
the map. A route runs `from` a place `to` another or `through` a layer of
|
|
133
|
+
lines, by `car`, `bike` or `foot`; with `progress` the part travelled fades and
|
|
134
|
+
the time and distance left are kept up to date; `write` names the fields its
|
|
135
|
+
seconds, metres and line go into. Routes come from the provider (`route`),
|
|
136
|
+
loaded the first time one is asked for, or from the app's own `route` in the
|
|
137
|
+
settings.
|
|
138
|
+
|
|
107
139
|
## Without a mouse
|
|
108
140
|
|
|
109
141
|
Tab reaches the map, which shows a cross at its centre: the arrow keys move the
|
|
@@ -120,13 +152,13 @@ zooms into a bubble, and Escape closes the card, back on its pin.
|
|
|
120
152
|
|
|
121
153
|
## Providers
|
|
122
154
|
|
|
123
|
-
| Provider | Road | Dark | Satellite | Address search |
|
|
124
|
-
| --- | --- | --- | --- | --- |
|
|
125
|
-
| `azureMaps({ key })` or `({ token, clientId })` | yes | yes | yes | yes, as people type |
|
|
126
|
-
| `googleMaps({ key, region, logo })` (Map Tiles API) | yes | no | yes |
|
|
127
|
-
| `mapbox({ token })` | yes | yes | yes | yes, as people type |
|
|
128
|
-
| `tiles({ url, credit })` | the app's own map images | | | the app's own |
|
|
129
|
-
| `openStreetMap()` | yes, **for demos only** | no | no | Photon, as people type, nearest first (or `{ search: 'nominatim' }`, on Enter) |
|
|
155
|
+
| Provider | Road | Dark | Satellite | Address search | Routes |
|
|
156
|
+
| --- | --- | --- | --- | --- | --- |
|
|
157
|
+
| `azureMaps({ key })` or `({ token, clientId })` | yes | yes | yes | yes, as people type | car, foot |
|
|
158
|
+
| `googleMaps({ key, region, logo })` (Map Tiles API) | yes | no | yes | Places API, as people type | car, bike, foot (Routes API) |
|
|
159
|
+
| `mapbox({ token })` | yes | yes | yes | yes, as people type | car (traffic), bike, foot |
|
|
160
|
+
| `tiles({ url, credit, route })` | the app's own map images | | | the app's own | the app's own |
|
|
161
|
+
| `openStreetMap()` | yes, **for demos only** | no | no | Photon, as people type, nearest first (or `{ search: 'nominatim' }`, on Enter) | OSRM's demo server, car only (or `osrmUrl`) |
|
|
130
162
|
|
|
131
163
|
Keys never live in Fieldia: pass one restricted to your sites, or a function
|
|
132
164
|
fetching a short-lived token from your server. Each provider's credits are shown
|
|
@@ -153,7 +185,8 @@ their settings (a place's address search, "My location", the field its address
|
|
|
153
185
|
goes into, the map's height; an area's shapes); pass the map widgets to the
|
|
154
186
|
designer and its editors too. A list page's panel has its Map: where each
|
|
155
187
|
record is, its pins, its card, and how the list opens. Give the screen editor
|
|
156
|
-
`listViews` (and `sampleCentre`, where its made-up records
|
|
157
|
-
the
|
|
188
|
+
`listViews` and `maps` (and `sampleCentre`, where its made-up records and
|
|
189
|
+
places are) and Try it shows the maps; with `maps` it offers a Map among its
|
|
190
|
+
blocks, whose panel sets its layers and the routes between them.
|
|
158
191
|
|
|
159
192
|
MIT. Leaflet is BSD-2-Clause; its stylesheet is included with its licence.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fieldia/map",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Fieldia's maps: a place and an area as fields, and a list's records on a map, on any map provider. Leaflet, loaded only where a map is shown.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://fieldia.dev",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"./package.json": "./package.json"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@fieldia/core": "0.
|
|
25
|
-
"@fieldia/viewer": "0.
|
|
26
|
-
"@fieldia/widgets": "0.
|
|
24
|
+
"@fieldia/core": "0.16.0",
|
|
25
|
+
"@fieldia/viewer": "0.16.0",
|
|
26
|
+
"@fieldia/widgets": "0.16.0",
|
|
27
27
|
"leaflet": "^1.9.4",
|
|
28
28
|
"tslib": "^2.8.1"
|
|
29
29
|
},
|
package/src/index.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { mapWidgets } from './lib/widgets.mjs';
|
|
2
2
|
export { mapListViews } from './lib/list-view.mjs';
|
|
3
|
+
export { mapParts } from './lib/form-map.mjs';
|
|
3
4
|
export { MAP_ICONS } from './lib/map-icons.mjs';
|
|
4
5
|
export type { MapRecord, PinDrawer } from './lib/pins.mjs';
|
|
5
6
|
export { mapKinds, type MapKind, type MapKindContext } from './lib/kinds.mjs';
|
|
6
7
|
export type { MapSettings } from './lib/settings.mjs';
|
|
7
|
-
export { azureMaps, googleMaps, mapbox, openStreetMap, tiles, type AddressSearch, type AzureMapsOptions, type BaseMap, type Credit, type GoogleMapsOptions, type MapboxOptions, type MapProvider, type MapView, type OpenStreetMapOptions, type PlaceFound, type ReverseSearch, type SearchRequest, type TileSpec, type TilesOptions, } from './lib/providers.mjs';
|
|
8
|
+
export { azureMaps, googleMaps, mapbox, openStreetMap, tiles, type AddressSearch, type AzureMapsOptions, type BaseMap, type Credit, type GoogleMapsOptions, type MapboxOptions, type MapProvider, type MapView, type OpenStreetMapOptions, type PlaceFound, type ReverseSearch, type RouteFinder, type RouteFound, type RouteRequest, type TravelMode, type SearchRequest, type TileSpec, type TilesOptions, } from './lib/providers.mjs';
|
|
8
9
|
export { readArea, readPoint, writeArea, writePoint, metresBetween, type Area, type AreaFeature, type LatLng, type PointGeometry, type Shape } from './lib/geo.mjs';
|
|
9
10
|
export { MAP_LABELS, type MapLabels } from './lib/labels.mjs';
|
package/src/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { mapWidgets } from './lib/widgets';
|
|
2
2
|
export { mapListViews } from './lib/list-view';
|
|
3
|
+
export { mapParts } from './lib/form-map';
|
|
3
4
|
export { MAP_ICONS } from './lib/map-icons';
|
|
4
5
|
export type { MapRecord, PinDrawer } from './lib/pins';
|
|
5
6
|
export { mapKinds, type MapKind, type MapKindContext } from './lib/kinds';
|
|
6
7
|
export type { MapSettings } from './lib/settings';
|
|
7
|
-
export { azureMaps, googleMaps, mapbox, openStreetMap, tiles, type AddressSearch, type AzureMapsOptions, type BaseMap, type Credit, type GoogleMapsOptions, type MapboxOptions, type MapProvider, type MapView, type OpenStreetMapOptions, type PlaceFound, type ReverseSearch, type SearchRequest, type TileSpec, type TilesOptions, } from './lib/providers';
|
|
8
|
+
export { azureMaps, googleMaps, mapbox, openStreetMap, tiles, type AddressSearch, type AzureMapsOptions, type BaseMap, type Credit, type GoogleMapsOptions, type MapboxOptions, type MapProvider, type MapView, type OpenStreetMapOptions, type PlaceFound, type ReverseSearch, type RouteFinder, type RouteFound, type RouteRequest, type TravelMode, type SearchRequest, type TileSpec, type TilesOptions, } from './lib/providers';
|
|
8
9
|
export { readArea, readPoint, writeArea, writePoint, metresBetween, type Area, type AreaFeature, type LatLng, type PointGeometry, type Shape } from './lib/geo';
|
|
9
10
|
export { MAP_LABELS, type MapLabels } from './lib/labels';
|
package/src/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAP_LABELS = exports.metresBetween = exports.writePoint = exports.writeArea = exports.readPoint = exports.readArea = exports.tiles = exports.openStreetMap = exports.mapbox = exports.googleMaps = exports.azureMaps = exports.mapKinds = exports.MAP_ICONS = exports.mapListViews = exports.mapWidgets = void 0;
|
|
3
|
+
exports.MAP_LABELS = exports.metresBetween = exports.writePoint = exports.writeArea = exports.readPoint = exports.readArea = exports.tiles = exports.openStreetMap = exports.mapbox = exports.googleMaps = exports.azureMaps = exports.mapKinds = exports.MAP_ICONS = exports.mapParts = exports.mapListViews = exports.mapWidgets = void 0;
|
|
4
4
|
var widgets_1 = require("./lib/widgets");
|
|
5
5
|
Object.defineProperty(exports, "mapWidgets", { enumerable: true, get: function () { return widgets_1.mapWidgets; } });
|
|
6
6
|
var list_view_1 = require("./lib/list-view");
|
|
7
7
|
Object.defineProperty(exports, "mapListViews", { enumerable: true, get: function () { return list_view_1.mapListViews; } });
|
|
8
|
+
var form_map_1 = require("./lib/form-map");
|
|
9
|
+
Object.defineProperty(exports, "mapParts", { enumerable: true, get: function () { return form_map_1.mapParts; } });
|
|
8
10
|
var map_icons_1 = require("./lib/map-icons");
|
|
9
11
|
Object.defineProperty(exports, "MAP_ICONS", { enumerable: true, get: function () { return map_icons_1.MAP_ICONS; } });
|
|
10
12
|
var kinds_1 = require("./lib/kinds");
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/map/src/index.ts"],"names":[],"mappings":";;;AAAA,yCAA2C;AAAlC,qGAAA,UAAU,OAAA;AACnB,6CAA+C;AAAtC,yGAAA,YAAY,OAAA;AACrB,6CAA4C;AAAnC,sGAAA,SAAS,OAAA;AAElB,qCAA0E;AAAjE,iGAAA,QAAQ,OAAA;AAEjB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/map/src/index.ts"],"names":[],"mappings":";;;AAAA,yCAA2C;AAAlC,qGAAA,UAAU,OAAA;AACnB,6CAA+C;AAAtC,yGAAA,YAAY,OAAA;AACrB,2CAA0C;AAAjC,oGAAA,QAAQ,OAAA;AACjB,6CAA4C;AAAnC,sGAAA,SAAS,OAAA;AAElB,qCAA0E;AAAjE,iGAAA,QAAQ,OAAA;AAEjB,6CAwByB;AAvBvB,sGAAA,SAAS,OAAA;AACT,uGAAA,UAAU,OAAA;AACV,mGAAA,MAAM,OAAA;AACN,0GAAA,aAAa,OAAA;AACb,kGAAA,KAAK,OAAA;AAoBP,iCAAgK;AAAvJ,+FAAA,QAAQ,OAAA;AAAE,gGAAA,SAAS,OAAA;AAAE,gGAAA,SAAS,OAAA;AAAE,iGAAA,UAAU,OAAA;AAAE,oGAAA,aAAa,OAAA;AAClE,uCAA0D;AAAjD,oGAAA,UAAU,OAAA"}
|
package/src/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { mapWidgets } from './lib/widgets.mjs';
|
|
2
2
|
export { mapListViews } from './lib/list-view.mjs';
|
|
3
|
+
export { mapParts } from './lib/form-map.mjs';
|
|
3
4
|
export { MAP_ICONS } from './lib/map-icons.mjs';
|
|
4
5
|
export { mapKinds } from './lib/kinds.mjs';
|
|
5
6
|
export { azureMaps, googleMaps, mapbox, openStreetMap, tiles, } from './lib/providers.mjs';
|
package/src/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../libs/map/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAqC,MAAM,aAAa,CAAC;AAE1E,OAAO,EACL,SAAS,EACT,UAAU,EACV,MAAM,EACN,aAAa,EACb,KAAK,
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../libs/map/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAqC,MAAM,aAAa,CAAC;AAE1E,OAAO,EACL,SAAS,EACT,UAAU,EACV,MAAM,EACN,aAAa,EACb,KAAK,GAmBN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAA4E,MAAM,WAAW,CAAC;AAChK,OAAO,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asking a provider over the network: its answer as JSON, or its refusal in
|
|
3
|
+
* its own words, and a path read through an answer whose shape may vary.
|
|
4
|
+
* Kept apart, as the providers and their routes (loaded later) both use it.
|
|
5
|
+
*/
|
|
6
|
+
export type Fetch = typeof globalThis.fetch;
|
|
7
|
+
/**
|
|
8
|
+
* A provider's answer, or its refusal in its own words: "Places API (New) has
|
|
9
|
+
* not been used in project … or it is disabled" says what to do; a bare 403
|
|
10
|
+
* does not.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getJson(fetchWith: Fetch, url: string, init?: RequestInit): Promise<unknown>;
|
|
13
|
+
export type Json = {
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
};
|
|
16
|
+
export declare const isObject: (value: unknown) => value is Json;
|
|
17
|
+
export declare const pathOf: (value: unknown, ...path: string[]) => unknown;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asking a provider over the network: its answer as JSON, or its refusal in
|
|
3
|
+
* its own words, and a path read through an answer whose shape may vary.
|
|
4
|
+
* Kept apart, as the providers and their routes (loaded later) both use it.
|
|
5
|
+
*/
|
|
6
|
+
export type Fetch = typeof globalThis.fetch;
|
|
7
|
+
/**
|
|
8
|
+
* A provider's answer, or its refusal in its own words: "Places API (New) has
|
|
9
|
+
* not been used in project … or it is disabled" says what to do; a bare 403
|
|
10
|
+
* does not.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getJson(fetchWith: Fetch, url: string, init?: RequestInit): Promise<unknown>;
|
|
13
|
+
export type Json = {
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
};
|
|
16
|
+
export declare const isObject: (value: unknown) => value is Json;
|
|
17
|
+
export declare const pathOf: (value: unknown, ...path: string[]) => unknown;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Asking a provider over the network: its answer as JSON, or its refusal in
|
|
4
|
+
* its own words, and a path read through an answer whose shape may vary.
|
|
5
|
+
* Kept apart, as the providers and their routes (loaded later) both use it.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.pathOf = exports.isObject = void 0;
|
|
9
|
+
exports.getJson = getJson;
|
|
10
|
+
/**
|
|
11
|
+
* A provider's answer, or its refusal in its own words: "Places API (New) has
|
|
12
|
+
* not been used in project … or it is disabled" says what to do; a bare 403
|
|
13
|
+
* does not.
|
|
14
|
+
*/
|
|
15
|
+
async function getJson(fetchWith, url, init) {
|
|
16
|
+
const response = await fetchWith(url, init);
|
|
17
|
+
if (response.ok)
|
|
18
|
+
return response.json();
|
|
19
|
+
const body = await response.json().catch(() => null);
|
|
20
|
+
const said = (0, exports.pathOf)(body, 'error', 'message') ?? (0, exports.pathOf)(body, 'error_message') ?? (0, exports.pathOf)(body, 'message');
|
|
21
|
+
throw new Error(`${url.split('?')[0]} answered ${response.status}${typeof said === 'string' && said ? `: ${said}` : ''}`);
|
|
22
|
+
}
|
|
23
|
+
const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
24
|
+
exports.isObject = isObject;
|
|
25
|
+
const pathOf = (value, ...path) => path.reduce((at, key) => ((0, exports.isObject)(at) ? at[key] : undefined), value);
|
|
26
|
+
exports.pathOf = pathOf;
|
|
27
|
+
//# sourceMappingURL=answers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answers.js","sourceRoot":"","sources":["../../../../../libs/map/src/lib/answers.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AASH,0BAMC;AAXD;;;;GAIG;AACI,KAAK,UAAU,OAAO,CAAC,SAAgB,EAAE,GAAW,EAAE,IAAkB;IAC7E,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC5C,IAAI,QAAQ,CAAC,EAAE;QAAE,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IACxC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACrD,MAAM,IAAI,GAAG,IAAA,cAAM,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,IAAI,IAAA,cAAM,EAAC,IAAI,EAAE,eAAe,CAAC,IAAI,IAAA,cAAM,EAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC1G,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,QAAQ,CAAC,MAAM,GAAG,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC5H,CAAC;AAGM,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAiB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAAnH,QAAA,QAAQ,YAA2G;AACzH,MAAM,MAAM,GAAG,CAAC,KAAc,EAAE,GAAG,IAAc,EAAW,EAAE,CAAC,IAAI,CAAC,MAAM,CAAU,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,IAAA,gBAAQ,EAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,CAAC;AAAxI,QAAA,MAAM,UAAkI"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asking a provider over the network: its answer as JSON, or its refusal in
|
|
3
|
+
* its own words, and a path read through an answer whose shape may vary.
|
|
4
|
+
* Kept apart, as the providers and their routes (loaded later) both use it.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A provider's answer, or its refusal in its own words: "Places API (New) has
|
|
8
|
+
* not been used in project … or it is disabled" says what to do; a bare 403
|
|
9
|
+
* does not.
|
|
10
|
+
*/
|
|
11
|
+
export async function getJson(fetchWith, url, init) {
|
|
12
|
+
const response = await fetchWith(url, init);
|
|
13
|
+
if (response.ok)
|
|
14
|
+
return response.json();
|
|
15
|
+
const body = await response.json().catch(() => null);
|
|
16
|
+
const said = pathOf(body, 'error', 'message') ?? pathOf(body, 'error_message') ?? pathOf(body, 'message');
|
|
17
|
+
throw new Error(`${url.split('?')[0]} answered ${response.status}${typeof said === 'string' && said ? `: ${said}` : ''}`);
|
|
18
|
+
}
|
|
19
|
+
export const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
20
|
+
export const pathOf = (value, ...path) => path.reduce((at, key) => (isObject(at) ? at[key] : undefined), value);
|
|
21
|
+
//# sourceMappingURL=answers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answers.mjs","sourceRoot":"","sources":["../../../../../libs/map/src/lib/answers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,SAAgB,EAAE,GAAW,EAAE,IAAkB;IAC7E,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC5C,IAAI,QAAQ,CAAC,EAAE;QAAE,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IACxC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACrD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC1G,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,QAAQ,CAAC,MAAM,GAAG,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC5H,CAAC;AAGD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAiB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAChI,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAE,GAAG,IAAc,EAAW,EAAE,CAAC,IAAI,CAAC,MAAM,CAAU,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,CAAC"}
|
package/src/lib/card.d.mts
CHANGED
|
@@ -19,9 +19,17 @@ export interface CardOptions {
|
|
|
19
19
|
/** The fields the card shows, in order. */
|
|
20
20
|
fields: string[];
|
|
21
21
|
record: MapRecord;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
/** A box to choose the record, as its row's is: a list's map has one, a form's does not. */
|
|
23
|
+
chosen?: boolean;
|
|
24
|
+
choose?(on: boolean): void;
|
|
24
25
|
open?: () => void;
|
|
26
|
+
/** The list's buttons, each pressed for this record alone. */
|
|
27
|
+
actions?: {
|
|
28
|
+
id: string;
|
|
29
|
+
label: string;
|
|
30
|
+
style?: string;
|
|
31
|
+
}[];
|
|
32
|
+
act?(id: string, button: HTMLElement): void;
|
|
25
33
|
close(): void;
|
|
26
34
|
}
|
|
27
35
|
export interface Card {
|
package/src/lib/card.d.ts
CHANGED
|
@@ -19,9 +19,17 @@ export interface CardOptions {
|
|
|
19
19
|
/** The fields the card shows, in order. */
|
|
20
20
|
fields: string[];
|
|
21
21
|
record: MapRecord;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
/** A box to choose the record, as its row's is: a list's map has one, a form's does not. */
|
|
23
|
+
chosen?: boolean;
|
|
24
|
+
choose?(on: boolean): void;
|
|
24
25
|
open?: () => void;
|
|
26
|
+
/** The list's buttons, each pressed for this record alone. */
|
|
27
|
+
actions?: {
|
|
28
|
+
id: string;
|
|
29
|
+
label: string;
|
|
30
|
+
style?: string;
|
|
31
|
+
}[];
|
|
32
|
+
act?(id: string, button: HTMLElement): void;
|
|
25
33
|
close(): void;
|
|
26
34
|
}
|
|
27
35
|
export interface Card {
|
package/src/lib/card.js
CHANGED
|
@@ -44,10 +44,18 @@ function drawCard(options) {
|
|
|
44
44
|
body.append(make(doc, 'dl', 'fd-map-card-fields', ...lines.map(([label, value]) => make(doc, 'div', '', make(doc, 'dt', '', label), make(doc, 'dd', '', value)))));
|
|
45
45
|
const box = make(doc, 'input', 'fd-map-card-check');
|
|
46
46
|
box.type = 'checkbox';
|
|
47
|
-
box.checked = options.chosen;
|
|
48
|
-
box.addEventListener('change', () => options.choose(box.checked));
|
|
49
|
-
const actions = make(doc, 'div', 'fd-map-card-actions', make(doc, 'label', 'fd-map-card-choose', box, labels.choose));
|
|
47
|
+
box.checked = !!options.chosen;
|
|
48
|
+
box.addEventListener('change', () => options.choose?.(box.checked));
|
|
49
|
+
const actions = make(doc, 'div', 'fd-map-card-actions', ...(options.choose ? [make(doc, 'label', 'fd-map-card-choose', box, labels.choose)] : []));
|
|
50
50
|
let first = close;
|
|
51
|
+
for (const action of options.actions ?? []) {
|
|
52
|
+
const button = make(doc, 'button', `fd-button fd-button-${action.style ?? 'secondary'} fd-map-card-act`, action.label);
|
|
53
|
+
button.type = 'button';
|
|
54
|
+
button.dataset['action'] = action.id;
|
|
55
|
+
button.addEventListener('click', () => options.act?.(action.id, button));
|
|
56
|
+
actions.append(button);
|
|
57
|
+
first = button;
|
|
58
|
+
}
|
|
51
59
|
if (options.open && options.card.open !== false) {
|
|
52
60
|
const open = make(doc, 'button', 'fd-button fd-button-primary fd-map-card-open', labels.openRecord);
|
|
53
61
|
open.type = 'button';
|
|
@@ -55,7 +63,8 @@ function drawCard(options) {
|
|
|
55
63
|
actions.append(open);
|
|
56
64
|
first = open;
|
|
57
65
|
}
|
|
58
|
-
|
|
66
|
+
if (actions.childElementCount)
|
|
67
|
+
body.append(actions);
|
|
59
68
|
element.append(body);
|
|
60
69
|
return {
|
|
61
70
|
element,
|
package/src/lib/card.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.js","sourceRoot":"","sources":["../../../../../libs/map/src/lib/card.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"card.js","sourceRoot":"","sources":["../../../../../libs/map/src/lib/card.ts"],"names":[],"mappings":";;AAwDA,4BAsDC;AAGD,8BA4BC;AA5ID,qCAAoE;AACpE,iCAA4D;AAsC5D,SAAS,IAAI,CAAwC,GAAa,EAAE,GAAM,EAAE,SAAiB,EAAE,GAAG,QAA2B;IAC3H,MAAM,OAAO,GAAG,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC;IAC5B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,WAAW,CAAC,GAAa,EAAE,MAAqB,EAAE,KAAiB;IAC1E,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,mBAAmB,EAAE,GAAG,CAAC,CAAC;IAC7D,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC;IACvB,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC;IAChC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACxC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,QAAQ,CAAC,OAAoB;IAC3C,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAChE,MAAM,KAAK,GAAG,IAAA,YAAK,EAAC,IAAI,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACrF,MAAM,OAAO,GAAG,IAAI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AAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,kBAAkB,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,kBAAkB,EAAE,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,mBAAmB,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACrM,OAAO;QACL,OAAO;QACP,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS;QAC1B,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,EAAE;KAClE,CAAC;AACJ,CAAC"}
|
package/src/lib/card.mjs
CHANGED
|
@@ -40,10 +40,18 @@ export function drawCard(options) {
|
|
|
40
40
|
body.append(make(doc, 'dl', 'fd-map-card-fields', ...lines.map(([label, value]) => make(doc, 'div', '', make(doc, 'dt', '', label), make(doc, 'dd', '', value)))));
|
|
41
41
|
const box = make(doc, 'input', 'fd-map-card-check');
|
|
42
42
|
box.type = 'checkbox';
|
|
43
|
-
box.checked = options.chosen;
|
|
44
|
-
box.addEventListener('change', () => options.choose(box.checked));
|
|
45
|
-
const actions = make(doc, 'div', 'fd-map-card-actions', make(doc, 'label', 'fd-map-card-choose', box, labels.choose));
|
|
43
|
+
box.checked = !!options.chosen;
|
|
44
|
+
box.addEventListener('change', () => options.choose?.(box.checked));
|
|
45
|
+
const actions = make(doc, 'div', 'fd-map-card-actions', ...(options.choose ? [make(doc, 'label', 'fd-map-card-choose', box, labels.choose)] : []));
|
|
46
46
|
let first = close;
|
|
47
|
+
for (const action of options.actions ?? []) {
|
|
48
|
+
const button = make(doc, 'button', `fd-button fd-button-${action.style ?? 'secondary'} fd-map-card-act`, action.label);
|
|
49
|
+
button.type = 'button';
|
|
50
|
+
button.dataset['action'] = action.id;
|
|
51
|
+
button.addEventListener('click', () => options.act?.(action.id, button));
|
|
52
|
+
actions.append(button);
|
|
53
|
+
first = button;
|
|
54
|
+
}
|
|
47
55
|
if (options.open && options.card.open !== false) {
|
|
48
56
|
const open = make(doc, 'button', 'fd-button fd-button-primary fd-map-card-open', labels.openRecord);
|
|
49
57
|
open.type = 'button';
|
|
@@ -51,7 +59,8 @@ export function drawCard(options) {
|
|
|
51
59
|
actions.append(open);
|
|
52
60
|
first = open;
|
|
53
61
|
}
|
|
54
|
-
|
|
62
|
+
if (actions.childElementCount)
|
|
63
|
+
body.append(actions);
|
|
55
64
|
element.append(body);
|
|
56
65
|
return {
|
|
57
66
|
element,
|
package/src/lib/card.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.mjs","sourceRoot":"","sources":["../../../../../libs/map/src/lib/card.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAsC,MAAM,UAAU,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAkB,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"card.mjs","sourceRoot":"","sources":["../../../../../libs/map/src/lib/card.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAsC,MAAM,UAAU,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAkB,MAAM,QAAQ,CAAC;AAsC5D,SAAS,IAAI,CAAwC,GAAa,EAAE,GAAM,EAAE,SAAiB,EAAE,GAAG,QAA2B;IAC3H,MAAM,OAAO,GAAG,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC;IAC5B,OAAO,OAAO,CAAC;AACjB,CAAC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C,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,EAAE;KAClE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MapPartFactory } from '@fieldia/viewer';
|
|
2
|
+
import type { MapSettings } from './settings.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* A map on a form (`type: "map"`), for the viewer's `maps`: the record's
|
|
5
|
+
* places as layers. A layer is the record's own place (a kitchen, a door, a
|
|
6
|
+
* courier), a place for each of its lines (a round's stops), a route along
|
|
7
|
+
* the roads between them, or the reader's own place. Pins are drawn as a
|
|
8
|
+
* list's map draws them. A place that moves glides to each new position —
|
|
9
|
+
* along its route when it is on one — says when it was last seen once its
|
|
10
|
+
* news is old, and is followed until the person moves the map. A route's
|
|
11
|
+
* part already travelled fades, and its time and distance left are written
|
|
12
|
+
* into the record's fields the page names.
|
|
13
|
+
*
|
|
14
|
+
* mountViewer(host, { page, maps: mapParts({ provider }) })
|
|
15
|
+
*/
|
|
16
|
+
export declare function mapParts(settings: MapSettings): MapPartFactory;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MapPartFactory } from '@fieldia/viewer';
|
|
2
|
+
import type { MapSettings } from './settings';
|
|
3
|
+
/**
|
|
4
|
+
* A map on a form (`type: "map"`), for the viewer's `maps`: the record's
|
|
5
|
+
* places as layers. A layer is the record's own place (a kitchen, a door, a
|
|
6
|
+
* courier), a place for each of its lines (a round's stops), a route along
|
|
7
|
+
* the roads between them, or the reader's own place. Pins are drawn as a
|
|
8
|
+
* list's map draws them. A place that moves glides to each new position —
|
|
9
|
+
* along its route when it is on one — says when it was last seen once its
|
|
10
|
+
* news is old, and is followed until the person moves the map. A route's
|
|
11
|
+
* part already travelled fades, and its time and distance left are written
|
|
12
|
+
* into the record's fields the page names.
|
|
13
|
+
*
|
|
14
|
+
* mountViewer(host, { page, maps: mapParts({ provider }) })
|
|
15
|
+
*/
|
|
16
|
+
export declare function mapParts(settings: MapSettings): MapPartFactory;
|