jenosize-ui 0.2.2 → 0.3.1
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 +183 -63
- package/THIRD-PARTY-NOTICES.md +95 -0
- package/dist/GradientPicker-Bv3V3vL_.d.ts +144 -0
- package/dist/{PaymentInput-Dn5WVQVy.d.ts → PaymentInput-s7_s3UDi.d.ts} +1 -1
- package/dist/{Select-Dt5ARIH8.d.ts → Select-r233iMaU.d.ts} +15 -1
- package/dist/{TagInput-BaBeve6L.d.ts → TagInput-w_l9Fp5i.d.ts} +1 -1
- package/dist/area-chart.d.ts +2 -2
- package/dist/area-chart.js +8 -6
- package/dist/at-least-one-BZ2dsck-.d.ts +18 -0
- package/dist/avatar.d.ts +1 -1
- package/dist/avatar.js +12 -10
- package/dist/badge.d.ts +1 -1
- package/dist/badge.js +7 -6
- package/dist/bar-chart.d.ts +2 -2
- package/dist/bar-chart.js +8 -6
- package/dist/breadcrumb.d.ts +1 -1
- package/dist/breadcrumb.js +5 -4
- package/dist/button.d.ts +1 -1
- package/dist/button.js +12 -10
- package/dist/calendar.d.ts +1 -1
- package/dist/calendar.js +16 -14
- package/dist/callout.d.ts +4 -2
- package/dist/callout.js +13 -11
- package/dist/card.d.ts +59 -3
- package/dist/card.js +4 -3
- package/dist/carousel.d.ts +169 -0
- package/dist/carousel.js +10 -0
- package/dist/catalog.json +11976 -0
- package/dist/checkbox.js +9 -7
- package/dist/{chunk-AIARANKE.js → chunk-2EUVBRKG.js} +4 -4
- package/dist/{chunk-5ZEUTSCV.js → chunk-2RRPWOKT.js} +6 -6
- package/dist/{chunk-DD5KJVFV.js → chunk-3JFSKCVU.js} +19 -19
- package/dist/{chunk-OACWA4TC.js → chunk-3ZZZPT5G.js} +6 -6
- package/dist/{chunk-LQURV7HQ.js → chunk-47EOHGXM.js} +4 -4
- package/dist/{chunk-CGHYXWTT.js → chunk-4KRCT3Q2.js} +4 -4
- package/dist/chunk-4P3JA653.js +1129 -0
- package/dist/{chunk-FWRHBMWT.js → chunk-4Y32RIC7.js} +5 -19
- package/dist/{chunk-BBKE4W3B.js → chunk-5Z26DU23.js} +7 -7
- package/dist/{chunk-7QXOGAN6.js → chunk-6CJYVYVN.js} +87 -538
- package/dist/{chunk-3HOHLQVP.js → chunk-6FGLABYH.js} +3 -3
- package/dist/{chunk-GQRSABRN.js → chunk-6Q4VVBFO.js} +4 -4
- package/dist/{chunk-MCQG4H6T.js → chunk-6T3QAO5K.js} +12 -4
- package/dist/chunk-7JOW3LEH.js +4852 -0
- package/dist/{chunk-AFYXSZGW.js → chunk-7LSUUEAF.js} +7 -5
- package/dist/{chunk-7VLYQR4D.js → chunk-7OFGPDYJ.js} +3 -3
- package/dist/{chunk-7GUPNTAH.js → chunk-7RD5RTHU.js} +7 -7
- package/dist/{chunk-X2VMIBK5.js → chunk-A36W77MQ.js} +4 -4
- package/dist/chunk-AZFHRLYF.js +67 -0
- package/dist/{chunk-CFFWYXDW.js → chunk-B6LYO33Y.js} +5 -5
- package/dist/{chunk-P6CON2R2.js → chunk-BH32X25C.js} +3 -3
- package/dist/{chunk-KHGW72BM.js → chunk-CH2XMCWX.js} +3 -3
- package/dist/{chunk-FNQJJO63.js → chunk-D46OKHTH.js} +4 -4
- package/dist/{chunk-LE44X5GS.js → chunk-D4YGYNNY.js} +9 -9
- package/dist/{chunk-T5574MXM.js → chunk-D7WD4SUC.js} +8 -8
- package/dist/{chunk-33TOK7ES.js → chunk-DCKVNHV5.js} +5 -5
- package/dist/chunk-EBZNUQ6E.js +525 -0
- package/dist/{chunk-22M75A3N.js → chunk-ED5UCYAV.js} +14 -11
- package/dist/{chunk-IQNVSQRK.js → chunk-EDVYLO2N.js} +5 -5
- package/dist/{chunk-N3RVMBPX.js → chunk-EJKQGUUM.js} +4 -4
- package/dist/{chunk-POQTE7JI.js → chunk-EKQLIUV5.js} +7 -7
- package/dist/{chunk-ULGCGKOE.js → chunk-EKV3CVTY.js} +4 -4
- package/dist/{chunk-LCG34A5T.js → chunk-EVINS473.js} +5 -3
- package/dist/{chunk-ZZSNTCCL.js → chunk-G7B2QUQP.js} +4 -4
- package/dist/{chunk-SB3DG572.js → chunk-GHRZC5LS.js} +6 -6
- package/dist/{chunk-5YWH2ANQ.js → chunk-GIC6T647.js} +11 -10
- package/dist/{chunk-7ZM7SNCZ.js → chunk-GPHGPY6T.js} +3 -3
- package/dist/chunk-GV2KTRRP.js +325 -0
- package/dist/{chunk-4RBIWI2Q.js → chunk-GYL4KOPT.js} +3 -3
- package/dist/{chunk-5KSD4WKN.js → chunk-HB6UA6EF.js} +5 -5
- package/dist/{chunk-CGZXQ7PA.js → chunk-HNNNJP3A.js} +3 -3
- package/dist/chunk-HTWGTTSF.js +1011 -0
- package/dist/chunk-IH2F5UNQ.js +109 -0
- package/dist/{chunk-QNIKRB62.js → chunk-INYUL4DX.js} +4 -4
- package/dist/{chunk-SKRR3ZMP.js → chunk-IUB5TSSH.js} +3 -3
- package/dist/chunk-JGGSRKHW.js +344 -0
- package/dist/{chunk-ZR6HNKSN.js → chunk-JHHJNIW2.js} +3 -3
- package/dist/chunk-KBI442IB.js +113 -0
- package/dist/chunk-KBQJIVUB.js +33 -0
- package/dist/{chunk-3QXLIZIX.js → chunk-KNGJ3CSB.js} +3 -3
- package/dist/chunk-KNKR5TUM.js +183 -0
- package/dist/{chunk-KZP6B6B3.js → chunk-KTWTYK5U.js} +16 -5
- package/dist/{chunk-5XPMY2LF.js → chunk-LKUAVDWP.js} +5 -5
- package/dist/{chunk-YHBI52P2.js → chunk-LPWSP523.js} +3 -3
- package/dist/{chunk-GLKFFA7N.js → chunk-LY7IJOUF.js} +5 -5
- package/dist/{chunk-R4Z7BINC.js → chunk-LYWQD5KL.js} +8 -8
- package/dist/{chunk-LLPWQDF7.js → chunk-MTOTPAYZ.js} +3 -3
- package/dist/{chunk-AZ7DKRBY.js → chunk-MVF7FA4D.js} +5 -5
- package/dist/{chunk-AIGYMTCU.js → chunk-MVUNB43J.js} +3 -3
- package/dist/{chunk-T4ZFZTY6.js → chunk-N7DLNDER.js} +4 -4
- package/dist/{chunk-E2YZ7IMT.js → chunk-NDRQETOQ.js} +15 -11
- package/dist/{chunk-ZD3MOLIB.js → chunk-O7CPRU67.js} +4 -4
- package/dist/{chunk-OLLD2BZN.js → chunk-OEYKTHG7.js} +3 -3
- package/dist/{chunk-TX57TNJS.js → chunk-OG3H3RP2.js} +9 -9
- package/dist/{chunk-UGBNYSBN.js → chunk-PFKPKE6O.js} +20 -34
- package/dist/chunk-PRWPFBA5.js +619 -0
- package/dist/{chunk-QDKETK7D.js → chunk-S55JKMG7.js} +5 -5
- package/dist/{chunk-QDYE5LVT.js → chunk-SF3HCW4G.js} +45 -4
- package/dist/{chunk-6MMBQVRO.js → chunk-TDKKZA63.js} +9 -9
- package/dist/{chunk-HHYEAFCL.js → chunk-TDXHBS2C.js} +11 -11
- package/dist/{chunk-74AIU53R.js → chunk-THGGU64E.js} +3 -3
- package/dist/chunk-UHSGD4CD.js +364 -0
- package/dist/{chunk-HV2W6HUR.js → chunk-URAURI6G.js} +10 -10
- package/dist/{chunk-D6XO4JVM.js → chunk-UU6KUS5O.js} +42 -20
- package/dist/{chunk-NKG4N6HA.js → chunk-V7KEEDSF.js} +5 -4
- package/dist/{chunk-IEAWNA3V.js → chunk-VDFWWWLL.js} +3 -3
- package/dist/chunk-VHAA22YE.js +11 -0
- package/dist/chunk-WJB5GWAZ.js +20 -0
- package/dist/{chunk-KJ5JUS53.js → chunk-WM6DGNIA.js} +9 -9
- package/dist/{chunk-MFFA5MXY.js → chunk-WUXMLJEC.js} +5 -5
- package/dist/{chunk-YPNL2NBD.js → chunk-XNXBO44X.js} +33 -11
- package/dist/chunk-XPY3XT7L.js +5671 -0
- package/dist/{chunk-54SIZR63.js → chunk-XVFRDKZJ.js} +7 -7
- package/dist/{chunk-LYXPJERB.js → chunk-YDD46AX2.js} +5 -5
- package/dist/{chunk-NC63TYNW.js → chunk-YHQJGNXD.js} +7 -7
- package/dist/{chunk-I6WMNXC7.js → chunk-YKRE5NIH.js} +6 -6
- package/dist/{chunk-RJTVCA62.js → chunk-ZIEGUI25.js} +3 -3
- package/dist/{chunk-5DP7W5HX.js → chunk-ZLDWYTDA.js} +3 -3
- package/dist/color-input.d.ts +93 -0
- package/dist/color-input.js +36 -0
- package/dist/color-picker.d.ts +268 -0
- package/dist/color-picker.js +29 -0
- package/dist/color-value-DYzChVOW.d.ts +129 -0
- package/dist/combobox.d.ts +1 -1
- package/dist/combobox.js +14 -12
- package/dist/data-map.d.ts +1673 -0
- package/dist/data-map.js +36 -0
- package/dist/date-calendar.d.ts +49 -0
- package/dist/date-calendar.js +13 -0
- package/dist/date-input.d.ts +1 -1
- package/dist/date-input.js +12 -10
- package/dist/date-picker.d.ts +15 -131
- package/dist/date-picker.js +26 -21
- package/dist/date-types-CLZek3W2.d.ts +100 -0
- package/dist/dialog.d.ts +1 -1
- package/dist/dialog.js +10 -9
- package/dist/drawer.d.ts +1 -1
- package/dist/drawer.js +9 -8
- package/dist/dropdown-menu.d.ts +1 -1
- package/dist/dropdown-menu.js +5 -4
- package/dist/dropzone.d.ts +3 -3
- package/dist/dropzone.js +18 -16
- package/dist/file-trigger.js +1 -0
- package/dist/form.d.ts +15 -5
- package/dist/form.js +75 -35
- package/dist/header-navigation.d.ts +2 -2
- package/dist/header-navigation.js +20 -18
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +1 -0
- package/dist/illustration.js +1 -0
- package/dist/index.d.ts +26 -11
- package/dist/index.js +92 -77
- package/dist/indicator.js +5 -4
- package/dist/inline-banner.d.ts +68 -0
- package/dist/inline-banner.js +21 -0
- package/dist/input.d.ts +1 -1
- package/dist/input.js +11 -9
- package/dist/kanban-board.d.ts +2 -2
- package/dist/kanban-board.js +15 -13
- package/dist/labels-CuSlirP_.d.ts +1381 -0
- package/dist/line-chart.d.ts +2 -2
- package/dist/line-chart.js +8 -6
- package/dist/mcp.js +231 -0
- package/dist/number-input.d.ts +1 -1
- package/dist/number-input.js +11 -9
- package/dist/pagination.d.ts +1 -1
- package/dist/pagination.js +15 -13
- package/dist/{card-D56VxyAe.d.ts → panel-CUGm_Mxy.d.ts} +9 -57
- package/dist/payment-input.d.ts +3 -3
- package/dist/payment-input.js +11 -9
- package/dist/picker-draft-BPV3MUPY.d.ts +9 -0
- package/dist/pie-chart.d.ts +2 -2
- package/dist/pie-chart.js +8 -6
- package/dist/popover.d.ts +65 -4
- package/dist/popover.js +9 -8
- package/dist/progress-steps.js +5 -4
- package/dist/progress.js +4 -3
- package/dist/provider.d.ts +1 -1
- package/dist/provider.js +4 -3
- package/dist/qr-code.d.ts +227 -0
- package/dist/qr-code.js +20 -0
- package/dist/radar-chart.d.ts +2 -2
- package/dist/radar-chart.js +8 -6
- package/dist/radial-chart.d.ts +2 -2
- package/dist/radial-chart.js +8 -6
- package/dist/radio.js +9 -7
- package/dist/rich-text-editor.d.ts +624 -0
- package/dist/rich-text-editor.js +52 -0
- package/dist/rich-text-highlight.d.ts +11 -0
- package/dist/rich-text-highlight.js +65 -0
- package/dist/rich-text-sanitize.d.ts +17 -0
- package/dist/rich-text-sanitize.js +176 -0
- package/dist/scroll-area.js +1 -0
- package/dist/select.d.ts +2 -2
- package/dist/select.js +17 -15
- package/dist/separator.js +3 -2
- package/dist/shared-CGf2D8ZX.d.ts +20 -0
- package/dist/sidebar-navigation.d.ts +73 -32
- package/dist/sidebar-navigation.js +15 -13
- package/dist/sidebar-state.d.ts +76 -0
- package/dist/sidebar-state.js +27 -0
- package/dist/skeleton.js +3 -2
- package/dist/slider.d.ts +321 -0
- package/dist/slider.js +14 -0
- package/dist/styles.css +1 -1
- package/dist/switch.d.ts +1 -1
- package/dist/switch.js +3 -2
- package/dist/table.d.ts +3 -19
- package/dist/table.js +34 -32
- package/dist/tabs.js +3 -2
- package/dist/tag-input.d.ts +3 -3
- package/dist/tag-input.js +14 -12
- package/dist/tag.d.ts +1 -1
- package/dist/tag.js +5 -4
- package/dist/textarea.js +9 -7
- package/dist/theme.css +965 -0
- package/dist/theme.js +13 -11
- package/dist/toast.d.ts +1 -1
- package/dist/toast.js +13 -11
- package/dist/tooltip.js +5 -3
- package/dist/tree.d.ts +1 -1
- package/dist/tree.js +7 -6
- package/dist/{types-DR9rAEy1.d.ts → types-BoZ6XeLB.d.ts} +1 -1
- package/dist/{use-uploads-KaPqDklo.d.ts → use-uploads-cHo2p7Gn.d.ts} +1 -1
- package/dist/verification-code-input.js +11 -9
- package/package.json +105 -8
- package/dist/chunk-BLIZ3CL3.js +0 -49
- package/dist/labels-DPrh0se9.d.ts +0 -627
- package/dist/panel-El4oI68p.d.ts +0 -9
- package/dist/shared-BYXJPnsN.d.ts +0 -11
|
@@ -0,0 +1,1673 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import { M as MapLabels } from './labels-CuSlirP_.js';
|
|
3
|
+
import { A as AtLeastOne } from './at-least-one-BZ2dsck-.js';
|
|
4
|
+
import { R as RuleTexture } from './rule-BqzaIwJy.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* **Our vocabulary for the map.** No engine shape appears here at all — that is the point.
|
|
8
|
+
*
|
|
9
|
+
* Phase 0 locked `onReady` to a NARROW HOUSE HANDLE rather than the raw instance, and this file is
|
|
10
|
+
* what makes that enforceable: there is no path by which `maplibregl.Map` reaches a public type, so
|
|
11
|
+
* the consequences `02-engine-and-style.md` §1 priced for the raw alternative (a third-party name
|
|
12
|
+
* snapshotted into `api-snapshot.md`, a `dist/map.d.ts` non-portable in a way no other entry is, a
|
|
13
|
+
* narrowing that could never be undone) do not apply.
|
|
14
|
+
*
|
|
15
|
+
* ## Why the engine INSTANCE is opaque rather than a mirrored interface
|
|
16
|
+
*
|
|
17
|
+
* The first attempt declared a structural `MapEngineInstance` listing the ~30 methods the adapter
|
|
18
|
+
* calls. Two things were wrong with it, and both matter:
|
|
19
|
+
*
|
|
20
|
+
* 1. **It could not be called.** Parameters typed `never` accept nothing, and typing them loosely
|
|
21
|
+
* instead runs straight into method-parameter bivariance — a mirror that compiles proves nothing.
|
|
22
|
+
* 2. **It drifts SILENTLY.** Rename a method upstream and a hand-written mirror still type-checks
|
|
23
|
+
* while the call fails at runtime, which is the failure mode containment is supposed to prevent.
|
|
24
|
+
*
|
|
25
|
+
* So the instance is **opaque** (`MapEngineInstance` below) and **every call into the engine is a
|
|
26
|
+
* function in `engine.ts`**, written against MapLibre's real types. An upstream rename is then a
|
|
27
|
+
* `pnpm typecheck` failure in the one file allowed to name the engine — the guarantee falls out of
|
|
28
|
+
* the structure instead of being asserted on top of it.
|
|
29
|
+
*/
|
|
30
|
+
/** `[longitude, latitude]`. Ours, deliberately a tuple rather than MapLibre's `LngLatLike` union —
|
|
31
|
+
* an object/array/instance union is three spellings of one answer at a public boundary. */
|
|
32
|
+
type LngLatTuple = readonly [lng: number, lat: number];
|
|
33
|
+
/** `[west, south, east, north]` — the same order `03-drilldown-state.md` uses for a captured
|
|
34
|
+
* `parentBounds`, so a drill frame's bbox needs no conversion to be flown to. */
|
|
35
|
+
type BoundsTuple = readonly [west: number, south: number, east: number, north: number];
|
|
36
|
+
/** Chrome-aware padding. Not a single number: `fitBounds` must clear the legend and the breadcrumb
|
|
37
|
+
* independently, and those live on different edges (§8 — a drilled region under the legend is the
|
|
38
|
+
* component failing at the one job it took over). */
|
|
39
|
+
interface PaddingBox {
|
|
40
|
+
readonly top: number;
|
|
41
|
+
readonly right: number;
|
|
42
|
+
readonly bottom: number;
|
|
43
|
+
readonly left: number;
|
|
44
|
+
}
|
|
45
|
+
interface CameraPosition {
|
|
46
|
+
readonly center: LngLatTuple;
|
|
47
|
+
readonly zoom: number;
|
|
48
|
+
readonly bearing: number;
|
|
49
|
+
readonly pitch: number;
|
|
50
|
+
}
|
|
51
|
+
/** A camera target. Every field optional — a move may set only zoom. */
|
|
52
|
+
interface CameraTarget {
|
|
53
|
+
readonly center?: LngLatTuple;
|
|
54
|
+
readonly zoom?: number;
|
|
55
|
+
readonly bearing?: number;
|
|
56
|
+
readonly pitch?: number;
|
|
57
|
+
}
|
|
58
|
+
/** How a camera change is applied.
|
|
59
|
+
*
|
|
60
|
+
* `"jump"` is not merely "duration 0": `prefers-reduced-motion` collapses every animated move to
|
|
61
|
+
* it, and the distinction has to survive that collapse so the reconciler can tell a move it was
|
|
62
|
+
* ASKED to animate from one it was asked to snap. */
|
|
63
|
+
type CameraTransition = "jump" | "ease" | "fly";
|
|
64
|
+
/**
|
|
65
|
+
* How the map's OPENING FRAME arrives — the once-per-mount fit, and nothing else.
|
|
66
|
+
*
|
|
67
|
+
* It lives beside `CameraTransition` rather than on the camera options because what it selects is a
|
|
68
|
+
* `duration`/`linear` pair on `FitBoundsMove`, which is declared right below.
|
|
69
|
+
*
|
|
70
|
+
* **Two members, not three.** `"ease"` looks like the obvious middle setting and cannot exist
|
|
71
|
+
* honestly: `fitBounds` conflates `linear` with "duration 0" on the COVER path (`engine.ts`, the
|
|
72
|
+
* `easeTo` at the end of the cover branch reads `duration ?? (linear ? 0 : undefined)`), so a bare
|
|
73
|
+
* `{ linear: true }` would mean *500ms linear* under `fit: "contain"` and *instant* under
|
|
74
|
+
* `fit: "cover"` — one word, two behaviours, decided by an unrelated prop, silently.
|
|
75
|
+
*/
|
|
76
|
+
type MapIntro = "instant" | "fly";
|
|
77
|
+
/**
|
|
78
|
+
* How a fit FRAMES what it is given.
|
|
79
|
+
*
|
|
80
|
+
* Split out of `MapFit` because `"none"` is not a framing — it is an OPENING-frame answer meaning
|
|
81
|
+
* *"do not fit at all, the camera is already where I put it"*. An explicit fit has already been asked
|
|
82
|
+
* to move, so it cannot take that member, and the type says so instead of a runtime guard.
|
|
83
|
+
*
|
|
84
|
+
* Declared HERE rather than beside `MapFit` in `use-map-view.ts` because `FitBoundsMove` below now
|
|
85
|
+
* names it, and this file is the lower layer — the hook imports the engine's types, never the
|
|
86
|
+
* reverse. `use-map-view.ts` re-exports it, so the public name is unchanged.
|
|
87
|
+
*/
|
|
88
|
+
type MapFitFraming = "contain" | "cover";
|
|
89
|
+
interface CameraMove extends CameraTarget {
|
|
90
|
+
readonly transition?: CameraTransition;
|
|
91
|
+
readonly duration?: number;
|
|
92
|
+
readonly padding?: PaddingBox;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* One `fitBounds` move.
|
|
96
|
+
*
|
|
97
|
+
* **`fit` and `intro`, not `cover` and `linear`** — the same two axes the hook's `MapFitOptions`
|
|
98
|
+
* already names, spelled the same way. This shipped as two booleans beside two unions that answered
|
|
99
|
+
* the identical questions, and both are public: a caller reaching `handle.fitBounds` through
|
|
100
|
+
* `onReady` had to learn `{ cover: true, linear: true }` while the same intent through
|
|
101
|
+
* `view.fitTo` is `{ fit: "cover", intro: "instant" }`. AGENTS §4 — mutually exclusive answers are
|
|
102
|
+
* ONE union, and the boolean form cannot name its off state: `cover: false` is "contain" said
|
|
103
|
+
* badly, and `linear: false` is "fly" said badly.
|
|
104
|
+
*
|
|
105
|
+
* Nothing was removed. Both capabilities are still here; there is one way to ask for each.
|
|
106
|
+
*/
|
|
107
|
+
interface FitBoundsMove {
|
|
108
|
+
readonly bounds: BoundsTuple;
|
|
109
|
+
/**
|
|
110
|
+
* Whether the extent is CONTAINED in the canvas or COVERS it, cropping.
|
|
111
|
+
*
|
|
112
|
+
* `fitBounds` only ever contained. R5 §A measured **~84% of every map canvas as empty** and there
|
|
113
|
+
* was no way to say "fill the frame" — a country is tall and a dashboard panel is wide, so
|
|
114
|
+
* containing Thailand in a 16:9 box spends most of the box on sea. A real cartographic choice
|
|
115
|
+
* rather than a default: containing is right when the point is that two regions are far apart,
|
|
116
|
+
* covering is right when the point is the shape of the data.
|
|
117
|
+
* @default "contain"
|
|
118
|
+
*/
|
|
119
|
+
readonly fit?: MapFitFraming;
|
|
120
|
+
readonly padding?: PaddingBox;
|
|
121
|
+
readonly duration?: number;
|
|
122
|
+
readonly maxZoom?: number;
|
|
123
|
+
/** Whether the camera arcs there or cuts. `"instant"` is also what `prefers-reduced-motion`
|
|
124
|
+
* forces, whatever this says. @default "fly" */
|
|
125
|
+
readonly intro?: MapIntro;
|
|
126
|
+
}
|
|
127
|
+
/** A rendered feature, as the hit test returns it. Narrower than MapLibre's `MapGeoJSONFeature`:
|
|
128
|
+
* the drill-down needs an id and properties and nothing else. */
|
|
129
|
+
interface RenderedFeature {
|
|
130
|
+
readonly id: string | undefined;
|
|
131
|
+
readonly properties: Readonly<Record<string, unknown>>;
|
|
132
|
+
readonly layerId: string;
|
|
133
|
+
readonly sourceId: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The public escape hatch, Phase-0 decision 3: **a narrow house handle, not `maplibregl.Map`.**
|
|
137
|
+
*
|
|
138
|
+
* Deliberately small. `setPaintProperty`, `addLayer` and `getStyle` are absent, and their absence IS
|
|
139
|
+
* the point — a caller who needs them is past the line this library draws and should use MapLibre
|
|
140
|
+
* directly for that screen. Each widening of this interface is a design decision, not a shrug.
|
|
141
|
+
*/
|
|
142
|
+
interface MapHandle {
|
|
143
|
+
/** Where the camera is now. */
|
|
144
|
+
getCamera(): CameraPosition;
|
|
145
|
+
/** Move the camera. Honours `prefers-reduced-motion` exactly as the component's own moves do. */
|
|
146
|
+
setCamera(move: CameraMove): void;
|
|
147
|
+
/** Frame a bounding box, with the same legend-aware padding the drill-down uses. */
|
|
148
|
+
fitBounds(move: FitBoundsMove): void;
|
|
149
|
+
/** Hit test at a point in canvas pixels. Empty when nothing is under it. */
|
|
150
|
+
queryAt(point: {
|
|
151
|
+
readonly x: number;
|
|
152
|
+
readonly y: number;
|
|
153
|
+
}): readonly RenderedFeature[];
|
|
154
|
+
/** Force a resize measurement. Needed when the container is animated by something we cannot see
|
|
155
|
+
* (a drawer opening, a panel resizing) — the one call whose absence is a visible bug. */
|
|
156
|
+
redraw(): void;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Binning — turning a column of numbers into the classes a choropleth paints.
|
|
161
|
+
*
|
|
162
|
+
* Phase 0 locked **`quantile`** as the default, and it is a measured choice rather than a taste:
|
|
163
|
+
* on a 10-value fixture with six zeros (the shape of real sales-by-district data), equal-interval
|
|
164
|
+
* puts **9 of 10 values in bucket 0** — the flat-colour map — while quantile yields four reachable
|
|
165
|
+
* classes.
|
|
166
|
+
*
|
|
167
|
+
* Two behaviours here are the whole reason this is not four lines of `Math.min`/`Math.max`:
|
|
168
|
+
*
|
|
169
|
+
* 1. **Tie de-duplication.** `quantile` on skewed data produces DUPLICATE edges: if 60% of tambons
|
|
170
|
+
* have zero sales, the 1st–5th quantile boundaries are all `0`, so a naive implementation renders
|
|
171
|
+
* five identical `0–0` legend rows and four classes that no feature can ever fall into. Edges are
|
|
172
|
+
* de-duplicated and **the class count drops accordingly** — which is why `BinResult` reports what
|
|
173
|
+
* EXISTS separately from what was REQUESTED, and why the legend must render `bins.length`.
|
|
174
|
+
* 2. **All-identical collapses to ONE class**, not to a ramp of one colour repeated and not to a
|
|
175
|
+
* crash.
|
|
176
|
+
*/
|
|
177
|
+
/**
|
|
178
|
+
* How the classes are cut.
|
|
179
|
+
*
|
|
180
|
+
* `readonly number[]` is the explicit escape hatch — the hand-authored geometric ladder
|
|
181
|
+
* (`[10, 20, 50, 100, 200, 500, 1000]`) that a real dashboard ships, and which the reference
|
|
182
|
+
* screenshot uses precisely because someone hit the tie problem above.
|
|
183
|
+
*
|
|
184
|
+
* `"jenks"` (natural breaks) is deliberately **absent from v1**. It is the cartographically correct
|
|
185
|
+
* default for skewed money data, and adding a union member later is non-breaking — so it is a
|
|
186
|
+
* follow-up rather than a blocker, and `05-choropleth-api.md`'s open question 1 is answered "not
|
|
187
|
+
* yet, knowingly".
|
|
188
|
+
*/
|
|
189
|
+
type BinStrategy = "quantile" | "equal" | readonly number[];
|
|
190
|
+
interface Bin {
|
|
191
|
+
readonly index: number;
|
|
192
|
+
/** Inclusive. */
|
|
193
|
+
readonly min: number;
|
|
194
|
+
/** Inclusive on the LAST bin, exclusive otherwise — so a value equal to an interior edge lands in
|
|
195
|
+
* the HIGHER bin and no value is unassignable. */
|
|
196
|
+
readonly max: number;
|
|
197
|
+
}
|
|
198
|
+
interface BinResult {
|
|
199
|
+
/** What EXISTS. The legend renders these, never a fixed count. */
|
|
200
|
+
readonly bins: readonly Bin[];
|
|
201
|
+
/** What was ASKED for. Kept so the collapse is reportable rather than invisible. */
|
|
202
|
+
readonly requested: number;
|
|
203
|
+
/** True when tie de-duplication reduced the count. */
|
|
204
|
+
readonly collapsed: boolean;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* The drill-down state machine — the component's reason to exist.
|
|
209
|
+
*
|
|
210
|
+
* The caller writes one function (`load`) and does **not** write: the level/parent stack, the fetch
|
|
211
|
+
* cache, request **cancellation and ordering**, source/layer churn per level, parent-bbox `fitBounds`
|
|
212
|
+
* with legend-aware padding, the re-join + re-bin + legend repaint, `feature-state` hover/selected
|
|
213
|
+
* **and clearing it on level change**, the breadcrumb trail, a cache-aware loading state that does
|
|
214
|
+
* not flash, or the announcement on level change. That is the ~400 lines every dashboard
|
|
215
|
+
* reimplements and gets 80% right.
|
|
216
|
+
*
|
|
217
|
+
* Everything in this file is **pure or self-contained**: the reducer is a function, the cache is a
|
|
218
|
+
* class with no React in it. `use-drill.ts` binds it to the engine. That split is not tidiness — it
|
|
219
|
+
* is what let the Phase 1 spike prove the ordering invariants (`clearFeatureState` is the last thing
|
|
220
|
+
* the engine hears before new data lands) with **no engine present at all**.
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* One feature of a level's geometry.
|
|
225
|
+
*
|
|
226
|
+
* Declared with the GeoJSON fields it actually has rather than only the one we READ. The first draft
|
|
227
|
+
* named just `properties`, which made `LevelData` an exact type that **rejected a real
|
|
228
|
+
* FeatureCollection literal** — `type` and `geometry` were "unknown properties". A caller's `load`
|
|
229
|
+
* returns GeoJSON, so the type has to accept GeoJSON.
|
|
230
|
+
*
|
|
231
|
+
* `geometry` stays `unknown` on purpose: the drill-down never inspects a coordinate — it hands the
|
|
232
|
+
* whole collection to the engine — and mirroring the geometry union here would be a second GeoJSON
|
|
233
|
+
* type to keep in step for no benefit.
|
|
234
|
+
*/
|
|
235
|
+
interface LevelFeature {
|
|
236
|
+
readonly type?: "Feature";
|
|
237
|
+
readonly id?: string | number;
|
|
238
|
+
readonly geometry?: unknown;
|
|
239
|
+
readonly properties?: Readonly<Record<string, unknown>> | null;
|
|
240
|
+
readonly bbox?: BoundsTuple;
|
|
241
|
+
}
|
|
242
|
+
/** A GeoJSON FeatureCollection, as far as the machine needs to care. */
|
|
243
|
+
interface LevelData {
|
|
244
|
+
readonly type: "FeatureCollection";
|
|
245
|
+
readonly features: readonly LevelFeature[];
|
|
246
|
+
/** `[west, south, east, north]`, when the source supplies one. */
|
|
247
|
+
readonly bbox?: BoundsTuple;
|
|
248
|
+
}
|
|
249
|
+
interface DrillFrame {
|
|
250
|
+
/** A `levels[i].key`. */
|
|
251
|
+
readonly level: string;
|
|
252
|
+
/** The feature drilled INTO to reach this frame. `undefined` at the root. */
|
|
253
|
+
readonly parentId?: string;
|
|
254
|
+
/**
|
|
255
|
+
* The breadcrumb label — captured **at drill time**, not looked up later.
|
|
256
|
+
*
|
|
257
|
+
* This is the non-obvious part. Once the component has swapped to the child level, the parent's
|
|
258
|
+
* FeatureCollection may have been evicted from a bounded cache, so nothing can answer "what was
|
|
259
|
+
* this province called" retroactively. Record the fact when you have it.
|
|
260
|
+
*/
|
|
261
|
+
readonly parentLabel?: string;
|
|
262
|
+
/** The parent's bbox, captured for the same reason: it is what `back` restores. */
|
|
263
|
+
readonly parentBounds?: BoundsTuple;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** A GeoJSON feature, as far as the join needs to care. */
|
|
267
|
+
interface JoinFeature {
|
|
268
|
+
readonly id?: string | number;
|
|
269
|
+
readonly properties?: Readonly<Record<string, unknown>> | null;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* What a feature measures.
|
|
273
|
+
*
|
|
274
|
+
* A three-member union rather than an optional `value`, because "no data" is a real answer that the
|
|
275
|
+
* paint, the legend and the accessible table each render differently — and an `undefined` cannot be
|
|
276
|
+
* told apart from a field somebody forgot to set.
|
|
277
|
+
*/
|
|
278
|
+
type JoinMeasure = {
|
|
279
|
+
readonly kind: "value";
|
|
280
|
+
readonly value: number;
|
|
281
|
+
} | {
|
|
282
|
+
readonly kind: "category";
|
|
283
|
+
readonly category: string;
|
|
284
|
+
} | {
|
|
285
|
+
readonly kind: "none";
|
|
286
|
+
};
|
|
287
|
+
interface JoinOutcome<Row> {
|
|
288
|
+
readonly key: string;
|
|
289
|
+
/** Every row that matched this feature, in `rows` order. Empty iff the measure is `none`. */
|
|
290
|
+
readonly rows: readonly Row[];
|
|
291
|
+
readonly measure: JoinMeasure;
|
|
292
|
+
}
|
|
293
|
+
interface JoinDiagnostics {
|
|
294
|
+
/** Rows whose key matches no feature — usually a code-vintage mismatch. Tambon codes change with
|
|
295
|
+
* the year, and this is the single most common TH data defect. */
|
|
296
|
+
readonly unmatchedRowCount: number;
|
|
297
|
+
/** All of them, so `onUnmatched` can name every one; the WARNING prints only the first few.
|
|
298
|
+
*
|
|
299
|
+
* **This is a VALUE, not a callback, and that is the fix for a hard crash.** `joinRows` is called
|
|
300
|
+
* from `useMapView`'s projection memo — i.e. during render — so a callback invoked from here is a
|
|
301
|
+
* side effect in the render phase. The documented usage is `onUnmatched: setUnmatched`, and the
|
|
302
|
+
* keys are a fresh array every join, so that setState never converged: React counted the renders
|
|
303
|
+
* and threw *"Too many re-renders"*. The join reports; the hook's effect fires. */
|
|
304
|
+
readonly unmatchedRowKeys: readonly string[];
|
|
305
|
+
/** Duplicate feature keys: `promoteId` makes them the feature ID too, so hover lights two shapes
|
|
306
|
+
* at once. */
|
|
307
|
+
readonly duplicateFeatureKeys: readonly string[];
|
|
308
|
+
/** Features missing the join property entirely — they can never join, and the property name is
|
|
309
|
+
* usually just misspelled. */
|
|
310
|
+
readonly featuresMissingKey: number;
|
|
311
|
+
/** True when at least one feature is unjoined ⇒ the legend owes a `no data` swatch. */
|
|
312
|
+
readonly hasNoData: boolean;
|
|
313
|
+
}
|
|
314
|
+
interface JoinResult<Row> {
|
|
315
|
+
/** One entry per feature, in feature order. */
|
|
316
|
+
readonly outcomes: readonly JoinOutcome<Row>[];
|
|
317
|
+
readonly byKey: ReadonlyMap<string, JoinOutcome<Row>>;
|
|
318
|
+
readonly diagnostics: JoinDiagnostics;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/** A cartographic part of the basemap. Closed, because `style.ts` paints exactly these. */
|
|
322
|
+
type MapStylePart = "background" | "water" | "waterway" | "greenspace" | "building" | "buildingEdge" | "land" | "roadMajor" | "roadMinor" | "roadPath" | "boundaryCountry" | "boundaryRegion" | "labelCountry" | "labelRegion" | "labelPlace" | "labelPlaceMinor" | "labelRoad" | "labelWater" | "labelHalo" | "dataStroke" | "dataHoverStroke" | "dataSelectedStroke" | "dataNoDataStroke" | "lineCasing" | "pointCasing" | "clusterEdge" | "clusterText";
|
|
323
|
+
/** Which theme a style document was generated for. */
|
|
324
|
+
type MapStyleMode = "light" | "dark";
|
|
325
|
+
/** The library's semantic tone union, re-declared here rather than imported: this module is
|
|
326
|
+
* GENERATED and is imported by `style.ts`, which the SERVER build compiles — a runtime import of
|
|
327
|
+
* `src/lib/color.ts` (a table of Tailwind class strings) would drag the whole colour system into a
|
|
328
|
+
* map-only chunk for one type. Structurally identical to `SemanticColor` by construction, and
|
|
329
|
+
* `style.test.ts` asserts the two never diverge. */
|
|
330
|
+
type MapTone = "neutral" | "brand" | "success" | "warning" | "error" | "info";
|
|
331
|
+
/** The three diverging ramps, seven stops each (3 · midpoint · 3). A delta painted on a
|
|
332
|
+
* SEQUENTIAL ramp is unreadable — this is the member that fixes it. */
|
|
333
|
+
type MapDivergingRampName = "error-success" | "error-brand" | "warning-brand";
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* The layer union — **what to draw, as data**, and the six functions that build a member of it.
|
|
337
|
+
*
|
|
338
|
+
* `20-architecture-fork.md` framed the whole design question precisely:
|
|
339
|
+
*
|
|
340
|
+
* > How do you express "N layers of caller data on one camera" as DATA plus BOUNDED props, with
|
|
341
|
+
* > zero public parts and no raw style surface?
|
|
342
|
+
*
|
|
343
|
+
* Every reference answers it with children — `<Source id><Layer type paint/></Source>` — and that
|
|
344
|
+
* shape is illegal here twice over. `TIER_A` / `pnpm compound:check` fails a flat component that
|
|
345
|
+
* ships any public part; and `paint={{ "fill-color": "#7c3aed" }}` is a raw-colour escape hatch the
|
|
346
|
+
* generated-style rule exists to refuse (a `var()` in a WebGL paint property fails **silently**,
|
|
347
|
+
* which is why `style-colors.generated.ts` resolves to hex at build time).
|
|
348
|
+
*
|
|
349
|
+
* So a layer is a **closed spec with bounded props**, and the union is discriminated by `kind`.
|
|
350
|
+
*
|
|
351
|
+
* ## Two rules the union has to keep, or it stops being an abstraction
|
|
352
|
+
*
|
|
353
|
+
* 1. **A member is named for what the READER sees, never for a MapLibre layer type.** `heatmap`, not
|
|
354
|
+
* `type: "heatmap"`; `points`, not `circle` + `symbol`. That is what lets `points` switch from DOM
|
|
355
|
+
* markers to a WebGL `circle` layer by row count with no breaking change, and what would let
|
|
356
|
+
* `heatmap` become a hex grid later.
|
|
357
|
+
* 2. **The union stays SMALL — six, in the 6–8 range `_research/R1-gallery-inventory.md` recommends.**
|
|
358
|
+
* deck.gl's 33 layers reduce to ~8 primitives, and a new MapLibre layer type is not automatically a
|
|
359
|
+
* new member. Anything that fails the "a reader would name this" test belongs *inside* an existing
|
|
360
|
+
* member as a bounded prop.
|
|
361
|
+
*
|
|
362
|
+
* ## Why the six builders, and not plain object literals
|
|
363
|
+
*
|
|
364
|
+
* Every member is generic in the caller's OWN row type, and this is the one place TypeScript will not
|
|
365
|
+
* help: **a heterogeneous array literal does not instantiate a generic union per element.** Measured,
|
|
366
|
+
* four ways, before this file existed —
|
|
367
|
+
*
|
|
368
|
+
* | shape | `position: (b) => …` infers `b`? |
|
|
369
|
+
* | ----- | -------------------------------- |
|
|
370
|
+
* | `layers: { [K in keyof T]: PointsLayer<T[K]> }` (one generic interface) | **yes** |
|
|
371
|
+
* | the same mapped tuple over a generic UNION | no — `implicit any` |
|
|
372
|
+
* | `const` type parameter on the mapped tuple | no |
|
|
373
|
+
* | a second mapped tuple inferring the `kind` too, resolved through a conditional | no |
|
|
374
|
+
*
|
|
375
|
+
* Inference into a union target is the wall, and it is not a version quirk we can wait out. So the
|
|
376
|
+
* canonical form is **one builder per kind**, whose single call site instantiates cleanly:
|
|
377
|
+
*
|
|
378
|
+
* ```ts
|
|
379
|
+
* const view = useMapView({
|
|
380
|
+
* layers: [
|
|
381
|
+
* choroplethLayer({ id: "sales", rows, joinOn: …, scale: { kind: "sequential", value: (r) => r.salesTY } }),
|
|
382
|
+
* pointsLayer({ id: "branches", rows: branches, key: (b) => b.id, position: (b) => [b.lng, b.lat] }),
|
|
383
|
+
* ],
|
|
384
|
+
* });
|
|
385
|
+
* ```
|
|
386
|
+
*
|
|
387
|
+
* They are **plain function exports, never a lowercase namespace object** (`layer.choropleth`). The
|
|
388
|
+
* compound gate's scan is PascalCase-only, so a lowercase namespace would pass it — and a rule that
|
|
389
|
+
* does not fire is not permission (`21-layers-design.md` §2.1).
|
|
390
|
+
*
|
|
391
|
+
* `any` appears exactly once, in `MapLayer`'s erasure, and never reaches a caller: a builder's return
|
|
392
|
+
* type is `MapPointsLayer<Branch>`, and only the array's element type is widened.
|
|
393
|
+
*/
|
|
394
|
+
|
|
395
|
+
/** The GeoJSON any layer draws — the same shape a drill-down `load` resolves to, so one collection
|
|
396
|
+
* serves both and there is no second geometry type to keep in step. */
|
|
397
|
+
type MapGeoJson$1 = LevelData;
|
|
398
|
+
/** The six things a `<DataMap>` can draw. Named for what a reader sees — see this file's header. */
|
|
399
|
+
type MapLayerKind = "choropleth" | "points" | "heatmap" | "lines" | "areas" | "raster";
|
|
400
|
+
/**
|
|
401
|
+
* A layer's opacity — **four steps, not a `0..1` number.**
|
|
402
|
+
*
|
|
403
|
+
* AGENTS §4: a prop must not be looser than the thing it describes. A layer's opacity is a design
|
|
404
|
+
* decision with a ladder ("underneath", "washed", "solid"), not a continuous knob, and the union is
|
|
405
|
+
* also what keeps `props:check` clean without an `OPEN_BY_DESIGN` entry for a number that has no
|
|
406
|
+
* honest reason to be open.
|
|
407
|
+
*/
|
|
408
|
+
type MapOpacity = "full" | "strong" | "medium" | "faint";
|
|
409
|
+
/**
|
|
410
|
+
* What THIS layer's section does inside the stack. `"none"` names the off state rather than leaving
|
|
411
|
+
* it unspellable — the `legend: "none"` precedent, one level down.
|
|
412
|
+
*
|
|
413
|
+
* - **`"auto"`** — take the map's own `legend` form.
|
|
414
|
+
* - **`"expanded"`** — render the full labelled rows even where the map asked for `"compact"` /
|
|
415
|
+
* `"collapsed"`. The primary layer's key stays fully readable while five secondary layers ride the
|
|
416
|
+
* ramp strip. The more specific statement wins, exactly like a per-item `render` over the
|
|
417
|
+
* provider's `link`.
|
|
418
|
+
* - **`"none"`** — this layer contributes no section.
|
|
419
|
+
*
|
|
420
|
+
* `"expanded"` shipped as a member that did NOTHING: the component only ever tested for `"none"`, so
|
|
421
|
+
* it and `"auto"` were two spellings of one behaviour — the defect the closed-set rule exists to stop
|
|
422
|
+
* (AGENTS §4: a member owns every behaviour derived from it).
|
|
423
|
+
*/
|
|
424
|
+
type MapLayerLegend = "auto" | "expanded" | "none";
|
|
425
|
+
/** What every layer has, whatever it draws. */
|
|
426
|
+
interface MapLayerBase {
|
|
427
|
+
/**
|
|
428
|
+
* Stable identity. **One string, five jobs:** the React key, the `feature-state` scope, the legend
|
|
429
|
+
* section id, the text-alternative section id, and the layer-toggle row id. Reusing an id across
|
|
430
|
+
* two layers is the one mistake that corrupts all five at once, so it is dev-warned.
|
|
431
|
+
*/
|
|
432
|
+
readonly id: string;
|
|
433
|
+
/**
|
|
434
|
+
* The layer's name in the legend, the toggle and the text alternative.
|
|
435
|
+
*
|
|
436
|
+
* CONTENT, so it is a prop and never a label (AGENTS §4) — `ChoroplethLevel.label` is the exact
|
|
437
|
+
* precedent. Falls back to the kind's own word from the labels cascade.
|
|
438
|
+
*/
|
|
439
|
+
readonly label?: string;
|
|
440
|
+
/**
|
|
441
|
+
* **INITIAL** visibility only. The live value is `view.layers[i].visible`, because a toggle is
|
|
442
|
+
* state and state has one owner (`pnpm state:check`).
|
|
443
|
+
* @default true
|
|
444
|
+
*/
|
|
445
|
+
readonly visible?: boolean;
|
|
446
|
+
/** @default "full" */
|
|
447
|
+
readonly opacity?: MapOpacity;
|
|
448
|
+
/**
|
|
449
|
+
* Hit-testable.
|
|
450
|
+
*
|
|
451
|
+
* The commonest N-layer defect is a backdrop that swallows clicks meant for the layer above it, so
|
|
452
|
+
* this is a real prop rather than an implementation detail. Defaults to `true` for a data layer and
|
|
453
|
+
* `false` for `raster`, which is imagery and has nothing to say.
|
|
454
|
+
*/
|
|
455
|
+
readonly interactive?: boolean;
|
|
456
|
+
/** @default "auto" */
|
|
457
|
+
readonly legend?: MapLayerLegend;
|
|
458
|
+
}
|
|
459
|
+
/** A sequential ramp: a house tone, or your own ordered list, palest first. */
|
|
460
|
+
type MapRamp = MapTone | readonly string[];
|
|
461
|
+
/** A diverging ramp: one of the three named pairs, or your own odd-length list with the midpoint in
|
|
462
|
+
* the middle. */
|
|
463
|
+
type MapDivergingRamp = MapDivergingRampName | readonly string[];
|
|
464
|
+
/**
|
|
465
|
+
* One category of a categorical fill.
|
|
466
|
+
*
|
|
467
|
+
* `tone` is the library's own closed union and is what makes categorical legal under §7 — six hues,
|
|
468
|
+
* already paired for both themes, and nothing to typo. It is the answer for a status, a state, a
|
|
469
|
+
* pass/fail.
|
|
470
|
+
*
|
|
471
|
+
* `color` is the escape hatch for the case `tone` genuinely cannot express: a category whose colour
|
|
472
|
+
* is a FACT rather than a design choice — a party's own colour, a brand's, a standard's AQI band. It
|
|
473
|
+
* mirrors `ChartSeries.color` / `ChartDatum.color`, which override the chart `palette` the same way,
|
|
474
|
+
* and it WINS over `tone` when both are set.
|
|
475
|
+
*
|
|
476
|
+
* **One rule differs from the chart's, and it is the engine's, not a preference:** a chart's colour
|
|
477
|
+
* lands in a `style` and the browser resolves it, so `token("utility-blue-600")` works there. A
|
|
478
|
+
* MapLibre paint property is JSON handed to WebGL — it resolves no custom property and understands
|
|
479
|
+
* no modern colour function, so `var(…)`, `token(…)`, `oklch()`, `hwb()` and `color-mix()` all fail
|
|
480
|
+
* SILENTLY (the declaration is dropped and the layer keeps its default). Pass a **resolved** colour:
|
|
481
|
+
* a hex, `rgb()`, `hsl()`, or a CSS named colour. `dev-warn` reports the rest.
|
|
482
|
+
*/
|
|
483
|
+
interface MapCategory {
|
|
484
|
+
/** The caller's own category key, as `value` returns it. */
|
|
485
|
+
readonly value: string;
|
|
486
|
+
/** What the legend prints. CONTENT, so it is a prop, not a label. */
|
|
487
|
+
readonly label: string;
|
|
488
|
+
/** The house tone. Ignored when `color` is set. */
|
|
489
|
+
readonly tone?: MapTone;
|
|
490
|
+
/** A resolved CSS colour — hex / `rgb()` / `hsl()` / a named colour. Wins over `tone`. */
|
|
491
|
+
readonly color?: string;
|
|
492
|
+
}
|
|
493
|
+
/** How many rows collapse into one feature. R3 row 18 — and it fixes a real Thai defect: postal-code
|
|
494
|
+
* rows against tambon polygons means a feature owns several rows, and today the join dev-warns on
|
|
495
|
+
* the duplicate and silently keeps the last one. */
|
|
496
|
+
type MapAggregate = "sum" | "mean" | "min" | "max" | "count";
|
|
497
|
+
/**
|
|
498
|
+
* The half of a scale that turns a ROW into a NUMBER.
|
|
499
|
+
*
|
|
500
|
+
* Shared by the three quantitative scale kinds and absent from `categorical`, which is the point: a
|
|
501
|
+
* categorical map has no `aggregate` and no `rate` to be silently dead, because the type does not
|
|
502
|
+
* offer them. The alternative — one flat spec with a dev-warn policing the combination — is the
|
|
503
|
+
* anti-pattern AGENTS §4 names by name.
|
|
504
|
+
*/
|
|
505
|
+
interface MapQuantitativeValue<Row> {
|
|
506
|
+
/** The number being painted. A function, matching `Table`'s `cell`: data → value. */
|
|
507
|
+
readonly value: (row: Row) => number;
|
|
508
|
+
/** How several rows on one feature combine. Without it the LAST row wins and the join warns. */
|
|
509
|
+
readonly aggregate?: MapAggregate;
|
|
510
|
+
/**
|
|
511
|
+
* Rate normalisation — R3 row 21.
|
|
512
|
+
*
|
|
513
|
+
* A choropleth of raw counts is the #1 cartographic anti-pattern: it draws a population map every
|
|
514
|
+
* time. `rate` divides by a denominator the caller supplies and carries **the denominator into the
|
|
515
|
+
* legend and the popup**, because a rate whose base is not stated lies quietly — 60% on-time out of
|
|
516
|
+
* 5 and 99% out of 5,000 must not land in look-alike adjacent bins with nothing to tell them apart.
|
|
517
|
+
*/
|
|
518
|
+
readonly rate?: {
|
|
519
|
+
/** The multiplier the rate is quoted in. @default 1 */
|
|
520
|
+
readonly per?: 1 | 100 | 1000 | 100_000;
|
|
521
|
+
readonly denominator: (row: Row) => number;
|
|
522
|
+
};
|
|
523
|
+
/** How a value becomes text, in the legend and the accessible table. The component owns FORMATTING
|
|
524
|
+
* because it owns locale; the caller owns the currency and the unit. */
|
|
525
|
+
readonly formatValue?: (value: number) => string;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* **How a row becomes a colour** — the accessor and the ramp, in one object.
|
|
529
|
+
*
|
|
530
|
+
* The accessor lives here rather than beside `rows` for one reason that is worth the extra nesting:
|
|
531
|
+
* a categorical map's accessor returns a **string** and a sequential map's returns a **number**, and
|
|
532
|
+
* with one top-level `value` prop either the type is loose (`number | string`) or one of the two
|
|
533
|
+
* modes ships a prop that means nothing. Putting it in the discriminated member makes both illegal
|
|
534
|
+
* states unrepresentable and costs one word at the call site.
|
|
535
|
+
*/
|
|
536
|
+
type MapScale<Row> =
|
|
537
|
+
/** The default. Classes cut from the distribution — see `bins.ts` for why `quantile` is the
|
|
538
|
+
* default and what tie de-duplication does to the class count. */
|
|
539
|
+
({
|
|
540
|
+
readonly kind: "sequential";
|
|
541
|
+
readonly ramp?: MapRamp;
|
|
542
|
+
readonly bins?: BinStrategy;
|
|
543
|
+
} & MapQuantitativeValue<Row>)
|
|
544
|
+
/**
|
|
545
|
+
* R3 row 20. A delta on a sequential ramp is simply unreadable: `-40%` and `+40%` land in adjacent
|
|
546
|
+
* classes and the map reads as if nothing happened. The midpoint is pinned, so "no change" has a
|
|
547
|
+
* colour of its own.
|
|
548
|
+
*/
|
|
549
|
+
| ({
|
|
550
|
+
readonly kind: "diverging";
|
|
551
|
+
readonly ramp?: MapDivergingRamp;
|
|
552
|
+
readonly center?: number;
|
|
553
|
+
readonly bins?: BinStrategy;
|
|
554
|
+
} & MapQuantitativeValue<Row>)
|
|
555
|
+
/** A hand-authored ladder — the geometric one a real dashboard ships (`[10, 50, 100, 500]`). */
|
|
556
|
+
| ({
|
|
557
|
+
readonly kind: "steps";
|
|
558
|
+
readonly edges: readonly number[];
|
|
559
|
+
readonly ramp?: MapRamp;
|
|
560
|
+
} & MapQuantitativeValue<Row>)
|
|
561
|
+
/** R3 row 4 — winning party, AQI band, site status, sold/open/reserved. A `match`, not a ramp, and
|
|
562
|
+
* the legend renders a swatch per value rather than a range. */
|
|
563
|
+
| {
|
|
564
|
+
readonly kind: "categorical";
|
|
565
|
+
readonly value: (row: Row) => string;
|
|
566
|
+
readonly categories: readonly MapCategory[];
|
|
567
|
+
};
|
|
568
|
+
/** A level in a hierarchy. **Names only, never geometry** — see `MapLevels`. */
|
|
569
|
+
interface MapLevel {
|
|
570
|
+
/** The key `load` is called with. */
|
|
571
|
+
readonly key: string;
|
|
572
|
+
/** The caller's own word for this level ("จังหวัด", "Floor", "Aisle"). CONTENT, so it is a prop. */
|
|
573
|
+
readonly label: string;
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* The drilling wire — **D3 in `70-differentiators.md`, and the component's moat.**
|
|
577
|
+
*
|
|
578
|
+
* Nothing in it is administrative. It walks *any* tree of named regions whose children are fetched on
|
|
579
|
+
* demand: warehouse → zone → aisle → bay, mall → floor → unit, sales territory → district → rep. The
|
|
580
|
+
* levels are strings the caller chose and `load` is a function the caller wrote; the state machine —
|
|
581
|
+
* the stack, the `(level, parentId)` cache, cancellation **with ordering**, `settledDepth` so a
|
|
582
|
+
* speculative tip never reports, `feature-state` cleared per level, legend-aware `fitBounds`, and a
|
|
583
|
+
* breadcrumb whose label is captured at click time because the parent may be evicted by then — is
|
|
584
|
+
* ours.
|
|
585
|
+
*
|
|
586
|
+
* The WIRE is here; the POSITION is on the hook (decision 7). That split is the `useTree` precedent
|
|
587
|
+
* exactly: the hook owns expansion and never mutates `nodes`.
|
|
588
|
+
*/
|
|
589
|
+
interface MapLevels {
|
|
590
|
+
/** Outermost first. A NON-EMPTY tuple — a hierarchy with zero levels is not a thing, and the type
|
|
591
|
+
* says so rather than a runtime guard discovering it. */
|
|
592
|
+
readonly levels: readonly [MapLevel, ...MapLevel[]];
|
|
593
|
+
/** `parentId` is undefined at the outermost level. */
|
|
594
|
+
readonly load: (level: string, parentId?: string) => Promise<MapGeoJson$1>;
|
|
595
|
+
}
|
|
596
|
+
/** Where a polygon layer's edge sits on the weight ladder. */
|
|
597
|
+
type MapOutline = "none" | "hairline" | "strong";
|
|
598
|
+
/** R5 §B.4 — "the reader cannot name a single region without hovering". `"top"` labels only the
|
|
599
|
+
* features whose value is in the top class, which is what a real thematic map does at country zoom. */
|
|
600
|
+
type MapFeatureLabels = "none" | "all" | "top";
|
|
601
|
+
interface MapChoroplethLayerSpec<Row> extends MapLayerBase {
|
|
602
|
+
/** A static collection, OR the drilling wire. */
|
|
603
|
+
readonly features: MapGeoJson$1 | MapLevels;
|
|
604
|
+
/** The caller's own domain objects — not `Option`s, no `value`/`label`, exactly like `<Table rows>`. */
|
|
605
|
+
readonly rows: readonly Row[];
|
|
606
|
+
/**
|
|
607
|
+
* The join.
|
|
608
|
+
*
|
|
609
|
+
* `feature` does **double duty**: it is the GeoJSON property to match on AND — through the source's
|
|
610
|
+
* `promoteId` — the feature id that hover and selection address. It must be present and unique per
|
|
611
|
+
* level; both failures are silent, so both get a dev-warning.
|
|
612
|
+
*/
|
|
613
|
+
readonly joinOn: {
|
|
614
|
+
readonly feature: string;
|
|
615
|
+
readonly row: (row: Row) => string;
|
|
616
|
+
};
|
|
617
|
+
/** How a row becomes a colour. Required, because it carries the value accessor. */
|
|
618
|
+
readonly scale: MapScale<Row>;
|
|
619
|
+
readonly outline?: MapOutline;
|
|
620
|
+
/** @default "none" */
|
|
621
|
+
readonly labelFeatures?: MapFeatureLabels;
|
|
622
|
+
/**
|
|
623
|
+
* The HOVER readout's body. Optional in the strongest sense: with no `renderTooltip` at all the map
|
|
624
|
+
* still names the region and prints its formatted value, derived from the same `name` and `scale`
|
|
625
|
+
* the legend and the accessible table read — so the two can never disagree. This is for the caller
|
|
626
|
+
* who wants more than a name and a number.
|
|
627
|
+
*/
|
|
628
|
+
readonly renderTooltip?: (feature: JoinFeature, rows: readonly Row[]) => React.ReactNode;
|
|
629
|
+
/** The display name for a region — the breadcrumb, the accessible table, the popup's title.
|
|
630
|
+
* @default the feature's `name` property */
|
|
631
|
+
readonly name?: (feature: JoinFeature) => string;
|
|
632
|
+
/**
|
|
633
|
+
* Popup body for a clicked region.
|
|
634
|
+
*
|
|
635
|
+
* `rows` PLURAL, because `aggregate` means a feature may own several — and it is **empty** for an
|
|
636
|
+
* unjoined feature, a real state that must render rather than crash. The `Table.cell` category:
|
|
637
|
+
* data → node, never structure.
|
|
638
|
+
*/
|
|
639
|
+
readonly renderPopup?: (feature: JoinFeature, rows: readonly Row[]) => React.ReactNode;
|
|
640
|
+
/**
|
|
641
|
+
* R3 row 22 — which rows matched nothing.
|
|
642
|
+
*
|
|
643
|
+
* `"Buriram"` vs `"Buri Ram"` silently drops one province of 77 and paints it "No data", and a
|
|
644
|
+
* silent wrong answer is a craft defect as much as a correctness one. Reported, never absorbed.
|
|
645
|
+
*
|
|
646
|
+
* **Called from an effect, after commit, and only when the SET changes** — including when it
|
|
647
|
+
* changes to `[]`, so a caller who fixed their keys is told. `setUnmatched` is therefore the
|
|
648
|
+
* intended usage and is safe: the join itself runs during render, so calling this from there made
|
|
649
|
+
* that exact call an unbounded render loop ("Too many re-renders").
|
|
650
|
+
*/
|
|
651
|
+
readonly onUnmatched?: (keys: readonly string[]) => void;
|
|
652
|
+
/**
|
|
653
|
+
* Which time frame a row belongs to — R3 row 6, the time axis.
|
|
654
|
+
*
|
|
655
|
+
* An accessor rather than a magic `row.frame` property, for the same reason every other axis is one:
|
|
656
|
+
* the caller's rows are their own domain objects and the library must not reserve a field name in
|
|
657
|
+
* them. The key is opaque and is matched against `MapTimeFrame.key` — **the map never parses a
|
|
658
|
+
* date**, because formatting owns locale, zone and era and those belong to the app.
|
|
659
|
+
*
|
|
660
|
+
* A row with no frame accessor at all is shown in EVERY frame, which is what makes a static layer
|
|
661
|
+
* legal beside an animated one.
|
|
662
|
+
*/
|
|
663
|
+
readonly frame?: (row: Row) => string;
|
|
664
|
+
}
|
|
665
|
+
/** The pin vocabulary — R5 §C.3 measured the whole shipped set as "one shape, and it is a text pill". */
|
|
666
|
+
type MapMarkerShape = "dot" | "ring" | "pin" | "teardrop" | "label" | "icon" | "avatar";
|
|
667
|
+
/** How big a graduated symbol gets. Ours, so it is a ladder rather than a pixel number. */
|
|
668
|
+
type MapSizeRange = "sm" | "md" | "lg";
|
|
669
|
+
/**
|
|
670
|
+
* Which rendering a `points` layer uses.
|
|
671
|
+
*
|
|
672
|
+
* `"auto"` resolves by count and is almost always right. The two named modes exist because the trade
|
|
673
|
+
* is real and a caller sometimes has to choose it (`21-layers-design.md` §3c):
|
|
674
|
+
*
|
|
675
|
+
* | mode | right from | right to | why it stops |
|
|
676
|
+
* | ---- | ---------- | -------- | ------------ |
|
|
677
|
+
* | `dom` | 1 | ~300 rendered | each marker is a positioned React node repositioned per frame; past a few hundred every pan stutters. The ONLY mode where a marker is composable and focusable |
|
|
678
|
+
* | `gl` | ~300 | ~100 000 | no DOM node ⇒ no focus and no React content; the popup becomes a hit test + our own portal |
|
|
679
|
+
*
|
|
680
|
+
* A `renderMarker` **forces** `dom`, and the type says so by making the two props coexist rather than
|
|
681
|
+
* by a warning discovering it at runtime.
|
|
682
|
+
*/
|
|
683
|
+
type MapPointsMode = "auto" | "dom" | "gl";
|
|
684
|
+
interface MapClusterOptions {
|
|
685
|
+
/**
|
|
686
|
+
* The merge distance in CSS pixels.
|
|
687
|
+
*
|
|
688
|
+
* OPEN by design (`props:check` → `OPEN_BY_DESIGN`): it is a screen measure whose whole positive
|
|
689
|
+
* range is meaningful, so no union can describe it. The engine ABSORBS a bad one — a radius of 0
|
|
690
|
+
* produces one cluster per point and reports nothing — so it owes the dev-warn a clamp would hide.
|
|
691
|
+
* @default 48 on a fine pointer, 64 on a coarse one
|
|
692
|
+
*/
|
|
693
|
+
readonly radius?: number;
|
|
694
|
+
/** Above this zoom nothing clusters. @default 14 */
|
|
695
|
+
readonly maxZoom?: number;
|
|
696
|
+
/**
|
|
697
|
+
* R5 §C.1–C.2: today a cluster of 3 and a cluster of 300 render identically, which is the single
|
|
698
|
+
* most-cited visual defect and is literally the benchmark's look.
|
|
699
|
+
* @default "count"
|
|
700
|
+
*/
|
|
701
|
+
readonly sizeBy?: "none" | "count";
|
|
702
|
+
/**
|
|
703
|
+
* What happens to pins that sit on the SAME point once zooming can separate them no further.
|
|
704
|
+
*
|
|
705
|
+
* `"stack"` leaves them piled, so the ones underneath are permanently unreachable — R5 §C.8.
|
|
706
|
+
* `"spiderfy"` fans them onto a short radius with leader lines, which is the standard answer and
|
|
707
|
+
* the only one that makes every pin clickable.
|
|
708
|
+
*
|
|
709
|
+
* A union rather than `spiderfy?: boolean`, for the reason `sizeBy` beside it already follows: the
|
|
710
|
+
* off state is a real behaviour (they stack) and deserves a name, rather than being the unspellable
|
|
711
|
+
* absence of the other one.
|
|
712
|
+
* @default "stack"
|
|
713
|
+
*/
|
|
714
|
+
readonly coincident?: "stack" | "spiderfy";
|
|
715
|
+
}
|
|
716
|
+
interface MapPointsLayerSpec<Row> extends MapLayerBase {
|
|
717
|
+
readonly rows: readonly Row[];
|
|
718
|
+
/**
|
|
719
|
+
* Stable identity, and it is what makes **live diffing** possible (R3 row 16): a 15-minute outage
|
|
720
|
+
* poll or a 1-second GPS tick re-passes `rows`, and the layer moves / adds / removes by key with no
|
|
721
|
+
* remount and no camera jump. Without it every poll is a rebuild, and a rebuild mid-pan is what
|
|
722
|
+
* makes a live map unusable.
|
|
723
|
+
*/
|
|
724
|
+
readonly key: (row: Row) => string;
|
|
725
|
+
readonly position: (row: Row) => LngLatTuple;
|
|
726
|
+
/**
|
|
727
|
+
* What this point is CALLED — the pin's own text, its accessible name, and its row in the text
|
|
728
|
+
* alternative.
|
|
729
|
+
*
|
|
730
|
+
* Spelled `name` rather than `label` across all four data layers that have named things, because
|
|
731
|
+
* `MapLayerBase.label` is the LAYER's name and two meanings of one word on one object is how a
|
|
732
|
+
* caller writes the wrong one. One concept, one word: `name` is the datum, `label` is the layer.
|
|
733
|
+
*/
|
|
734
|
+
readonly name?: (row: Row) => string;
|
|
735
|
+
/** @default "pin" */
|
|
736
|
+
readonly marker?: MapMarkerShape;
|
|
737
|
+
/** R3 row 8 — graduated symbols. A circle per case count, a bubble by customers-affected. */
|
|
738
|
+
readonly size?: {
|
|
739
|
+
readonly value: (row: Row) => number;
|
|
740
|
+
readonly range?: MapSizeRange;
|
|
741
|
+
};
|
|
742
|
+
readonly tone?: MapTone | ((row: Row) => MapTone);
|
|
743
|
+
/**
|
|
744
|
+
* The caller's own word for each tone this layer paints — **what turns a colour encoding into a
|
|
745
|
+
* readable one.**
|
|
746
|
+
*
|
|
747
|
+
* A `tone` FUNCTION is expressive and, on its own, unkeyable: `tone: (row) => row.status ===
|
|
748
|
+
* "closing" ? "error" : "success"` puts red and green marks on the canvas, and the map has no way
|
|
749
|
+
* to know that red means "closing". It shipped that way — the showcase's own kitchen sink painted
|
|
750
|
+
* three tones with no key at all — and `legend.tsx`'s header names exactly that failure: a colour
|
|
751
|
+
* whose meaning the reader has to guess is a picture of a distribution rather than a reading of
|
|
752
|
+
* one.
|
|
753
|
+
*
|
|
754
|
+
* So the words come from the only place that has them. `Partial`, and keyed by the closed
|
|
755
|
+
* `MapTone` union rather than by `string`, so a typo is a compile error and a tone you never paint
|
|
756
|
+
* costs nothing. Supply it and the layer gets a legend section; omit it while painting more than
|
|
757
|
+
* one tone and `dev-warn` says so, because a silent unkeyed encoding is the thing to avoid, not
|
|
758
|
+
* the omission.
|
|
759
|
+
*
|
|
760
|
+
* A single fixed `tone` needs no entry: one colour that never varies encodes nothing, so there is
|
|
761
|
+
* nothing to key.
|
|
762
|
+
*/
|
|
763
|
+
readonly toneLabels?: Partial<Record<MapTone, string>>;
|
|
764
|
+
/** A node the caller composes. Its presence FORCES `mode: "dom"` — see `MapPointsMode`. */
|
|
765
|
+
readonly renderMarker?: (row: Row) => React.ReactNode;
|
|
766
|
+
readonly renderPopup?: (row: Row) => React.ReactNode;
|
|
767
|
+
/** The HOVER readout's body. With none, the map still names the point from `name` and prints its
|
|
768
|
+
* `size` magnitude — see `MapChoroplethLayerSpec.renderTooltip`. */
|
|
769
|
+
readonly renderTooltip?: (row: Row) => React.ReactNode;
|
|
770
|
+
/**
|
|
771
|
+
* Which time frame a row belongs to — R3 row 6, the time axis.
|
|
772
|
+
*
|
|
773
|
+
* An accessor rather than a magic `row.frame` property, for the same reason every other axis is one:
|
|
774
|
+
* the caller's rows are their own domain objects and the library must not reserve a field name in
|
|
775
|
+
* them. The key is opaque and is matched against `MapTimeFrame.key` — **the map never parses a
|
|
776
|
+
* date**, because formatting owns locale, zone and era and those belong to the app.
|
|
777
|
+
*
|
|
778
|
+
* A row with no frame accessor at all is shown in EVERY frame, which is what makes a static layer
|
|
779
|
+
* legal beside an animated one.
|
|
780
|
+
*/
|
|
781
|
+
readonly frame?: (row: Row) => string;
|
|
782
|
+
/** A switch travels with its settings: `AtLeastOne` makes `{}` a type error, because an empty
|
|
783
|
+
* object is a second spelling of the default. */
|
|
784
|
+
readonly cluster?: false | AtLeastOne<MapClusterOptions>;
|
|
785
|
+
/** @default "auto" */
|
|
786
|
+
readonly mode?: MapPointsMode;
|
|
787
|
+
}
|
|
788
|
+
/** How wide a heat kernel is. Ours, so it is a union — not MapLibre's pixel number, which is
|
|
789
|
+
* zoom-relative and means nothing at the call site. */
|
|
790
|
+
type MapHeatRadius = "tight" | "medium" | "wide";
|
|
791
|
+
/**
|
|
792
|
+
* R3 row 9. Order density over Bangkok, complaint density, hotel supply.
|
|
793
|
+
*
|
|
794
|
+
* **No `renderPopup`, and the absence is the design**: a density surface has no features, so there is
|
|
795
|
+
* nothing for a popup to be about. Its text alternative is a summary for the same reason.
|
|
796
|
+
*/
|
|
797
|
+
interface MapHeatmapLayerSpec<Row> extends MapLayerBase {
|
|
798
|
+
readonly rows: readonly Row[];
|
|
799
|
+
readonly position: (row: Row) => LngLatTuple;
|
|
800
|
+
readonly weight?: (row: Row) => number;
|
|
801
|
+
/** @default "medium" */
|
|
802
|
+
readonly radius?: MapHeatRadius;
|
|
803
|
+
/** @default the house heat ramp — multi-hue, because a density gradient has no swatch to match. */
|
|
804
|
+
readonly ramp?: readonly string[];
|
|
805
|
+
/**
|
|
806
|
+
* Which time frame a row belongs to — R3 row 6, the time axis.
|
|
807
|
+
*
|
|
808
|
+
* An accessor rather than a magic `row.frame` property, for the same reason every other axis is one:
|
|
809
|
+
* the caller's rows are their own domain objects and the library must not reserve a field name in
|
|
810
|
+
* them. The key is opaque and is matched against `MapTimeFrame.key` — **the map never parses a
|
|
811
|
+
* date**, because formatting owns locale, zone and era and those belong to the app.
|
|
812
|
+
*
|
|
813
|
+
* A row with no frame accessor at all is shown in EVERY frame, which is what makes a static layer
|
|
814
|
+
* legal beside an animated one.
|
|
815
|
+
*/
|
|
816
|
+
readonly frame?: (row: Row) => string;
|
|
817
|
+
}
|
|
818
|
+
/** How heavy a route is drawn. */
|
|
819
|
+
type MapLineWeight = "hairline" | "sm" | "md" | "lg";
|
|
820
|
+
/**
|
|
821
|
+
* R3 row 14. Breadcrumb tracks, O-D arcs, BTS/MRT lines, fibre routes.
|
|
822
|
+
*/
|
|
823
|
+
interface MapLinesLayerSpec<Row> extends MapLayerBase {
|
|
824
|
+
readonly rows: readonly Row[];
|
|
825
|
+
readonly key: (row: Row) => string;
|
|
826
|
+
readonly path: (row: Row) => readonly LngLatTuple[];
|
|
827
|
+
/** What this route is CALLED — see `MapPointsLayerSpec.name`. */
|
|
828
|
+
readonly name?: (row: Row) => string;
|
|
829
|
+
readonly tone?: MapTone | ((row: Row) => MapTone);
|
|
830
|
+
/**
|
|
831
|
+
* The caller's own word for each tone this layer paints — **what turns a colour encoding into a
|
|
832
|
+
* readable one.**
|
|
833
|
+
*
|
|
834
|
+
* A `tone` FUNCTION is expressive and, on its own, unkeyable: `tone: (row) => row.status ===
|
|
835
|
+
* "closing" ? "error" : "success"` puts red and green marks on the canvas, and the map has no way
|
|
836
|
+
* to know that red means "closing". It shipped that way — the showcase's own kitchen sink painted
|
|
837
|
+
* three tones with no key at all — and `legend.tsx`'s header names exactly that failure: a colour
|
|
838
|
+
* whose meaning the reader has to guess is a picture of a distribution rather than a reading of
|
|
839
|
+
* one.
|
|
840
|
+
*
|
|
841
|
+
* So the words come from the only place that has them. `Partial`, and keyed by the closed
|
|
842
|
+
* `MapTone` union rather than by `string`, so a typo is a compile error and a tone you never paint
|
|
843
|
+
* costs nothing. Supply it and the layer gets a legend section; omit it while painting more than
|
|
844
|
+
* one tone and `dev-warn` says so, because a silent unkeyed encoding is the thing to avoid, not
|
|
845
|
+
* the omission.
|
|
846
|
+
*
|
|
847
|
+
* A single fixed `tone` needs no entry: one colour that never varies encodes nothing, so there is
|
|
848
|
+
* nothing to key.
|
|
849
|
+
*/
|
|
850
|
+
readonly toneLabels?: Partial<Record<MapTone, string>>;
|
|
851
|
+
/** @default "md" */
|
|
852
|
+
readonly weight?: MapLineWeight;
|
|
853
|
+
/**
|
|
854
|
+
* The house rule vocabulary, reused **by name** (`src/lib/rule.ts` — `line` · `dashed` · `dot`), so
|
|
855
|
+
* a route's texture and a `<Separator>`'s are one word.
|
|
856
|
+
*
|
|
857
|
+
* **Not the same PAINT**, and the difference is worth knowing: the rule system's texture is a
|
|
858
|
+
* `background-image` gradient with pinned geometry, which cannot follow a corner; a MapLibre
|
|
859
|
+
* `line-dasharray` can. The names transfer; the mechanism does not.
|
|
860
|
+
*/
|
|
861
|
+
readonly texture?: RuleTexture;
|
|
862
|
+
/**
|
|
863
|
+
* Direction, as repeated glyphs along the line.
|
|
864
|
+
*
|
|
865
|
+
* A union beside `texture` and `curve`, which are the spec's two other decoration axes and both
|
|
866
|
+
* name their off state; `arrows` was the odd one out, and one object with three axes spelled two
|
|
867
|
+
* ways is how a caller writes `arrows: "none"` and gets a type error. `"forward"` follows the
|
|
868
|
+
* path's own point order, which is the only direction the library can know.
|
|
869
|
+
* @default "none"
|
|
870
|
+
*/
|
|
871
|
+
readonly arrows?: "none" | "forward";
|
|
872
|
+
/** An arc rather than a great circle, for origin–destination flows. Computed by us. */
|
|
873
|
+
readonly curve?: "none" | "arc";
|
|
874
|
+
readonly renderPopup?: (row: Row) => React.ReactNode;
|
|
875
|
+
/**
|
|
876
|
+
* Which time frame a row belongs to — R3 row 6, the time axis.
|
|
877
|
+
*
|
|
878
|
+
* An accessor rather than a magic `row.frame` property, for the same reason every other axis is one:
|
|
879
|
+
* the caller's rows are their own domain objects and the library must not reserve a field name in
|
|
880
|
+
* them. The key is opaque and is matched against `MapTimeFrame.key` — **the map never parses a
|
|
881
|
+
* date**, because formatting owns locale, zone and era and those belong to the app.
|
|
882
|
+
*
|
|
883
|
+
* A row with no frame accessor at all is shown in EVERY frame, which is what makes a static layer
|
|
884
|
+
* legal beside an animated one.
|
|
885
|
+
*/
|
|
886
|
+
readonly frame?: (row: Row) => string;
|
|
887
|
+
}
|
|
888
|
+
/** How a polygon layer is filled. `"wash"` is see-through by design: an `areas` layer is usually ON
|
|
889
|
+
* something. */
|
|
890
|
+
type MapAreaFill = "solid" | "wash" | "none";
|
|
891
|
+
/**
|
|
892
|
+
* R3 row 2 — **24 of 38 cards**, and the second-largest gap the shipped component had.
|
|
893
|
+
*
|
|
894
|
+
* Arbitrary caller GeoJSON that is NOT a level in a hierarchy and carries NO value to bin: isochrone
|
|
895
|
+
* MultiPolygons with islands, hand-drawn delivery zones, affected-area polygons, franchise
|
|
896
|
+
* territories, catchment buffers.
|
|
897
|
+
*/
|
|
898
|
+
interface MapAreasLayerSpec extends MapLayerBase {
|
|
899
|
+
readonly features: MapGeoJson$1;
|
|
900
|
+
readonly tone?: MapTone | ((feature: JoinFeature) => MapTone);
|
|
901
|
+
/**
|
|
902
|
+
* The caller's own word for each tone this layer paints — **what turns a colour encoding into a
|
|
903
|
+
* readable one.**
|
|
904
|
+
*
|
|
905
|
+
* A `tone` FUNCTION is expressive and, on its own, unkeyable: `tone: (row) => row.status ===
|
|
906
|
+
* "closing" ? "error" : "success"` puts red and green marks on the canvas, and the map has no way
|
|
907
|
+
* to know that red means "closing". It shipped that way — the showcase's own kitchen sink painted
|
|
908
|
+
* three tones with no key at all — and `legend.tsx`'s header names exactly that failure: a colour
|
|
909
|
+
* whose meaning the reader has to guess is a picture of a distribution rather than a reading of
|
|
910
|
+
* one.
|
|
911
|
+
*
|
|
912
|
+
* So the words come from the only place that has them. `Partial`, and keyed by the closed
|
|
913
|
+
* `MapTone` union rather than by `string`, so a typo is a compile error and a tone you never paint
|
|
914
|
+
* costs nothing. Supply it and the layer gets a legend section; omit it while painting more than
|
|
915
|
+
* one tone and `dev-warn` says so, because a silent unkeyed encoding is the thing to avoid, not
|
|
916
|
+
* the omission.
|
|
917
|
+
*
|
|
918
|
+
* A single fixed `tone` needs no entry: one colour that never varies encodes nothing, so there is
|
|
919
|
+
* nothing to key.
|
|
920
|
+
*/
|
|
921
|
+
readonly toneLabels?: Partial<Record<MapTone, string>>;
|
|
922
|
+
/** @default "wash" */
|
|
923
|
+
readonly fill?: MapAreaFill;
|
|
924
|
+
/** @default "hairline" */
|
|
925
|
+
readonly outline?: MapOutline;
|
|
926
|
+
readonly name?: (feature: JoinFeature) => string;
|
|
927
|
+
readonly renderPopup?: (feature: JoinFeature) => React.ReactNode;
|
|
928
|
+
}
|
|
929
|
+
/** MapLibre's `ImageSource` takes exactly four corners, clockwise from top-left. Named rather than a
|
|
930
|
+
* positional array, because a mis-ordered corner renders a mirrored image and nothing errors. */
|
|
931
|
+
interface MapImageCorners {
|
|
932
|
+
readonly topLeft: LngLatTuple;
|
|
933
|
+
readonly topRight: LngLatTuple;
|
|
934
|
+
readonly bottomRight: LngLatTuple;
|
|
935
|
+
readonly bottomLeft: LngLatTuple;
|
|
936
|
+
}
|
|
937
|
+
type MapRasterSource = {
|
|
938
|
+
readonly kind: "tilejson";
|
|
939
|
+
readonly url: string;
|
|
940
|
+
} | {
|
|
941
|
+
readonly kind: "tiles";
|
|
942
|
+
readonly tiles: readonly string[];
|
|
943
|
+
readonly minzoom?: number;
|
|
944
|
+
readonly maxzoom?: number;
|
|
945
|
+
} | {
|
|
946
|
+
readonly kind: "image";
|
|
947
|
+
readonly url: string;
|
|
948
|
+
readonly corners: MapImageCorners;
|
|
949
|
+
};
|
|
950
|
+
/**
|
|
951
|
+
* R3 row 15, and card 8.7 — **the warehouse floor plan**.
|
|
952
|
+
*
|
|
953
|
+
* Flood extent, NDVI, satellite for landmark-finding — and the story that reframes the whole
|
|
954
|
+
* component, because a floor plan proves the coordinate space does not have to be geography.
|
|
955
|
+
*/
|
|
956
|
+
interface MapRasterLayerSpec extends MapLayerBase {
|
|
957
|
+
readonly source: MapRasterSource;
|
|
958
|
+
/** A raster overlay carries its own credit, printed beside the basemap's. */
|
|
959
|
+
readonly attribution?: string;
|
|
960
|
+
}
|
|
961
|
+
type MapChoroplethLayer<Row> = MapChoroplethLayerSpec<Row> & {
|
|
962
|
+
readonly kind: "choropleth";
|
|
963
|
+
};
|
|
964
|
+
type MapPointsLayer<Row> = MapPointsLayerSpec<Row> & {
|
|
965
|
+
readonly kind: "points";
|
|
966
|
+
};
|
|
967
|
+
type MapHeatmapLayer<Row> = MapHeatmapLayerSpec<Row> & {
|
|
968
|
+
readonly kind: "heatmap";
|
|
969
|
+
};
|
|
970
|
+
type MapLinesLayer<Row> = MapLinesLayerSpec<Row> & {
|
|
971
|
+
readonly kind: "lines";
|
|
972
|
+
};
|
|
973
|
+
type MapAreasLayer = MapAreasLayerSpec & {
|
|
974
|
+
readonly kind: "areas";
|
|
975
|
+
};
|
|
976
|
+
type MapRasterLayer = MapRasterLayerSpec & {
|
|
977
|
+
readonly kind: "raster";
|
|
978
|
+
};
|
|
979
|
+
/**
|
|
980
|
+
* One layer, erased.
|
|
981
|
+
*
|
|
982
|
+
* The `any`s are the union's erasure and nothing more — a builder returns `MapPointsLayer<Branch>`,
|
|
983
|
+
* and only the ARRAY's element type is widened to this. No caller ever sees `any` for a row.
|
|
984
|
+
*/
|
|
985
|
+
type MapLayer = MapChoroplethLayer<any> | MapPointsLayer<any> | MapHeatmapLayer<any> | MapLinesLayer<any> | MapAreasLayer | MapRasterLayer;
|
|
986
|
+
/** A choropleth — polygons coloured by a value, with the drill-down when `features` is a hierarchy. */
|
|
987
|
+
declare function choroplethLayer<Row>(spec: MapChoroplethLayerSpec<Row>): MapChoroplethLayer<Row>;
|
|
988
|
+
/** Points — pins, dots, graduated bubbles, clusters. */
|
|
989
|
+
declare function pointsLayer<Row>(spec: MapPointsLayerSpec<Row>): MapPointsLayer<Row>;
|
|
990
|
+
/** A density surface. */
|
|
991
|
+
declare function heatmapLayer<Row>(spec: MapHeatmapLayerSpec<Row>): MapHeatmapLayer<Row>;
|
|
992
|
+
/** Routes, tracks, flows. */
|
|
993
|
+
declare function linesLayer<Row>(spec: MapLinesLayerSpec<Row>): MapLinesLayer<Row>;
|
|
994
|
+
/** Arbitrary polygons that are not a level and carry no value. Non-generic — it takes features, not
|
|
995
|
+
* rows — and ships anyway, so a reader never has to remember which four of the six need a builder. */
|
|
996
|
+
declare function areasLayer(spec: MapAreasLayerSpec): MapAreasLayer;
|
|
997
|
+
/** Imagery, or a floor plan. Non-generic, for the reason `areasLayer` gives. */
|
|
998
|
+
declare function rasterLayer(spec: MapRasterLayerSpec): MapRasterLayer;
|
|
999
|
+
|
|
1000
|
+
/** One row of a legend section. A discriminated shape, because a range and a category are read
|
|
1001
|
+
* differently and only the range kind formats numbers. */
|
|
1002
|
+
type MapLegendEntry = {
|
|
1003
|
+
readonly kind: "range";
|
|
1004
|
+
readonly id: string;
|
|
1005
|
+
readonly color: string;
|
|
1006
|
+
readonly from: number;
|
|
1007
|
+
readonly to: number;
|
|
1008
|
+
readonly last: boolean;
|
|
1009
|
+
} | {
|
|
1010
|
+
readonly kind: "category";
|
|
1011
|
+
readonly id: string;
|
|
1012
|
+
readonly color: string;
|
|
1013
|
+
readonly label: string;
|
|
1014
|
+
}
|
|
1015
|
+
/** The unjoined swatch — an OUTLINE, because the map paints no fill there either. */
|
|
1016
|
+
| {
|
|
1017
|
+
readonly kind: "no-data";
|
|
1018
|
+
readonly id: string;
|
|
1019
|
+
readonly color: string;
|
|
1020
|
+
};
|
|
1021
|
+
interface MapScaleResolution {
|
|
1022
|
+
/** Join key → the resolved hex the polygon is filled with. A key absent from this map is unjoined
|
|
1023
|
+
* and is deliberately left unpainted. */
|
|
1024
|
+
readonly colorByKey: ReadonlyMap<string, string>;
|
|
1025
|
+
readonly entries: readonly MapLegendEntry[];
|
|
1026
|
+
/** What the classes actually came out as — the legend renders `bins.length`, never a fixed six,
|
|
1027
|
+
* because tie de-duplication makes the count dynamic. `undefined` for a categorical scale. */
|
|
1028
|
+
readonly bins?: BinResult;
|
|
1029
|
+
/** The denominator's own words, when `rate` is in play — `"per 100,000"`. Carried into the legend
|
|
1030
|
+
* and the popup, or the map lies quietly. */
|
|
1031
|
+
readonly rateSuffix?: number;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
/** The LAYOUT a section draws in — one labelled row per class, or one ramp strip with two ends. */
|
|
1035
|
+
type MapLegendLayout = "stacked" | "compact";
|
|
1036
|
+
/** The COLLAPSE, an axis of its OWN: whether the key has a toggle, and whether it starts collapsed.
|
|
1037
|
+
* `"none"` names the off state rather than leaving it unspellable, and it is the default — a key
|
|
1038
|
+
* that cannot be read at rest is R5 §F1's largest measured visual defect. */
|
|
1039
|
+
type MapLegendCollapse = "none" | "open" | "closed";
|
|
1040
|
+
/** Both axes, when a caller needs to set them together. `AtLeastOne` in the prop makes `{}` a type
|
|
1041
|
+
* error, because an empty object is a second spelling of the default (`useTable`'s `paginate`). */
|
|
1042
|
+
interface MapLegendOptions {
|
|
1043
|
+
/** @default "stacked" */
|
|
1044
|
+
readonly layout?: MapLegendLayout;
|
|
1045
|
+
/** @default "none" */
|
|
1046
|
+
readonly collapse?: MapLegendCollapse;
|
|
1047
|
+
}
|
|
1048
|
+
/** How the whole stack renders. A bare layout is the common case; `"none"` is no legend at all. */
|
|
1049
|
+
type MapLegendDisplay = MapLegendLayout | "none" | AtLeastOne<MapLegendOptions>;
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* Where the ground comes from. **Ours is the STYLE; the DATA is always the caller's.**
|
|
1053
|
+
*
|
|
1054
|
+
* Three members, and the one that used to be here — `kind: "none"`, a flat themed plate with no
|
|
1055
|
+
* geometry at all — is **deleted**. Decision 5b (`50-decisions-log.md`): *"it's a map component, I
|
|
1056
|
+
* want to see a map ALL the time."* A component whose default rendering is "not a map" has the wrong
|
|
1057
|
+
* default, and every measurement in `_research/R5-visual-audit.md` was downstream of that one fact.
|
|
1058
|
+
*
|
|
1059
|
+
* What replaces it is not "nothing, renamed": a caller who genuinely wants a plain ground now brings
|
|
1060
|
+
* an outline and spells it `{ kind: "geojson", land, ground: "page" }` — there is still geometry, and
|
|
1061
|
+
* the polygons still ARE the map. What is gone is the mode where nothing is drawn.
|
|
1062
|
+
*/
|
|
1063
|
+
type MapTileSource = MapSourceBase &
|
|
1064
|
+
/** A TileJSON endpoint — what every hosted provider gives you. */
|
|
1065
|
+
({
|
|
1066
|
+
readonly kind: "tilejson";
|
|
1067
|
+
readonly url: string;
|
|
1068
|
+
}
|
|
1069
|
+
/** Explicit tile URL templates, for a self-hosted build with no TileJSON in front of it. */
|
|
1070
|
+
| {
|
|
1071
|
+
readonly kind: "tiles";
|
|
1072
|
+
readonly tiles: readonly string[];
|
|
1073
|
+
readonly minzoom?: number;
|
|
1074
|
+
readonly maxzoom?: number;
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* **Your own GeoJSON as the ground** — a real cartographic plate, drawn from collections you
|
|
1078
|
+
* already hold. No tiles, no network, no key, and it works on a plane.
|
|
1079
|
+
*
|
|
1080
|
+
* Four strata rather than one plate, because a single land polygon on a page-coloured background
|
|
1081
|
+
* is what made the old showcase read as a failed load: there was nothing to orient against and
|
|
1082
|
+
* ~84% of the canvas was empty. Land + water + boundaries + places is a map.
|
|
1083
|
+
*
|
|
1084
|
+
* It is the same geometry a drill-down `load` resolves to, so a caller who already has an outline
|
|
1085
|
+
* passes it here unchanged — and **the library still ships zero bytes of geometry.**
|
|
1086
|
+
*/
|
|
1087
|
+
| {
|
|
1088
|
+
readonly kind: "geojson";
|
|
1089
|
+
/** The landmass — every landmass in view, not only the subject. A country alone in a blue field
|
|
1090
|
+
* has nothing to orient against; its neighbours are what make it read as a place. */
|
|
1091
|
+
readonly land: MapGeoJson;
|
|
1092
|
+
/** Lakes and inland seas, as FILLS, drawn over the land. The sea is the `ground`, not a
|
|
1093
|
+
* collection. */
|
|
1094
|
+
readonly water?: MapGeoJson;
|
|
1095
|
+
/** Rivers and canals, as LINES. A separate member from `water` because they are a different
|
|
1096
|
+
* geometry with a different paint — a river drawn as a fill is a hairline sliver or nothing. */
|
|
1097
|
+
readonly rivers?: MapGeoJson;
|
|
1098
|
+
/** Internal administrative edges — a second, quieter rank under the coastline. */
|
|
1099
|
+
readonly boundaries?: MapGeoJson;
|
|
1100
|
+
/** International edges, drawn ABOVE `boundaries` in the emphatic role. Needed whenever `land` is
|
|
1101
|
+
* a dissolved multi-country collection: the coastline then traces the continent and nothing
|
|
1102
|
+
* says where one country stops and the next begins. */
|
|
1103
|
+
readonly borders?: MapGeoJson;
|
|
1104
|
+
/**
|
|
1105
|
+
* Populated places, labelled from a `name` property (`name:<lang>` is honoured where present,
|
|
1106
|
+
* exactly as a vector basemap's labels are).
|
|
1107
|
+
*
|
|
1108
|
+
* Two OPTIONAL properties rank them, and both are the house's own names rather than any
|
|
1109
|
+
* provider's: **`capital`** (truthy ⇒ drawn bold and one step larger) and **`rank`** (a number,
|
|
1110
|
+
* **0 = most important**), which drives both the zoom a label first appears at and which label
|
|
1111
|
+
* survives a collision. A collection carrying neither still draws — every place is then rank 0
|
|
1112
|
+
* and the engine's collision is the only hierarchy, which is what shipped before.
|
|
1113
|
+
*/
|
|
1114
|
+
readonly places?: MapGeoJson;
|
|
1115
|
+
/**
|
|
1116
|
+
* A latitude/longitude grid. `"coarse"` is 20°, `"fine"` is 10°.
|
|
1117
|
+
*
|
|
1118
|
+
* Off by default: on a country-sized frame it is noise. On a WORLD frame it is the difference
|
|
1119
|
+
* between a map and a set of shapes — it says the surface is a globe and gives the eye something
|
|
1120
|
+
* to measure position against where there is no other reference.
|
|
1121
|
+
* @default "none"
|
|
1122
|
+
*/
|
|
1123
|
+
readonly graticule?: "none" | "coarse" | "fine";
|
|
1124
|
+
/**
|
|
1125
|
+
* What is NOT land.
|
|
1126
|
+
*
|
|
1127
|
+
* `"water"` — the sea, and the default, because if you are drawing a land plate then what
|
|
1128
|
+
* surrounds it is sea; painting it the page colour is what makes a coastline read as a crop
|
|
1129
|
+
* mark rather than a shore. Decision 5: **water is blue**, and it is one of the two chromatic
|
|
1130
|
+
* exceptions the achromatic-basemap rule already carves out.
|
|
1131
|
+
*
|
|
1132
|
+
* `"page"` — for a plate that is not geography at all: a warehouse floor, a stadium bowl, a
|
|
1133
|
+
* seating chart. There the surround has no meaning and a blue field would invent one.
|
|
1134
|
+
*
|
|
1135
|
+
* A named union rather than a `sea?: boolean`, because the off state is a real answer that
|
|
1136
|
+
* deserves a name (the `OverflowMode` precedent, AGENTS §4).
|
|
1137
|
+
* @default "water"
|
|
1138
|
+
*/
|
|
1139
|
+
readonly ground?: "water" | "page";
|
|
1140
|
+
/**
|
|
1141
|
+
* The coastline/boundary stroke around `land`.
|
|
1142
|
+
*
|
|
1143
|
+
* **`MapOutline`, the same union `choroplethLayer` and `areasLayer` take** — it was a
|
|
1144
|
+
* `boolean` here and a three-member union there, one word asking one question in two shapes,
|
|
1145
|
+
* so a caller who learned `outline: "hairline"` on a layer wrote `outline: true` on the
|
|
1146
|
+
* ground. `"none"` names the off state (the `ground` union two lines up already does), and
|
|
1147
|
+
* the weight axis it gains is real: a plate basemap under a dense choropleth wants
|
|
1148
|
+
* `"hairline"`, one under a single highlighted region wants `"strong"`.
|
|
1149
|
+
* @default "hairline"
|
|
1150
|
+
*/
|
|
1151
|
+
readonly outline?: MapOutline;
|
|
1152
|
+
});
|
|
1153
|
+
/**
|
|
1154
|
+
* What every ground shares, whatever it is made of.
|
|
1155
|
+
*
|
|
1156
|
+
* An intersection rather than a member repeated three times: `glyphs` is a property of the ASSET
|
|
1157
|
+
* HOST, not of the geometry, so it is orthogonal to `kind` — and TypeScript distributes the
|
|
1158
|
+
* intersection over the union, so narrowing on `kind` still works exactly as before.
|
|
1159
|
+
*/
|
|
1160
|
+
interface MapSourceBase {
|
|
1161
|
+
/**
|
|
1162
|
+
* Where the label glyph atlas is served from — a `{fontstack}/{range}.pbf` template.
|
|
1163
|
+
*
|
|
1164
|
+
* **This is the one thing standing between a ground and offline labels.** MapLibre renders text
|
|
1165
|
+
* from SDF atlases it FETCHES; the default is OpenFreeMap's, so a map drawing nothing but the
|
|
1166
|
+
* caller's own GeoJSON still reaches a third party the moment it draws a single place name — or,
|
|
1167
|
+
* behind a firewall, draws none. Point this at a self-hosted subset (ten or so files for Latin +
|
|
1168
|
+
* Thai) and the whole ground is local.
|
|
1169
|
+
*
|
|
1170
|
+
* Genuinely open — it is a URL template with a documented grammar, and no union can describe one.
|
|
1171
|
+
* @default "https://tiles.openfreemap.org/fonts/{fontstack}/{range}.pbf"
|
|
1172
|
+
*/
|
|
1173
|
+
readonly glyphs?: string;
|
|
1174
|
+
}
|
|
1175
|
+
/**
|
|
1176
|
+
* The ground a `<DataMap>` shows when the caller has not chosen one — decision 5b's other half.
|
|
1177
|
+
*
|
|
1178
|
+
* **This is a URL, not data.** "Zero bytes of geometry in the package" is intact: what is added is a
|
|
1179
|
+
* sensible pointer, and the two are different commitments.
|
|
1180
|
+
*
|
|
1181
|
+
* OpenFreeMap is the only tile host that is keyless, accountless and free, which are the three
|
|
1182
|
+
* properties that make a default work *without a decision*. It is also **donation-funded with no
|
|
1183
|
+
* SLA**, so three things ship with it and none is optional: this sentence, the recommendation ladder
|
|
1184
|
+
* in `docs/components/data-map.md`, and a production `dev-warn` when a build is still using it
|
|
1185
|
+
* (`warnDefaultSource` below). Overriding is one prop.
|
|
1186
|
+
*/
|
|
1187
|
+
declare const DEFAULT_MAP_SOURCE: MapTileSource;
|
|
1188
|
+
/** The GeoJSON a `geojson` basemap draws — the same shape a drill-down `load` resolves to, so one
|
|
1189
|
+
* collection serves both and there is no second geometry type to keep in step. */
|
|
1190
|
+
type MapGeoJson = LevelData;
|
|
1191
|
+
|
|
1192
|
+
/** One point, ready to place. `row` is carried through so a popup and a marker renderer get the
|
|
1193
|
+
* caller's own object rather than our copy of three of its fields. */
|
|
1194
|
+
interface ProjectedPoint<Row = unknown> {
|
|
1195
|
+
readonly key: string;
|
|
1196
|
+
readonly position: LngLatTuple;
|
|
1197
|
+
readonly name?: string;
|
|
1198
|
+
readonly tone: MapTone;
|
|
1199
|
+
/** `undefined` when the layer has no `size` — the marker draws at its natural step. */
|
|
1200
|
+
readonly magnitude?: number;
|
|
1201
|
+
readonly row: Row;
|
|
1202
|
+
}
|
|
1203
|
+
/** One route, ready to draw. */
|
|
1204
|
+
interface ProjectedLine<Row = unknown> {
|
|
1205
|
+
readonly key: string;
|
|
1206
|
+
readonly path: readonly LngLatTuple[];
|
|
1207
|
+
readonly name?: string;
|
|
1208
|
+
readonly tone: MapTone;
|
|
1209
|
+
readonly row: Row;
|
|
1210
|
+
}
|
|
1211
|
+
/** One weighted sample for a density surface. */
|
|
1212
|
+
interface ProjectedWeight {
|
|
1213
|
+
readonly position: LngLatTuple;
|
|
1214
|
+
readonly weight: number;
|
|
1215
|
+
}
|
|
1216
|
+
/** What every projection carries, whatever it draws. */
|
|
1217
|
+
interface ProjectionBase {
|
|
1218
|
+
readonly id: string;
|
|
1219
|
+
/** Already resolved: the layer's own `label`, or the kind's word from the labels cascade. */
|
|
1220
|
+
readonly label: string;
|
|
1221
|
+
readonly visible: boolean;
|
|
1222
|
+
readonly opacity: MapOpacity;
|
|
1223
|
+
readonly interactive: boolean;
|
|
1224
|
+
/** How many features this layer is currently PROJECTING. Rendered, not supplied — 15,000 clustered
|
|
1225
|
+
* points render ~60 bubbles — which is why the scale dev-warn and the a11y budget both read it. */
|
|
1226
|
+
readonly renderedCount: number;
|
|
1227
|
+
}
|
|
1228
|
+
type MapLayerProjection = (ProjectionBase & {
|
|
1229
|
+
readonly kind: "choropleth";
|
|
1230
|
+
/** `undefined` before the first level has loaded. */
|
|
1231
|
+
readonly features?: MapGeoJson$1;
|
|
1232
|
+
readonly join?: JoinResult<any>;
|
|
1233
|
+
readonly scale?: MapScaleResolution;
|
|
1234
|
+
readonly joinProperty: string;
|
|
1235
|
+
/** Feature key → display name. Built from the level currently PAINTED, so the popup, the
|
|
1236
|
+
* breadcrumb and the accessible table cannot disagree about what a region is called. */
|
|
1237
|
+
readonly nameByKey: ReadonlyMap<string, string>;
|
|
1238
|
+
readonly format: (value: number) => string;
|
|
1239
|
+
/** The level currently painted — its `label` is what the table's caption says. */
|
|
1240
|
+
readonly level: MapLevel;
|
|
1241
|
+
readonly loading: boolean;
|
|
1242
|
+
readonly error: unknown;
|
|
1243
|
+
readonly canDrill: boolean;
|
|
1244
|
+
}) | (ProjectionBase & {
|
|
1245
|
+
readonly kind: "points";
|
|
1246
|
+
readonly points: readonly ProjectedPoint[];
|
|
1247
|
+
readonly marker: MapMarkerShape;
|
|
1248
|
+
readonly sizeRange: MapSizeRange;
|
|
1249
|
+
/** The measured span of `size.value`, so a bubble's radius is relative to the SET rather than
|
|
1250
|
+
* to an absolute number that means nothing at a different scale. */
|
|
1251
|
+
readonly magnitudeRange?: readonly [number, number];
|
|
1252
|
+
readonly clustered: boolean;
|
|
1253
|
+
}) | (ProjectionBase & {
|
|
1254
|
+
readonly kind: "heatmap";
|
|
1255
|
+
readonly weights: readonly ProjectedWeight[];
|
|
1256
|
+
readonly ramp?: readonly string[];
|
|
1257
|
+
}) | (ProjectionBase & {
|
|
1258
|
+
readonly kind: "lines";
|
|
1259
|
+
readonly lines: readonly ProjectedLine[];
|
|
1260
|
+
readonly weight: MapLineWeight;
|
|
1261
|
+
}) | (ProjectionBase & {
|
|
1262
|
+
readonly kind: "areas";
|
|
1263
|
+
readonly features: MapGeoJson$1;
|
|
1264
|
+
readonly toneByIndex: readonly MapTone[];
|
|
1265
|
+
readonly names: readonly string[];
|
|
1266
|
+
}) | (ProjectionBase & {
|
|
1267
|
+
readonly kind: "raster";
|
|
1268
|
+
});
|
|
1269
|
+
/** The kind's own word, when a layer brought no `label`. Keyed by `MapLayerKind`, so a new member
|
|
1270
|
+
* cannot be added without one. */
|
|
1271
|
+
type MapKindLabels = Readonly<Record<MapLayer["kind"], string>>;
|
|
1272
|
+
|
|
1273
|
+
/** Why there is no map. A named union rather than a `boolean` pair, because the three answers are
|
|
1274
|
+
* mutually exclusive and each one renders differently — `unsupported` is a permanent state with a
|
|
1275
|
+
* static fallback, `error` offers a retry, `loading` offers neither. */
|
|
1276
|
+
type MapEngineStatus = "loading" | "ready" | "unsupported" | "error";
|
|
1277
|
+
|
|
1278
|
+
/**
|
|
1279
|
+
* How the camera opens, and how it frames what it is given.
|
|
1280
|
+
*
|
|
1281
|
+
* ONE object, not `minZoom`/`maxZoom` at the top level — and not only for tidiness: `state:check`
|
|
1282
|
+
* rule 3 compares TOP-LEVEL NAMES between the hook's options and the component's props, so a name
|
|
1283
|
+
* that could plausibly live on both is a collision waiting to be introduced.
|
|
1284
|
+
*/
|
|
1285
|
+
interface MapCameraOptions {
|
|
1286
|
+
readonly center?: LngLatTuple;
|
|
1287
|
+
readonly zoom?: number;
|
|
1288
|
+
readonly bounds?: BoundsTuple;
|
|
1289
|
+
readonly zoomRange?: MapZoomRange;
|
|
1290
|
+
/**
|
|
1291
|
+
* The framing intent — R5 §A, where **~84% of every map canvas was measured as empty** and there
|
|
1292
|
+
* was no way to say "fill the frame".
|
|
1293
|
+
*
|
|
1294
|
+
* `"contain"` fits the whole extent inside the canvas with the chrome cleared (today's only
|
|
1295
|
+
* behaviour). `"cover"` fills the canvas and crops — right for a hero, wrong for a map whose job is
|
|
1296
|
+
* to show that two regions are far apart. `"none"` leaves the camera exactly where `center`/`zoom`
|
|
1297
|
+
* put it, which is what a story with a pinned literal camera needs.
|
|
1298
|
+
* @default "contain"
|
|
1299
|
+
*/
|
|
1300
|
+
readonly fit?: MapFit;
|
|
1301
|
+
/**
|
|
1302
|
+
* How the OPENING FRAME arrives — the once-per-mount fit, and nothing else.
|
|
1303
|
+
*
|
|
1304
|
+
* `"instant"` (the default) paints the map already framed. `"fly"` restores the animated open.
|
|
1305
|
+
*
|
|
1306
|
+
* **The default is static because the animation has nothing true to show.** The engine cannot open
|
|
1307
|
+
* at a bbox — `MapInit` takes only `center`/`zoom` — so a fitted map opens at `[0, 0]` zoom 1 and is
|
|
1308
|
+
* corrected by a `fitBounds` issued after `load`. An arc there does not transition between two
|
|
1309
|
+
* states the reader cares about; it displays the empty Atlantic on the way out of it. Reduced
|
|
1310
|
+
* motion has always taken this path (`resolveFit`); this gives it a name and makes it the default.
|
|
1311
|
+
*
|
|
1312
|
+
* Only the opening move. A reader pressing "fit to data" or "reset" still gets an animation — there
|
|
1313
|
+
* the motion is doing real work, because it says how far the view moved. Under `fit: "cover"` the
|
|
1314
|
+
* animated open is one eased zoom rather than a flyTo curve, since cover is computed rather than
|
|
1315
|
+
* delegated.
|
|
1316
|
+
* @default "instant"
|
|
1317
|
+
*/
|
|
1318
|
+
readonly intro?: MapIntro;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
type MapFit = MapFitFraming | "none";
|
|
1322
|
+
/**
|
|
1323
|
+
* One fit's options.
|
|
1324
|
+
*
|
|
1325
|
+
* **`fit` defaults to `"contain"`, and does NOT inherit `camera.fit`.** That is the whole meaning of
|
|
1326
|
+
* the word: a control called *fit to data* that returns a CROPPED view is not fitting, and under
|
|
1327
|
+
* `camera: { fit: "cover" }` it measurably was not — 25 of 90 markers finished entirely outside the
|
|
1328
|
+
* frame on the hero story. `"cover"` is the OPENING frame's intent, and `resetView` is what restores
|
|
1329
|
+
* it; the reader keeps a control that means "show me everything" and one that means "put it back",
|
|
1330
|
+
* and each does what its name says. _(This REVERSES "the framing intent travels with the fit": the
|
|
1331
|
+
* intent does travel — to the opening frame and to `resetView`, which pass it explicitly.)_
|
|
1332
|
+
*/
|
|
1333
|
+
interface MapFitOptions {
|
|
1334
|
+
/** How this one move looks. Defaults to `"fly"` because a fit a reader asked for is a move they
|
|
1335
|
+
* need to SEE — the arc is what says how far the view went. The opening frame passes `"instant"`. */
|
|
1336
|
+
readonly intro?: MapIntro;
|
|
1337
|
+
/** @default "contain" */
|
|
1338
|
+
readonly fit?: MapFitFraming;
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
/** A numeric bound pair. Exported as an interface rather than left inline, because `props:check`
|
|
1342
|
+
* cannot descend into an inline object literal — and invisibility is not a licence. */
|
|
1343
|
+
interface MapZoomRange {
|
|
1344
|
+
readonly min?: number;
|
|
1345
|
+
readonly max?: number;
|
|
1346
|
+
}
|
|
1347
|
+
interface MapSelectionOptions {
|
|
1348
|
+
/** @default "single" */
|
|
1349
|
+
readonly mode?: "single" | "multiple";
|
|
1350
|
+
/** CONTROLLED selection — a table row hovering a region, R3 row 3's reverse direction. */
|
|
1351
|
+
readonly selected?: readonly MapFeatureRef[];
|
|
1352
|
+
/** `"isolate"` dims everything not selected rather than only outlining what is. @default "outline" */
|
|
1353
|
+
readonly emphasis?: "outline" | "isolate";
|
|
1354
|
+
}
|
|
1355
|
+
interface MapTimeFrame {
|
|
1356
|
+
/** Opaque, and matched by equality against a layer's `frame` accessor. */
|
|
1357
|
+
readonly key: string;
|
|
1358
|
+
/** Already formatted for display — the map never parses a date. */
|
|
1359
|
+
readonly label: string;
|
|
1360
|
+
}
|
|
1361
|
+
interface MapTimeOptions {
|
|
1362
|
+
readonly frames: readonly MapTimeFrame[];
|
|
1363
|
+
readonly defaultFrame?: string;
|
|
1364
|
+
/**
|
|
1365
|
+
* A switch travels with its settings.
|
|
1366
|
+
*
|
|
1367
|
+
* `fps` is genuinely OPEN — frames advance on a wall-clock interval and any positive rate is
|
|
1368
|
+
* meaningful, so no union could express it. It is therefore one of the values `props:check` cannot
|
|
1369
|
+
* reject, and the house rule (AGENTS §4) is that such a prop owes a dev-mode warning wherever a bad
|
|
1370
|
+
* value would otherwise be absorbed: `setInterval(…, 1000 / 0)` is `Infinity`, which never fires,
|
|
1371
|
+
* so the map simply stops advancing and reports nothing at all.
|
|
1372
|
+
*/
|
|
1373
|
+
readonly playback?: false | AtLeastOne<{
|
|
1374
|
+
readonly fps?: number;
|
|
1375
|
+
readonly loop?: boolean;
|
|
1376
|
+
}>;
|
|
1377
|
+
}
|
|
1378
|
+
/**
|
|
1379
|
+
* A feature, addressed.
|
|
1380
|
+
*
|
|
1381
|
+
* **Always layer-qualified.** With N layers a bare feature id is ambiguous — a province code and a
|
|
1382
|
+
* branch id can collide, and the failure is silent: the wrong layer lights up.
|
|
1383
|
+
*/
|
|
1384
|
+
interface MapFeatureRef {
|
|
1385
|
+
readonly layerId: string;
|
|
1386
|
+
readonly featureId: string;
|
|
1387
|
+
}
|
|
1388
|
+
/**
|
|
1389
|
+
* Everything that is not the layer list — shared by the `layers` form and the one-layer shorthand,
|
|
1390
|
+
* so a field can never exist on one and not the other.
|
|
1391
|
+
*/
|
|
1392
|
+
interface UseMapViewBaseOptions {
|
|
1393
|
+
readonly camera?: AtLeastOne<MapCameraOptions>;
|
|
1394
|
+
readonly selection?: false | AtLeastOne<MapSelectionOptions>;
|
|
1395
|
+
readonly time?: false | AtLeastOne<MapTimeOptions>;
|
|
1396
|
+
/**
|
|
1397
|
+
* Reported after the drill **settles**, so a caller mirroring into a URL never records a
|
|
1398
|
+
* speculative frame. The tip of the stack moves at click time and the canvas moves when the data
|
|
1399
|
+
* lands; those are different moments and only the second one is true.
|
|
1400
|
+
*/
|
|
1401
|
+
readonly onDrill?: (frames: readonly DrillFrame[]) => void;
|
|
1402
|
+
/** R3 row 3 — cross-filter OUT to the page, 19 of 38 cards. The highest value-per-line on the list:
|
|
1403
|
+
* it is what makes the map a MEMBER of the dashboard rather than a picture of one. */
|
|
1404
|
+
readonly onSelect?: (refs: readonly MapFeatureRef[]) => void;
|
|
1405
|
+
/** Viewport cross-filter. Fired on SETTLE, never per frame — a per-frame callback recomputing a KPI
|
|
1406
|
+
* is the single easiest way to make a map feel broken. */
|
|
1407
|
+
readonly onCameraSettle?: (camera: CameraPosition, bbox: BoundsTuple) => void;
|
|
1408
|
+
readonly onLayerToggle?: (layerId: string, visible: boolean) => void;
|
|
1409
|
+
}
|
|
1410
|
+
interface UseMapViewOptions extends UseMapViewBaseOptions {
|
|
1411
|
+
/** Ordered back-to-front. A NON-EMPTY tuple — a map with zero layers is not a thing, and the type
|
|
1412
|
+
* says so rather than a runtime guard discovering it. */
|
|
1413
|
+
readonly layers: readonly [MapLayer, ...MapLayer[]];
|
|
1414
|
+
}
|
|
1415
|
+
interface MapLayerState {
|
|
1416
|
+
readonly id: string;
|
|
1417
|
+
readonly label: string;
|
|
1418
|
+
readonly kind: MapLayer["kind"];
|
|
1419
|
+
readonly visible: boolean;
|
|
1420
|
+
readonly opacity: MapOpacity;
|
|
1421
|
+
/** How many features this layer is currently PROJECTING — rendered, not supplied. */
|
|
1422
|
+
readonly renderedCount: number;
|
|
1423
|
+
}
|
|
1424
|
+
interface MapDrillState {
|
|
1425
|
+
readonly frames: readonly DrillFrame[];
|
|
1426
|
+
readonly level: string;
|
|
1427
|
+
/** How deep the data has actually SETTLED, versus how deep the stack claims to be. */
|
|
1428
|
+
readonly settledDepth: number;
|
|
1429
|
+
readonly canDrillUp: boolean;
|
|
1430
|
+
readonly loading: boolean;
|
|
1431
|
+
}
|
|
1432
|
+
interface MapTimeState {
|
|
1433
|
+
readonly frame: string;
|
|
1434
|
+
readonly frames: readonly MapTimeFrame[];
|
|
1435
|
+
readonly playing: boolean;
|
|
1436
|
+
}
|
|
1437
|
+
/** Where `fitTo` is aimed. A union rather than four methods: they are four spellings of one verb. */
|
|
1438
|
+
type MapFitTarget = "data" | {
|
|
1439
|
+
readonly layerId: string;
|
|
1440
|
+
} | {
|
|
1441
|
+
readonly bounds: BoundsTuple;
|
|
1442
|
+
} | {
|
|
1443
|
+
readonly refs: readonly MapFeatureRef[];
|
|
1444
|
+
};
|
|
1445
|
+
interface UseMapViewResult {
|
|
1446
|
+
/**
|
|
1447
|
+
* Live per-layer state — **objects, not a `readonly string[]` of ids.**
|
|
1448
|
+
*
|
|
1449
|
+
* That is a deliberate typing choice rather than an accident: a bare string array is an open type
|
|
1450
|
+
* `props:check` would make us allowlist, and the object carries what a caller actually wants
|
|
1451
|
+
* anyway. The gate pushed the design somewhere better.
|
|
1452
|
+
*/
|
|
1453
|
+
readonly layers: readonly MapLayerState[];
|
|
1454
|
+
readonly camera: CameraPosition;
|
|
1455
|
+
readonly bbox: BoundsTuple;
|
|
1456
|
+
readonly selected: readonly MapFeatureRef[];
|
|
1457
|
+
readonly drill: MapDrillState;
|
|
1458
|
+
readonly time?: MapTimeState;
|
|
1459
|
+
readonly status: MapEngineStatus;
|
|
1460
|
+
setLayerVisible(layerId: string, visible: boolean): void;
|
|
1461
|
+
setLayerOpacity(layerId: string, opacity: MapOpacity): void;
|
|
1462
|
+
select(refs: readonly MapFeatureRef[]): void;
|
|
1463
|
+
clearSelection(): void;
|
|
1464
|
+
drillInto(ref: MapFeatureRef): void;
|
|
1465
|
+
/**
|
|
1466
|
+
* Leave the current level.
|
|
1467
|
+
*
|
|
1468
|
+
* With no argument: up ONE, which is what the back button means. With a `to`, jump straight to
|
|
1469
|
+
* that DEPTH — `0` is the root — which is what makes the breadcrumb a navigation control rather
|
|
1470
|
+
* than a label. It shipped as one-level-only, so a four-level trail took three clicks to get home
|
|
1471
|
+
* and every crumb but the last was an inert `<span>`; a trail you cannot click is a picture of
|
|
1472
|
+
* where you are, not a way back.
|
|
1473
|
+
*/
|
|
1474
|
+
drillUp(to?: number): void;
|
|
1475
|
+
setFrame(key: string): void;
|
|
1476
|
+
setPlaying(playing: boolean): void;
|
|
1477
|
+
setCamera(move: CameraMove): void;
|
|
1478
|
+
/** Frames a target. **CONTAINS by default** — `camera.fit: "cover"` is the opening frame's intent
|
|
1479
|
+
* and does not travel here; `resetView` restores it. See `MapFitOptions`. */
|
|
1480
|
+
fitTo(target: MapFitTarget, options?: MapFitOptions): void;
|
|
1481
|
+
/**
|
|
1482
|
+
* Put the map back how it opened: drill trail to its root, layer overrides dropped, camera to the
|
|
1483
|
+
* OPENING frame. **Not** `fitTo("data")`, which frames whatever is drawn right now — see the
|
|
1484
|
+
* implementation for the one configuration in which the two coincide.
|
|
1485
|
+
*/
|
|
1486
|
+
resetView(): void;
|
|
1487
|
+
/**
|
|
1488
|
+
* **Internal.** The seam `<DataMap>` uses to install the engine and to publish what it computes.
|
|
1489
|
+
*
|
|
1490
|
+
* Not part of the contract and not documented as one — a caller who reaches for it is past the line
|
|
1491
|
+
* the library draws. It is a property rather than a second return value because `state:check`
|
|
1492
|
+
* requires the hook to hand back ONE instance, and an instance that needs unpacking is two.
|
|
1493
|
+
*/
|
|
1494
|
+
readonly internal: MapViewInternal;
|
|
1495
|
+
}
|
|
1496
|
+
/** What the component installs. See `UseMapViewResult.internal`. */
|
|
1497
|
+
interface MapViewBridge {
|
|
1498
|
+
readonly handle: MapHandle;
|
|
1499
|
+
readonly padding: () => PaddingBox;
|
|
1500
|
+
}
|
|
1501
|
+
interface MapViewInternal {
|
|
1502
|
+
readonly projections: readonly MapLayerProjection[];
|
|
1503
|
+
readonly layerSpecs: readonly MapLayer[];
|
|
1504
|
+
readonly selectionMode: "single" | "multiple" | false;
|
|
1505
|
+
readonly emphasis: "outline" | "isolate";
|
|
1506
|
+
readonly cameraOptions: MapCameraOptions;
|
|
1507
|
+
/** Whether the time axis can be PLAYED, as opposed to only scrubbed — `playback: false` leaves the
|
|
1508
|
+
* frames and drops the transport, and a play button that cannot play is worse than none. */
|
|
1509
|
+
readonly playbackEnabled: boolean;
|
|
1510
|
+
attach(bridge: MapViewBridge | undefined): void;
|
|
1511
|
+
setStatus(status: MapEngineStatus): void;
|
|
1512
|
+
/** The kind → word table, published by the component once the labels cascade has resolved. The
|
|
1513
|
+
* hook keeps an English fallback so it stays renderable with no provider at all — which is the
|
|
1514
|
+
* server case, and the case every unit test runs in. */
|
|
1515
|
+
setKindLabels(labels: MapKindLabels): void;
|
|
1516
|
+
reportCamera(camera: CameraPosition, bbox: BoundsTuple, settled: boolean): void;
|
|
1517
|
+
/** The drill's geometry, keyed by layer id — what the painter feeds to the engine. */
|
|
1518
|
+
readonly drillData: ReadonlyMap<string, MapGeoJson$1 | undefined>;
|
|
1519
|
+
/**
|
|
1520
|
+
* The bbox of every VISIBLE layer, or `undefined` while nothing has landed.
|
|
1521
|
+
*
|
|
1522
|
+
* The same answer `fitTo("data")` computes, exposed so `<DataMap>` can hand it to the ENGINE
|
|
1523
|
+
* CONSTRUCTOR — which is the only moment early enough to stop a fitted map painting the Atlantic
|
|
1524
|
+
* first. A method rather than a field because the walk is over every coordinate of every feature,
|
|
1525
|
+
* and the component asks once.
|
|
1526
|
+
*/
|
|
1527
|
+
dataBounds(): BoundsTuple | undefined;
|
|
1528
|
+
}
|
|
1529
|
+
/** The general form: N layers, ordered back-to-front. */
|
|
1530
|
+
declare function useMapView(options: UseMapViewOptions): UseMapViewResult;
|
|
1531
|
+
/** One choropleth — see {@link ShorthandSpecs}. */
|
|
1532
|
+
declare function useMapView<Row>(options: UseMapViewBaseOptions & {
|
|
1533
|
+
readonly choropleth: MapChoroplethLayerSpec<Row>;
|
|
1534
|
+
}): UseMapViewResult;
|
|
1535
|
+
/** One points layer. */
|
|
1536
|
+
declare function useMapView<Row>(options: UseMapViewBaseOptions & {
|
|
1537
|
+
readonly points: MapPointsLayerSpec<Row>;
|
|
1538
|
+
}): UseMapViewResult;
|
|
1539
|
+
/** One heatmap. */
|
|
1540
|
+
declare function useMapView<Row>(options: UseMapViewBaseOptions & {
|
|
1541
|
+
readonly heatmap: MapHeatmapLayerSpec<Row>;
|
|
1542
|
+
}): UseMapViewResult;
|
|
1543
|
+
/** One lines layer. */
|
|
1544
|
+
declare function useMapView<Row>(options: UseMapViewBaseOptions & {
|
|
1545
|
+
readonly lines: MapLinesLayerSpec<Row>;
|
|
1546
|
+
}): UseMapViewResult;
|
|
1547
|
+
/** One areas layer. */
|
|
1548
|
+
declare function useMapView(options: UseMapViewBaseOptions & {
|
|
1549
|
+
readonly areas: MapAreasLayerSpec;
|
|
1550
|
+
}): UseMapViewResult;
|
|
1551
|
+
/** One raster overlay. */
|
|
1552
|
+
declare function useMapView(options: UseMapViewBaseOptions & {
|
|
1553
|
+
readonly raster: MapRasterLayerSpec;
|
|
1554
|
+
}): UseMapViewResult;
|
|
1555
|
+
|
|
1556
|
+
/**
|
|
1557
|
+
* Which chrome the map draws.
|
|
1558
|
+
*
|
|
1559
|
+
* A closed set, all ours. MapLibre's own controls stay unmounted — but the REASON is design
|
|
1560
|
+
* consistency (one focus ring, one icon set, one token vocabulary), not reach: correction C1 found
|
|
1561
|
+
* that `MapOptions.locale` makes the engine's strings perfectly reachable, and we now pass it.
|
|
1562
|
+
*/
|
|
1563
|
+
type MapControl = "zoom" | "reset" | "fitData" | "layers" | "fullscreen" | "scale";
|
|
1564
|
+
type MapTextAlternative = "sr-only" | "visible" | "responsive" | "none";
|
|
1565
|
+
/** What renders when there is no WebGL, and on the server. */
|
|
1566
|
+
type MapFallback = "text" | "none" | {
|
|
1567
|
+
readonly image: string;
|
|
1568
|
+
readonly alt: string;
|
|
1569
|
+
};
|
|
1570
|
+
/**
|
|
1571
|
+
* **Why `onSelect` is omitted, since `DataMapProps` declares none of its own.**
|
|
1572
|
+
*
|
|
1573
|
+
* It is a NAME-COLLISION guard, not a leftover. `onSelect` on a `<div>` is the DOM's text-selection
|
|
1574
|
+
* event; `onSelect` on this component's state channel — `useMapView({ onSelect })` — is *"a feature
|
|
1575
|
+
* was selected"*, which is what anyone writing it here would mean. Leaving the native one spellable
|
|
1576
|
+
* lets a caller write `<DataMap onSelect={…}>`, get no error, and never fire: the wrong event, on the
|
|
1577
|
+
* wrong object, silently. Omitting it turns that into a compile error that points at the hook.
|
|
1578
|
+
*/
|
|
1579
|
+
interface DataMapProps extends Omit<React.ComponentPropsWithoutRef<"div">, "onSelect"> {
|
|
1580
|
+
/**
|
|
1581
|
+
* The BASEMAP.
|
|
1582
|
+
*
|
|
1583
|
+
* **Optional, with a real default** — decision 5b: *"it's a map component, I want to see a map ALL
|
|
1584
|
+
* the time."* A caller who has not yet chosen a tile provider still gets a map. The default is
|
|
1585
|
+
* OpenFreeMap: keyless, accountless, free — and **donation-funded with no SLA**, so set this before
|
|
1586
|
+
* you ship anything load-bearing. `docs/components/data-map.md` carries the provider ladder.
|
|
1587
|
+
*/
|
|
1588
|
+
source?: MapTileSource;
|
|
1589
|
+
/** The one state channel. REQUIRED — an optional instance is a second owner. */
|
|
1590
|
+
view: UseMapViewResult;
|
|
1591
|
+
/**
|
|
1592
|
+
* How the legend stack renders — **two independent axes travelling as one prop**, the way
|
|
1593
|
+
* `useTable`'s `paginate` carries a switch and its settings.
|
|
1594
|
+
*
|
|
1595
|
+
* The LAYOUT (`layout`):
|
|
1596
|
+
* - **`"stacked"`** — one labelled row per class. The full key, and the default.
|
|
1597
|
+
* - **`"compact"`** — the same classes as a contiguous ramp strip with its two ends labelled: three
|
|
1598
|
+
* lines per section instead of `1 + N`, still readable at rest. A no-op on a CATEGORICAL section,
|
|
1599
|
+
* whose classes have no order for two end labels to describe.
|
|
1600
|
+
*
|
|
1601
|
+
* The FOLD (`collapse`), which is a different question and so does NOT live in the same union:
|
|
1602
|
+
* - **`"none"`** (default) — no toggle. R5 §F1 measured a key that cannot be read at rest as the
|
|
1603
|
+
* single highest-value visual defect on the shipped page, so collapsing is opt-in.
|
|
1604
|
+
* - **`"open"`** / **`"closed"`** — a toggle, starting open or collapsed.
|
|
1605
|
+
*
|
|
1606
|
+
* A bare string is the shorthand for that layout with no collapse; `"none"` is no legend at all.
|
|
1607
|
+
*
|
|
1608
|
+
* ```tsx
|
|
1609
|
+
* <DataMap legend="compact" /> // small map, key still readable
|
|
1610
|
+
* <DataMap legend={{ layout: "stacked", collapse: "closed" }} /> // the full key, out of the way
|
|
1611
|
+
* ```
|
|
1612
|
+
* @default "stacked"
|
|
1613
|
+
*/
|
|
1614
|
+
legend?: MapLegendDisplay;
|
|
1615
|
+
/** @default ["zoom", "reset", "fitData", "layers"] */
|
|
1616
|
+
controls?: readonly MapControl[];
|
|
1617
|
+
/**
|
|
1618
|
+
* The time axis's own chrome — play/pause + a scrubber, drawn only when `useMapView({ time })` is
|
|
1619
|
+
* configured. `"none"` for a page that draws its own transport beside the map.
|
|
1620
|
+
*
|
|
1621
|
+
* **Called `transport`, not `time`, and the rename is the point.** `useMapView({ time })` is the
|
|
1622
|
+
* DATA — the frames, which key belongs to which row, whether it plays. This is the WIDGET that
|
|
1623
|
+
* drives it. Both were spelled `time`, so `time="none"` and `time: false` were two different
|
|
1624
|
+
* questions wearing one word, and `pnpm state:check`'s "a prop must not shadow a hook option" rule
|
|
1625
|
+
* could not see the collision (it reads `UseMapViewOptions`, whose snapshot body is only
|
|
1626
|
+
* `{ layers }` — the other seven options live on an unexported base interface).
|
|
1627
|
+
* @default "bar"
|
|
1628
|
+
*/
|
|
1629
|
+
transport?: "bar" | "none";
|
|
1630
|
+
/**
|
|
1631
|
+
* The DOM projection of every layer.
|
|
1632
|
+
*
|
|
1633
|
+
* `"responsive"` is `sr-only` on a fine pointer and `visible` below the breakpoint — because on a
|
|
1634
|
+
* 390px screen a choropleth of 77 provinces is *pixels*, not information, and we are the only map
|
|
1635
|
+
* that holds the rows to offer instead.
|
|
1636
|
+
* @default "sr-only"
|
|
1637
|
+
*/
|
|
1638
|
+
textAlternative?: MapTextAlternative;
|
|
1639
|
+
/** @default "text" */
|
|
1640
|
+
fallback?: MapFallback;
|
|
1641
|
+
/**
|
|
1642
|
+
* How the map takes wheel and touch gestures.
|
|
1643
|
+
*
|
|
1644
|
+
* `"cooperative"` — a wheel scrolls the PAGE unless ⌘/Ctrl is held, and a one-finger drag pans the
|
|
1645
|
+
* page rather than the map; the engine shows its own help text when someone tries. `"direct"` —
|
|
1646
|
+
* the map takes every gesture, which is right when it is the whole viewport and wrong the moment
|
|
1647
|
+
* it is a panel someone has to scroll past.
|
|
1648
|
+
*
|
|
1649
|
+
* A union rather than the `cooperativeGestures?: boolean` it shipped as: `false` is not "off", it
|
|
1650
|
+
* is a second real mode, and the `OverflowMode` precedent (AGENTS §4) says the off state gets a
|
|
1651
|
+
* name. Sibling axes on this component — `legend`, `transport`, `textAlternative`, `fallback` —
|
|
1652
|
+
* all name theirs.
|
|
1653
|
+
* @default "cooperative"
|
|
1654
|
+
*/
|
|
1655
|
+
gestures?: "cooperative" | "direct";
|
|
1656
|
+
/**
|
|
1657
|
+
* The caller's own credit line, printed beside the basemap's — for the DATA, which is always
|
|
1658
|
+
* theirs. Defaults to nothing, because the library has no idea who to credit for it.
|
|
1659
|
+
*
|
|
1660
|
+
* The basemap's own credit is NOT this prop and cannot be turned off: a `tilejson`/`tiles` ground
|
|
1661
|
+
* always prints OSM/ODbL, and `basemapAttribution` is where that is decided. Previously this prop
|
|
1662
|
+
* DEFAULTED to the OSM line, which meant a map drawing the caller's own GeoJSON — no tiles, no
|
|
1663
|
+
* network — credited OpenStreetMap for geometry it had never touched.
|
|
1664
|
+
*/
|
|
1665
|
+
attribution?: string;
|
|
1666
|
+
/** Per-instance copy overrides; wins over the app-wide `<JenosizeUIProvider labels>`. */
|
|
1667
|
+
labels?: MapLabels;
|
|
1668
|
+
/** The narrow house handle — camera, fit, hit test, redraw. Deliberately NOT the MapLibre instance. */
|
|
1669
|
+
onReady?: (handle: MapHandle) => void;
|
|
1670
|
+
}
|
|
1671
|
+
declare function DataMap({ source, view, legend, controls, transport, textAlternative, fallback, gestures, attribution, labels: labelOverrides, onReady, className, ...rest }: DataMapProps): React$1.JSX.Element;
|
|
1672
|
+
|
|
1673
|
+
export { type BinStrategy, type BoundsTuple, type CameraMove, type CameraPosition, DEFAULT_MAP_SOURCE, DataMap, type DataMapProps, type DrillFrame, type FitBoundsMove, type JoinFeature, type LevelData, type LevelFeature, type LngLatTuple, type MapAggregate, type MapAreaFill, type MapAreasLayerSpec, type MapCameraOptions, type MapCategory, type MapChoroplethLayerSpec, type MapClusterOptions, type MapControl, type MapDivergingRamp, type MapDivergingRampName, type MapDrillState, type MapEngineStatus, type MapFallback, type MapFeatureLabels, type MapFeatureRef, type MapFit, type MapFitFraming, type MapFitOptions, type MapFitTarget, type MapGeoJson$1 as MapGeoJson, type MapHandle, type MapHeatRadius, type MapHeatmapLayerSpec, type MapImageCorners, type MapIntro, MapLabels, type MapLayer, type MapLayerBase, type MapLayerKind, type MapLayerLegend, type MapLayerState, type MapLegendCollapse, type MapLegendDisplay, type MapLegendLayout, type MapLegendOptions, type MapLevel, type MapLevels, type MapLineWeight, type MapLinesLayerSpec, type MapMarkerShape, type MapOpacity, type MapOutline, type MapPointsLayerSpec, type MapPointsMode, type MapQuantitativeValue, type MapRamp, type MapRasterLayerSpec, type MapRasterSource, type MapScale, type MapSelectionOptions, type MapSizeRange, type MapStyleMode, type MapStylePart, type MapTextAlternative, type MapTileSource, type MapTimeFrame, type MapTimeOptions, type MapTimeState, type MapTone, type MapViewInternal, type MapZoomRange, type PaddingBox, type RenderedFeature, type UseMapViewBaseOptions, type UseMapViewOptions, type UseMapViewResult, areasLayer, choroplethLayer, heatmapLayer, linesLayer, pointsLayer, rasterLayer, useMapView };
|