@mailwoman/react 9.3.0 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/fonts.css +59 -0
  2. package/lib/common/About.tsx +105 -0
  3. package/lib/common/KindBadge.tsx +2 -7
  4. package/lib/common/confidence-tiers.ts +50 -0
  5. package/lib/common/index.ts +22 -0
  6. package/lib/common/text-tokens.ts +88 -0
  7. package/lib/index.ts +10 -103
  8. package/lib/map/BackendControl.tsx +7 -3
  9. package/lib/map/CompareToggle.tsx +5 -4
  10. package/lib/map/{GeocoderDemo.tsx → Geocoder.tsx} +81 -61
  11. package/lib/map/GeocoderControls.tsx +352 -0
  12. package/lib/map/{DemoMap.tsx → MapCanvas.tsx} +15 -15
  13. package/lib/map/MapChipRow.tsx +77 -0
  14. package/lib/map/MapCompass.tsx +77 -0
  15. package/lib/map/MapControlStack.tsx +98 -0
  16. package/lib/map/MapFooter.tsx +115 -0
  17. package/lib/map/MapProgressBar.tsx +58 -0
  18. package/lib/map/MapSearchBar.tsx +68 -0
  19. package/lib/map/MapSheet.tsx +62 -0
  20. package/lib/map/PlaceMarker.tsx +1 -1
  21. package/lib/map/ResolvedPlaceLayers.tsx +3 -3
  22. package/lib/map/ResultCamera.tsx +1 -1
  23. package/lib/map/ResultPanel.tsx +2 -2
  24. package/lib/map/VersionPicker.tsx +3 -3
  25. package/lib/map/fake-runtime.ts +122 -0
  26. package/lib/map/index.ts +35 -16
  27. package/lib/map/map-debug.ts +51 -0
  28. package/lib/map/place-render.ts +3 -2
  29. package/lib/map/types.ts +58 -42
  30. package/lib/map/{useDemoGeocode.ts → useGeocode.ts} +8 -8
  31. package/lib/map/useMapBearing.ts +56 -0
  32. package/lib/map/useMapLabelPick.ts +123 -0
  33. package/lib/pipeline/CandidatePicker.tsx +1 -1
  34. package/lib/pipeline/ComponentTable.tsx +1 -2
  35. package/lib/pipeline/ConfidenceCell.tsx +7 -19
  36. package/lib/pipeline/FailureDiagnostic.tsx +56 -0
  37. package/lib/pipeline/ResolvedPlace.tsx +17 -4
  38. package/lib/pipeline/SpanHighlight.tsx +97 -0
  39. package/lib/pipeline/TimingPanel.tsx +65 -0
  40. package/lib/pipeline/TreeView.tsx +55 -0
  41. package/lib/pipeline/copy.ts +1 -1
  42. package/lib/pipeline/index.ts +36 -0
  43. package/lib/pipeline/types.ts +2 -75
  44. package/lib/pipeline/useParsePipeline.ts +31 -19
  45. package/lib/poi/index.ts +39 -0
  46. package/lib/poi/types.ts +2 -1
  47. package/lib/runtime/index.ts +16 -0
  48. package/lib/runtime/{useDemoRuntime.ts → useReleaseRuntime.ts} +22 -24
  49. package/out/common/About.d.ts +21 -0
  50. package/out/common/About.d.ts.map +1 -0
  51. package/out/common/About.js +8 -0
  52. package/out/common/About.js.map +1 -0
  53. package/out/common/KindBadge.d.ts +2 -9
  54. package/out/common/KindBadge.d.ts.map +1 -1
  55. package/out/common/KindBadge.js.map +1 -1
  56. package/out/common/confidence-tiers.d.ts +36 -0
  57. package/out/common/confidence-tiers.d.ts.map +1 -0
  58. package/out/common/confidence-tiers.js +42 -0
  59. package/out/common/confidence-tiers.js.map +1 -0
  60. package/out/common/index.d.ts +22 -0
  61. package/out/common/index.d.ts.map +1 -0
  62. package/out/common/index.js +15 -0
  63. package/out/common/index.js.map +1 -0
  64. package/out/common/text-tokens.d.ts +46 -0
  65. package/out/common/text-tokens.d.ts.map +1 -0
  66. package/out/common/text-tokens.js +52 -0
  67. package/out/common/text-tokens.js.map +1 -0
  68. package/out/index.d.ts +5 -51
  69. package/out/index.d.ts.map +1 -1
  70. package/out/index.js +4 -30
  71. package/out/index.js.map +1 -1
  72. package/out/map/BackendControl.d.ts.map +1 -1
  73. package/out/map/BackendControl.js +1 -1
  74. package/out/map/BackendControl.js.map +1 -1
  75. package/out/map/CompareToggle.d.ts +2 -2
  76. package/out/map/CompareToggle.d.ts.map +1 -1
  77. package/out/map/CompareToggle.js +1 -1
  78. package/out/map/CompareToggle.js.map +1 -1
  79. package/out/map/Geocoder.d.ts +67 -0
  80. package/out/map/Geocoder.d.ts.map +1 -0
  81. package/out/map/Geocoder.js +98 -0
  82. package/out/map/Geocoder.js.map +1 -0
  83. package/out/map/GeocoderControls.d.ts +81 -0
  84. package/out/map/GeocoderControls.d.ts.map +1 -0
  85. package/out/map/GeocoderControls.js +79 -0
  86. package/out/map/GeocoderControls.js.map +1 -0
  87. package/out/map/{DemoMap.d.ts → MapCanvas.d.ts} +15 -15
  88. package/out/map/MapCanvas.d.ts.map +1 -0
  89. package/out/map/{DemoMap.js → MapCanvas.js} +2 -2
  90. package/out/map/MapCanvas.js.map +1 -0
  91. package/out/map/MapChipRow.d.ts +47 -0
  92. package/out/map/MapChipRow.d.ts.map +1 -0
  93. package/out/map/MapChipRow.js +12 -0
  94. package/out/map/MapChipRow.js.map +1 -0
  95. package/out/map/MapCompass.d.ts +42 -0
  96. package/out/map/MapCompass.d.ts.map +1 -0
  97. package/out/map/MapCompass.js +11 -0
  98. package/out/map/MapCompass.js.map +1 -0
  99. package/out/map/MapControlStack.d.ts +57 -0
  100. package/out/map/MapControlStack.d.ts.map +1 -0
  101. package/out/map/MapControlStack.js +15 -0
  102. package/out/map/MapControlStack.js.map +1 -0
  103. package/out/map/MapFooter.d.ts +40 -0
  104. package/out/map/MapFooter.d.ts.map +1 -0
  105. package/out/map/MapFooter.js +51 -0
  106. package/out/map/MapFooter.js.map +1 -0
  107. package/out/map/MapProgressBar.d.ts +34 -0
  108. package/out/map/MapProgressBar.d.ts.map +1 -0
  109. package/out/map/MapProgressBar.js +8 -0
  110. package/out/map/MapProgressBar.js.map +1 -0
  111. package/out/map/MapSearchBar.d.ts +49 -0
  112. package/out/map/MapSearchBar.d.ts.map +1 -0
  113. package/out/map/MapSearchBar.js +6 -0
  114. package/out/map/MapSearchBar.js.map +1 -0
  115. package/out/map/MapSheet.d.ts +32 -0
  116. package/out/map/MapSheet.d.ts.map +1 -0
  117. package/out/map/MapSheet.js +33 -0
  118. package/out/map/MapSheet.js.map +1 -0
  119. package/out/map/OverlayLayers.js +1 -1
  120. package/out/map/PlaceMarker.d.ts +1 -1
  121. package/out/map/ResolvedPlaceLayers.d.ts +3 -3
  122. package/out/map/ResolvedPlaceLayers.js +1 -1
  123. package/out/map/ResultCamera.d.ts +1 -1
  124. package/out/map/ResultCamera.js +1 -1
  125. package/out/map/ResultPanel.d.ts +2 -2
  126. package/out/map/ResultPanel.d.ts.map +1 -1
  127. package/out/map/ResultPanel.js +1 -1
  128. package/out/map/ResultPanel.js.map +1 -1
  129. package/out/map/VersionPicker.d.ts +3 -3
  130. package/out/map/VersionPicker.d.ts.map +1 -1
  131. package/out/map/fake-runtime.d.ts +38 -0
  132. package/out/map/fake-runtime.d.ts.map +1 -0
  133. package/out/map/fake-runtime.js +107 -0
  134. package/out/map/fake-runtime.js.map +1 -0
  135. package/out/map/index.d.ts +27 -10
  136. package/out/map/index.d.ts.map +1 -1
  137. package/out/map/index.js +16 -6
  138. package/out/map/index.js.map +1 -1
  139. package/out/map/map-debug.d.ts +31 -0
  140. package/out/map/map-debug.d.ts.map +1 -0
  141. package/out/map/map-debug.js +31 -0
  142. package/out/map/map-debug.js.map +1 -0
  143. package/out/map/place-render.d.ts +2 -2
  144. package/out/map/place-render.d.ts.map +1 -1
  145. package/out/map/place-render.js +1 -1
  146. package/out/map/place-render.js.map +1 -1
  147. package/out/map/types.d.ts +60 -42
  148. package/out/map/types.d.ts.map +1 -1
  149. package/out/map/types.js +5 -5
  150. package/out/map/{useDemoGeocode.d.ts → useGeocode.d.ts} +9 -9
  151. package/out/map/useGeocode.d.ts.map +1 -0
  152. package/out/map/{useDemoGeocode.js → useGeocode.js} +4 -4
  153. package/out/map/useGeocode.js.map +1 -0
  154. package/out/map/useMapBearing.d.ts +28 -0
  155. package/out/map/useMapBearing.d.ts.map +1 -0
  156. package/out/map/useMapBearing.js +35 -0
  157. package/out/map/useMapBearing.js.map +1 -0
  158. package/out/map/useMapLabelPick.d.ts +23 -0
  159. package/out/map/useMapLabelPick.d.ts.map +1 -0
  160. package/out/map/useMapLabelPick.js +104 -0
  161. package/out/map/useMapLabelPick.js.map +1 -0
  162. package/out/pipeline/CandidatePicker.d.ts +1 -1
  163. package/out/pipeline/CandidatePicker.d.ts.map +1 -1
  164. package/out/pipeline/CandidatePicker.js +1 -1
  165. package/out/pipeline/CandidatePicker.js.map +1 -1
  166. package/out/pipeline/ComponentTable.d.ts +1 -1
  167. package/out/pipeline/ComponentTable.d.ts.map +1 -1
  168. package/out/pipeline/ComponentTable.js.map +1 -1
  169. package/out/pipeline/ConfidenceCell.d.ts +2 -2
  170. package/out/pipeline/ConfidenceCell.d.ts.map +1 -1
  171. package/out/pipeline/ConfidenceCell.js +4 -16
  172. package/out/pipeline/ConfidenceCell.js.map +1 -1
  173. package/out/pipeline/FailureDiagnostic.d.ts +15 -0
  174. package/out/pipeline/FailureDiagnostic.d.ts.map +1 -0
  175. package/out/pipeline/FailureDiagnostic.js +21 -0
  176. package/out/pipeline/FailureDiagnostic.js.map +1 -0
  177. package/out/pipeline/PipelineExplorer.js +1 -1
  178. package/out/pipeline/QueryForm.js +1 -1
  179. package/out/pipeline/ResolvedPlace.d.ts +1 -1
  180. package/out/pipeline/ResolvedPlace.d.ts.map +1 -1
  181. package/out/pipeline/ResolvedPlace.js +4 -10
  182. package/out/pipeline/ResolvedPlace.js.map +1 -1
  183. package/out/pipeline/SpanHighlight.d.ts +23 -0
  184. package/out/pipeline/SpanHighlight.d.ts.map +1 -0
  185. package/out/pipeline/SpanHighlight.js +31 -0
  186. package/out/pipeline/SpanHighlight.js.map +1 -0
  187. package/out/pipeline/TimingPanel.d.ts +16 -0
  188. package/out/pipeline/TimingPanel.d.ts.map +1 -0
  189. package/out/pipeline/TimingPanel.js +20 -0
  190. package/out/pipeline/TimingPanel.js.map +1 -0
  191. package/out/pipeline/TreeView.d.ts +17 -0
  192. package/out/pipeline/TreeView.d.ts.map +1 -0
  193. package/out/pipeline/TreeView.js +15 -0
  194. package/out/pipeline/TreeView.js.map +1 -0
  195. package/out/pipeline/copy.d.ts +1 -1
  196. package/out/pipeline/copy.d.ts.map +1 -1
  197. package/out/pipeline/index.d.ts +33 -0
  198. package/out/pipeline/index.d.ts.map +1 -0
  199. package/out/pipeline/index.js +21 -0
  200. package/out/pipeline/index.js.map +1 -0
  201. package/out/pipeline/types.d.ts +2 -68
  202. package/out/pipeline/types.d.ts.map +1 -1
  203. package/out/pipeline/types.js +1 -1
  204. package/out/pipeline/useParsePipeline.d.ts +7 -3
  205. package/out/pipeline/useParsePipeline.d.ts.map +1 -1
  206. package/out/pipeline/useParsePipeline.js +6 -2
  207. package/out/pipeline/useParsePipeline.js.map +1 -1
  208. package/out/poi/LiveResultsBlock.js +1 -1
  209. package/out/poi/POIExplorer.js +1 -1
  210. package/out/poi/SubjectPanel.js +1 -1
  211. package/out/poi/index.d.ts +23 -0
  212. package/out/poi/index.d.ts.map +1 -0
  213. package/out/poi/index.js +15 -0
  214. package/out/poi/index.js.map +1 -0
  215. package/out/poi/runtime.d.ts.map +1 -1
  216. package/out/poi/types.d.ts +2 -1
  217. package/out/poi/types.d.ts.map +1 -1
  218. package/out/runtime/index.d.ts +9 -0
  219. package/out/runtime/index.d.ts.map +1 -0
  220. package/out/runtime/index.js +8 -0
  221. package/out/runtime/index.js.map +1 -0
  222. package/out/runtime/{useDemoRuntime.d.ts → useReleaseRuntime.d.ts} +18 -20
  223. package/out/runtime/useReleaseRuntime.d.ts.map +1 -0
  224. package/out/runtime/{useDemoRuntime.js → useReleaseRuntime.js} +4 -4
  225. package/out/runtime/useReleaseRuntime.js.map +1 -0
  226. package/package.json +222 -31
  227. package/styleframe.config.ts +329 -0
  228. package/styles.css +1995 -663
  229. package/tokens/index.css +116 -0
  230. package/tokens/tokens.json +528 -0
  231. package/tokens/tokens.resolver.json +185 -0
  232. package/lib/map/DemoControls.tsx +0 -194
  233. package/out/map/DemoControls.d.ts +0 -64
  234. package/out/map/DemoControls.d.ts.map +0 -1
  235. package/out/map/DemoControls.js +0 -30
  236. package/out/map/DemoControls.js.map +0 -1
  237. package/out/map/DemoMap.d.ts.map +0 -1
  238. package/out/map/DemoMap.js.map +0 -1
  239. package/out/map/GeocoderDemo.d.ts +0 -57
  240. package/out/map/GeocoderDemo.d.ts.map +0 -1
  241. package/out/map/GeocoderDemo.js +0 -98
  242. package/out/map/GeocoderDemo.js.map +0 -1
  243. package/out/map/useDemoGeocode.d.ts.map +0 -1
  244. package/out/map/useDemoGeocode.js.map +0 -1
  245. package/out/runtime/useDemoRuntime.d.ts.map +0 -1
  246. package/out/runtime/useDemoRuntime.js.map +0 -1
@@ -3,7 +3,7 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * `<DemoMap>` — the declarative map shell for the geocoder demo, over `react-map-gl/maplibre` (v8).
6
+ * `<MapCanvas>` — the declarative map shell for the geocoder demo, over `react-map-gl/maplibre` (v8).
7
7
  * Phase 1 is the shell only: a `<Map>` that takes a host-composed `mapStyle`, an initial (or
8
8
  * controlled) view state, and a `children` slot for the overlays/markers that land in later phases.
9
9
  * No overlay/marker/camera logic lives here yet.
@@ -15,10 +15,10 @@
15
15
  * the root barrel.
16
16
  *
17
17
  * CSS: the package imports no CSS from its modules (the node-safe invariant), so a host that renders
18
- * `<DemoMap>` must import `maplibre-gl/dist/maplibre-gl.css` itself (plus `@mailwoman/react/styles.css`
19
- * for the `.mw-demo-map` container). `<DemoMap>` is intrinsically a client component — a host that
18
+ * `<MapCanvas>` must import `maplibre-gl/dist/maplibre-gl.css` itself (plus `@mailwoman/react/styles.css`
19
+ * for the `.mw-demo-map` container). `<MapCanvas>` is intrinsically a client component — a host that
20
20
  * server-renders should wrap it in a client boundary (the package's `ClientOnly`), exactly as the
21
- * composed `GeocoderDemo` will in a later phase.
21
+ * composed `Geocoder` will in a later phase.
22
22
  */
23
23
 
24
24
  import type { CSSProperties, ReactNode, Ref } from "react"
@@ -26,23 +26,23 @@ import { Map } from "react-map-gl/maplibre"
26
26
  import type { MapProps, MapRef, ViewStateChangeEvent } from "react-map-gl/maplibre"
27
27
 
28
28
  /**
29
- * The style a `<DemoMap>` renders — a style URL or an inline/composed `StyleSpecification`.
29
+ * The style a `<MapCanvas>` renders — a style URL or an inline/composed `StyleSpecification`.
30
30
  */
31
- export type DemoMapStyle = NonNullable<MapProps["mapStyle"]>
31
+ export type MapCanvasStyle = NonNullable<MapProps["mapStyle"]>
32
32
 
33
33
  /**
34
- * Override for the `<Map>` props `<DemoMap>` does not surface explicitly (e.g. `minZoom`, `attributionControl`,
35
- * `maplibreLogo`). The controlled fields DemoMap owns are omitted so they can't be set twice.
34
+ * Override for the `<Map>` props `<MapCanvas>` does not surface explicitly (e.g. `minZoom`, `attributionControl`,
35
+ * `maplibreLogo`). The controlled fields MapCanvas owns are omitted so they can't be set twice.
36
36
  */
37
- export type DemoMapExtraProps = Partial<
37
+ export type MapCanvasExtraProps = Partial<
38
38
  Omit<MapProps, "mapStyle" | "initialViewState" | "viewState" | "onMove" | "children" | "style" | "ref">
39
39
  >
40
40
 
41
- export interface DemoMapProps {
41
+ export interface MapCanvasProps {
42
42
  /**
43
43
  * The map style — host-composed `StyleSpecification` or a style URL.
44
44
  */
45
- mapStyle: DemoMapStyle
45
+ mapStyle: MapCanvasStyle
46
46
  /**
47
47
  * Uncontrolled initial camera. Use this OR `viewState`, not both.
48
48
  */
@@ -76,9 +76,9 @@ export interface DemoMapProps {
76
76
  */
77
77
  style?: CSSProperties
78
78
  /**
79
- * Remaining `<Map>` props DemoMap does not surface explicitly.
79
+ * Remaining `<Map>` props MapCanvas does not surface explicitly.
80
80
  */
81
- mapProps?: DemoMapExtraProps
81
+ mapProps?: MapCanvasExtraProps
82
82
  }
83
83
 
84
84
  const FILL: CSSProperties = { width: "100%", height: "100%" }
@@ -87,7 +87,7 @@ const FILL: CSSProperties = { width: "100%", height: "100%" }
87
87
  * The controlled-viewport map shell. Renders a sized wrapper around a `react-map-gl/maplibre` `<Map>`; everything
88
88
  * host-specific (the composed `mapStyle`, the initial center) is injected, and overlays ride in as `children`.
89
89
  */
90
- export function DemoMap({
90
+ export function MapCanvas({
91
91
  mapStyle,
92
92
  initialViewState,
93
93
  viewState,
@@ -98,7 +98,7 @@ export function DemoMap({
98
98
  className,
99
99
  style,
100
100
  mapProps,
101
- }: DemoMapProps): ReactNode {
101
+ }: MapCanvasProps): ReactNode {
102
102
  const wrapperClassName = className ? `mw-demo-map ${className}` : "mw-demo-map"
103
103
 
104
104
  return (
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * `<MapChipRow>` — the row of example queries under a search bar.
7
+ *
8
+ * It SCROLLS horizontally and never wraps. Earth's twelve examples wrapped down five ragged rows (3/3/2/1/1/1) and
9
+ * took a third of the panel; one scrolling line is the shape the reference map apps use, and it costs a fixed
10
+ * height whatever the number of examples.
11
+ *
12
+ * NODE-SAFE: pure React, no maplibre.
13
+ */
14
+
15
+ import type { ReactNode } from "react"
16
+
17
+ import { cx } from "#common/cx"
18
+
19
+ export interface MapChip {
20
+ /**
21
+ * What the chip reads.
22
+ */
23
+ label: string
24
+ /**
25
+ * The query the chip stands for, handed back on press. Defaults to the label.
26
+ */
27
+ value?: string
28
+ /**
29
+ * Rendered before the label — a category mark.
30
+ */
31
+ icon?: ReactNode
32
+ }
33
+
34
+ export interface MapChipRowProps {
35
+ chips: MapChip[]
36
+ /**
37
+ * Fired with the chip's `value` (or its label) when one is pressed.
38
+ */
39
+ onPick: (value: string) => void
40
+ /**
41
+ * The chip matching this value reads as pressed.
42
+ */
43
+ activeValue?: string
44
+ disabled?: boolean
45
+ className?: string
46
+ /**
47
+ * Accessible name for the row, e.g. "Example addresses".
48
+ */
49
+ label?: string
50
+ }
51
+
52
+ export function MapChipRow({ chips, onPick, activeValue, disabled, className, label }: MapChipRowProps): ReactNode {
53
+ if (!chips.length) return null
54
+
55
+ return (
56
+ <div className={cx("mw-map-chiprow", className)} role="group" aria-label={label}>
57
+ {chips.map((chip) => {
58
+ const value = chip.value ?? chip.label
59
+ const active = value === activeValue
60
+
61
+ return (
62
+ <button
63
+ key={value}
64
+ type="button"
65
+ className={cx("mw-map-chip", active && "mw-map-chip--active")}
66
+ aria-pressed={active}
67
+ disabled={disabled}
68
+ onClick={() => onPick(value)}
69
+ >
70
+ {chip.icon ? <span className="mw-map-chip__icon">{chip.icon}</span> : null}
71
+ {chip.label}
72
+ </button>
73
+ )
74
+ })}
75
+ </div>
76
+ )
77
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * `<MapCompass>` — the needle that appears when the map leaves north and fades out when it returns.
7
+ *
8
+ * It is a compass ROSE, the way the reference map apps draw it: a ringed dial carrying a two-tone needle whose red
9
+ * half points north and whose pale half points south. A single-color arrow cannot say which end is north, so a
10
+ * reader has to already know the convention to read it; two tones say it outright. There is no `N` on the dial —
11
+ * at this size the letter and the needle's north tip want the same few pixels, and the tip is the clearer of them.
12
+ *
13
+ * The whole dial counter-rotates the bearing, so the needle keeps pointing at true north while the map turns under
14
+ * it. Pressing it returns the map to north, which is why the control is a button rather than an ornament.
15
+ *
16
+ * It stays mounted through the fade rather than unmounting on the bearing crossing zero, because a control that
17
+ * vanishes mid-gesture is the thing that reads as a glitch. `HIDE_BELOW_DEGREES` is the dead zone: a map settled by
18
+ * a snap-to-north lands a fraction off zero, and a compass that lingers over that fraction never goes away.
19
+ *
20
+ * Under `prefers-reduced-motion` it appears and disappears with no transition, and the dial still rotates —
21
+ * rotation IS the information, not decoration.
22
+ *
23
+ * NODE-SAFE: pure React, no maplibre. The host reads the bearing off its own map and passes it in.
24
+ */
25
+
26
+ import type { ReactNode } from "react"
27
+
28
+ import { cx } from "#common/cx"
29
+
30
+ /**
31
+ * Below this many degrees off north the compass is treated as pointing north and fades out.
32
+ */
33
+ const HIDE_BELOW_DEGREES = 0.5
34
+
35
+ export interface MapCompassProps {
36
+ /**
37
+ * The map's bearing in degrees, as MapLibre reports it: 0 is north, positive is counter-clockwise.
38
+ */
39
+ bearing: number
40
+ /**
41
+ * Fired when the compass is pressed — the host resets its map to north.
42
+ */
43
+ onResetNorth: () => void
44
+ /**
45
+ * The control's accessible name. @default "Reset bearing to north"
46
+ */
47
+ label?: string
48
+ className?: string
49
+ }
50
+
51
+ export function MapCompass({ bearing, onResetNorth, label, className }: MapCompassProps): ReactNode {
52
+ const facingNorth = Math.abs(bearing) < HIDE_BELOW_DEGREES
53
+
54
+ return (
55
+ <button
56
+ type="button"
57
+ className={cx("mw-map-compass", facingNorth && "mw-map-compass--north", className)}
58
+ aria-label={label ?? "Reset bearing to north"}
59
+ title={label ?? "Reset bearing to north"}
60
+ // Out of the tab order and out of the accessibility tree while it is invisible, so a keyboard reaches only
61
+ // the controls a pointer can see.
62
+ aria-hidden={facingNorth}
63
+ tabIndex={facingNorth ? -1 : 0}
64
+ onClick={onResetNorth}
65
+ >
66
+ <svg viewBox="0 0 32 32" width="26" height="26" aria-hidden="true" focusable="false">
67
+ <g style={{ transform: `rotate(${-bearing}deg)`, transformOrigin: "16px 16px" }}>
68
+ <circle cx="16" cy="16" r="12.5" className="mw-map-compass__dial" />
69
+
70
+ {/* North, then south. Two triangles meeting at the hub rather than one arrow through it. */}
71
+ <path d="M16 5.5 L20.5 16 L16 16 Z M16 5.5 L11.5 16 L16 16 Z" className="mw-map-compass__north" />
72
+ <path d="M16 26.5 L20.5 16 L16 16 Z M16 26.5 L11.5 16 L16 16 Z" className="mw-map-compass__south" />
73
+ </g>
74
+ </svg>
75
+ </button>
76
+ )
77
+ }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * `<MapControlStack>` — the column of map controls down one edge, and `<MapControlButton>`, the control inside it.
7
+ *
8
+ * Controls sit in GROUPS: a group is one glass capsule with hairlines between its buttons, and separate groups are
9
+ * separate capsules with a gap. That grouping is the whole layout idea — related controls read as one object, and
10
+ * an unrelated one (a compass that comes and goes) does not join a capsule it would resize.
11
+ *
12
+ * NODE-SAFE: pure React, no maplibre.
13
+ */
14
+
15
+ import type { ReactNode } from "react"
16
+
17
+ import { cx } from "#common/cx"
18
+
19
+ export interface MapControlButtonProps {
20
+ /**
21
+ * The mark inside the control — an SVG icon or a single glyph.
22
+ */
23
+ children: ReactNode
24
+ /**
25
+ * The control's accessible name. Required: the visible content is a mark, not a word.
26
+ */
27
+ label: string
28
+ onPress: () => void
29
+ /**
30
+ * Reads as active, for a control that toggles a layer or a mode.
31
+ */
32
+ active?: boolean
33
+ disabled?: boolean
34
+ className?: string
35
+ }
36
+
37
+ export function MapControlButton({
38
+ children,
39
+ label,
40
+ onPress,
41
+ active,
42
+ disabled,
43
+ className,
44
+ }: MapControlButtonProps): ReactNode {
45
+ return (
46
+ <button
47
+ type="button"
48
+ className={cx("mw-map-control", active && "mw-map-control--active", className)}
49
+ aria-label={label}
50
+ aria-pressed={active}
51
+ title={label}
52
+ disabled={disabled}
53
+ onClick={onPress}
54
+ >
55
+ {children}
56
+ </button>
57
+ )
58
+ }
59
+
60
+ export interface MapControlGroupProps {
61
+ children: ReactNode
62
+ className?: string
63
+ }
64
+
65
+ /**
66
+ * One capsule. Put related controls in the same group; give an unrelated one its own.
67
+ */
68
+ export function MapControlGroup({ children, className }: MapControlGroupProps): ReactNode {
69
+ return <div className={cx("mw-map-control-group", className)}>{children}</div>
70
+ }
71
+
72
+ export interface MapControlStackProps {
73
+ /**
74
+ * Groups, top to bottom.
75
+ */
76
+ children: ReactNode
77
+ /**
78
+ * Which edge the column sits against. @default "right"
79
+ */
80
+ side?: "left" | "right"
81
+ className?: string
82
+ /**
83
+ * Accessible name for the column, e.g. "Map controls".
84
+ */
85
+ label?: string
86
+ }
87
+
88
+ export function MapControlStack({ children, side = "right", className, label }: MapControlStackProps): ReactNode {
89
+ return (
90
+ <div
91
+ className={cx("mw-map-control-stack", `mw-map-control-stack--${side}`, className)}
92
+ role="group"
93
+ aria-label={label}
94
+ >
95
+ {children}
96
+ </div>
97
+ )
98
+ }
@@ -0,0 +1,115 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * `<MapFooter>` — the strip along the bottom of a map: identity and load status on the left, an attribution button
7
+ * on the right.
8
+ *
9
+ * Attribution is a licence obligation for every source these apps draw, so it is a first-class slot rather than
10
+ * something an app remembers to add. It sits behind a button because the strip has to stay ONE line: spelled out, the
11
+ * credits ran three lines deep on a phone and covered the sheet above them. The button names the obligation, and
12
+ * pressing it shows every credit — which is the treatment the reference map apps use.
13
+ *
14
+ * The status slot is where the loader says WHAT it is fetching while the bar at the top of the viewport says how far
15
+ * along it is.
16
+ *
17
+ * NODE-SAFE: pure React, no maplibre.
18
+ */
19
+
20
+ import { type ReactNode, useEffect, useId, useRef, useState } from "react"
21
+
22
+ import { cx } from "#common/cx"
23
+
24
+ export interface MapFooterProps {
25
+ /**
26
+ * The left side: a wordmark, a body name, a line saying what the page does.
27
+ */
28
+ identity?: ReactNode
29
+ /**
30
+ * Beside the identity: what is loading right now. Absent when nothing is.
31
+ */
32
+ status?: ReactNode
33
+ /**
34
+ * The credits, one entry per source. Shown in the popover the attribution button opens.
35
+ */
36
+ attribution?: ReactNode[]
37
+ /**
38
+ * What the attribution button reads. @default "Sources"
39
+ */
40
+ attributionLabel?: string
41
+ className?: string
42
+ }
43
+
44
+ export function MapFooter({
45
+ identity,
46
+ status,
47
+ attribution,
48
+ attributionLabel = "Sources",
49
+ className,
50
+ }: MapFooterProps): ReactNode {
51
+ const [open, setOpen] = useState(false)
52
+ const popoverID = useId()
53
+ const root = useRef<HTMLElement>(null)
54
+
55
+ // A popover closes when the conversation moves elsewhere: a press outside it, or Escape.
56
+ useEffect(() => {
57
+ if (!open) return
58
+
59
+ const onPointerDown = (event: PointerEvent) => {
60
+ if (!root.current?.contains(event.target as Node)) {
61
+ setOpen(false)
62
+ }
63
+ }
64
+
65
+ const onKeyDown = (event: KeyboardEvent) => {
66
+ if (event.key === "Escape") {
67
+ setOpen(false)
68
+ }
69
+ }
70
+
71
+ document.addEventListener("pointerdown", onPointerDown)
72
+ document.addEventListener("keydown", onKeyDown)
73
+
74
+ return () => {
75
+ document.removeEventListener("pointerdown", onPointerDown)
76
+ document.removeEventListener("keydown", onKeyDown)
77
+ }
78
+ }, [open])
79
+
80
+ if (!identity && !status && !attribution?.length) return null
81
+
82
+ return (
83
+ <footer className={cx("mw-map-footer", className)} ref={root}>
84
+ <div className="mw-map-footer__identity">
85
+ {identity}
86
+ {status ? <span className="mw-map-footer__status">{status}</span> : null}
87
+ </div>
88
+
89
+ {attribution?.length ? (
90
+ <div className="mw-map-footer__sources">
91
+ {open ? (
92
+ <div className="mw-map-footer__popover" id={popoverID} role="group" aria-label="Map data sources">
93
+ {attribution.map((entry, index) => (
94
+ // The entries are a fixed, ordered credit list that never reorders, so position is the identity.
95
+ <span key={index} className="mw-map-footer__credit">
96
+ {entry}
97
+ </span>
98
+ ))}
99
+ </div>
100
+ ) : null}
101
+
102
+ <button
103
+ type="button"
104
+ className="mw-map-footer__attribution-button"
105
+ aria-expanded={open}
106
+ aria-controls={open ? popoverID : undefined}
107
+ onClick={() => setOpen((value) => !value)}
108
+ >
109
+ {attributionLabel}
110
+ </button>
111
+ </div>
112
+ ) : null}
113
+ </footer>
114
+ )
115
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * `<MapProgressBar>` — the loading bar pinned across the top of the viewport.
7
+ *
8
+ * Loading a 38 MB model is a page-level event, not a control-level one, so it reports at the page's edge rather than
9
+ * inside the search field: a spinner in the field resizes the one control a visitor is trying to type into, and a
10
+ * staged list in the result sheet claims the space an answer will need.
11
+ *
12
+ * It reports a FRACTION when the loader names its steps and runs indeterminate when it does not, because a bar that
13
+ * invents a percentage is worse than one that admits it is only saying "still working".
14
+ *
15
+ * NODE-SAFE: pure React, no maplibre.
16
+ */
17
+
18
+ import type { ReactNode } from "react"
19
+
20
+ import { cx } from "#common/cx"
21
+
22
+ export interface MapProgressBarProps {
23
+ /**
24
+ * Whether the bar is showing at all. It stays mounted through its fade rather than unmounting on the transition.
25
+ */
26
+ active: boolean
27
+ /**
28
+ * Completed steps over total steps, in [0, 1]. Omit for work whose length is unknown.
29
+ */
30
+ fraction?: number | null
31
+ /**
32
+ * The bar's accessible name — what is loading, in a few words.
33
+ */
34
+ label: string
35
+ className?: string
36
+ }
37
+
38
+ export function MapProgressBar({ active, fraction, label, className }: MapProgressBarProps): ReactNode {
39
+ const determinate = typeof fraction === "number" && Number.isFinite(fraction)
40
+ const clamped = determinate ? Math.min(1, Math.max(0, fraction)) : 0
41
+
42
+ return (
43
+ <div
44
+ className={cx("mw-map-progress", !active && "mw-map-progress--idle", className)}
45
+ role="progressbar"
46
+ aria-label={label}
47
+ aria-hidden={!active}
48
+ aria-valuemin={determinate ? 0 : undefined}
49
+ aria-valuemax={determinate ? 100 : undefined}
50
+ aria-valuenow={determinate ? Math.round(clamped * 100) : undefined}
51
+ >
52
+ <div
53
+ className={cx("mw-map-progress__fill", !determinate && "mw-map-progress__fill--indeterminate")}
54
+ style={determinate ? { transform: `scaleX(${clamped})` } : undefined}
55
+ />
56
+ </div>
57
+ )
58
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * `<MapSearchBar>` — the floating search pill that sits over a map. Presentational only: it supplies the glass
7
+ * material, the pill shape and the two icon slots, and the host supplies the input and whatever backend answers it.
8
+ * Earth searches an address through the geocoder runtime and the planetary apps search a nomenclature artifact, so
9
+ * nothing about the query belongs here.
10
+ *
11
+ * The slots are elements rather than icon names because a leading mark and a trailing control differ per app — a
12
+ * magnifier on one, a body glyph on another.
13
+ *
14
+ * BUSY IS A LINE, NOT A SLOT. A spinner placed in the trailing slot changed the pill's height on every submit,
15
+ * because a slot is laid out and an indicator is not part of the query. `busy` draws a hairline across the pill's
16
+ * lower edge instead, which costs no layout. A host that wants `type="search"` also gets the browser's own clear
17
+ * button in that corner, and two crosses side by side is one control too many.
18
+ *
19
+ * NODE-SAFE: pure React, no maplibre.
20
+ */
21
+
22
+ import type { ReactNode } from "react"
23
+
24
+ import { cx } from "#common/cx"
25
+
26
+ export interface MapSearchBarProps {
27
+ /**
28
+ * The input (or combobox) the host owns. Rendered between the two slots.
29
+ */
30
+ children: ReactNode
31
+ /**
32
+ * Rendered before the input — a magnifier, a body mark, a back arrow.
33
+ */
34
+ leading?: ReactNode
35
+ /**
36
+ * Rendered after the input — a microphone, a menu. Not a spinner: pass {@link busy} instead.
37
+ */
38
+ trailing?: ReactNode
39
+ /**
40
+ * A query is running. Draws a progress hairline along the pill's lower edge, which takes no layout.
41
+ */
42
+ busy?: boolean
43
+ /**
44
+ * Extra class on the pill.
45
+ */
46
+ className?: string
47
+ /**
48
+ * Accessible name for the surrounding region, when the bar is the app's primary search.
49
+ */
50
+ label?: string
51
+ }
52
+
53
+ export function MapSearchBar({ children, leading, trailing, busy, className, label }: MapSearchBarProps): ReactNode {
54
+ return (
55
+ <div
56
+ className={cx("mw-map-searchbar", busy && "mw-map-searchbar--busy", className)}
57
+ role={label ? "search" : undefined}
58
+ aria-label={label}
59
+ aria-busy={busy}
60
+ >
61
+ {leading ? <span className="mw-map-searchbar__slot mw-map-searchbar__slot--leading">{leading}</span> : null}
62
+
63
+ <span className="mw-map-searchbar__field">{children}</span>
64
+
65
+ {trailing ? <span className="mw-map-searchbar__slot mw-map-searchbar__slot--trailing">{trailing}</span> : null}
66
+ </div>
67
+ )
68
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * `<MapSheet>` — a side panel over the map: a title, a close button, and content.
7
+ *
8
+ * The close button is not optional. On a wide screen the control that opened the sheet stays visible beside it and
9
+ * could close it again, but on a phone the sheet is the whole panel and covers that control — so a sheet without its
10
+ * own close is a sheet a phone cannot dismiss. One component carries it so the four sheets in these apps cannot
11
+ * disagree about that.
12
+ *
13
+ * Escape closes it too, because a panel over the whole screen is a modal in every way that matters to someone
14
+ * holding a keyboard.
15
+ *
16
+ * NODE-SAFE: pure React, no maplibre.
17
+ */
18
+
19
+ import { type ReactNode, useEffect } from "react"
20
+
21
+ import { cx } from "#common/cx"
22
+
23
+ export interface MapSheetProps {
24
+ /**
25
+ * The sheet's heading, and its accessible name.
26
+ */
27
+ title: string
28
+ /**
29
+ * Dismiss the sheet.
30
+ */
31
+ onClose: () => void
32
+ children: ReactNode
33
+ className?: string
34
+ }
35
+
36
+ export function MapSheet({ title, onClose, children, className }: MapSheetProps): ReactNode {
37
+ useEffect(() => {
38
+ const onKeyDown = (event: KeyboardEvent) => {
39
+ if (event.key === "Escape") {
40
+ onClose()
41
+ }
42
+ }
43
+
44
+ document.addEventListener("keydown", onKeyDown)
45
+
46
+ return () => document.removeEventListener("keydown", onKeyDown)
47
+ }, [onClose])
48
+
49
+ return (
50
+ <aside className={cx("mw-map-sheet mw-map-sheet--side", className)} aria-label={title}>
51
+ <div className="mw-map-sheet__header">
52
+ <h2 className="mw-map-sheet__title">{title}</h2>
53
+
54
+ <button type="button" className="mw-map-sheet__close" aria-label={`Close ${title}`} onClick={onClose}>
55
+ <span aria-hidden="true">×</span>
56
+ </button>
57
+ </div>
58
+
59
+ <div className="mw-map-sheet__body">{children}</div>
60
+ </aside>
61
+ )
62
+ }
@@ -6,7 +6,7 @@
6
6
  * `<PlaceMarker>` — the resolved-place pin, as a declarative `react-map-gl/maplibre` `<Marker>`. This
7
7
  * replaces the old imperative `new maplibre.Marker(...).setLngLat(...).addTo(map)` (+ the manual
8
8
  * `markerRef.current.remove()` teardown) from the demo's redraw effect: mounting/unmounting the marker
9
- * is now React's job, keyed on the resolved candidate. Renders as a child of `<DemoMap>`.
9
+ * is now React's job, keyed on the resolved candidate. Renders as a child of `<MapCanvas>`.
10
10
  *
11
11
  * NODE-IMPORT SAFETY: imports `react-map-gl/maplibre` at module scope, so it is reachable ONLY through
12
12
  * the `@mailwoman/react/map` subpath, never the package root.
@@ -3,10 +3,10 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * `<ResolvedPlaceLayers>` — the drop-in that renders a whole {@link MapPlaceRenderSpec} as `<DemoMap>`
6
+ * `<ResolvedPlaceLayers>` — the drop-in that renders a whole {@link MapPlaceRenderSpec} as `<MapCanvas>`
7
7
  * children: the marker(s), the outline, and (optionally) the camera move. This is the declarative
8
8
  * replacement for the demo's imperative marker/bbox/camera redraw effect — a consumer computes the spec
9
- * with `useMapPlaceRender(place)` and drops `<ResolvedPlaceLayers spec={spec} />` inside `<DemoMap>`.
9
+ * with `useMapPlaceRender(place)` and drops `<ResolvedPlaceLayers spec={spec} />` inside `<MapCanvas>`.
10
10
  *
11
11
  * `spec = null` (no result / no candidate) renders nothing, which also unmounts the previous marker +
12
12
  * outline — the teardown the old effect did by hand (`markerRef.remove()`, `clearBbox`) is now just
@@ -28,7 +28,7 @@ export interface ResolvedPlaceLayersProps {
28
28
  spec: MapPlaceRenderSpec | null
29
29
  /**
30
30
  * Apply the computed camera target via {@link ResultCamera}. @default true. Set false when the consumer drives the
31
- * camera itself (e.g. a controlled `<DemoMap viewState>` fed by {@link cameraToViewState}).
31
+ * camera itself (e.g. a controlled `<MapCanvas viewState>` fed by {@link cameraToViewState}).
32
32
  */
33
33
  applyCamera?: boolean
34
34
  /**
@@ -11,7 +11,7 @@
11
11
  * `useMap()` (exactly as `DashboardMap`/`GeoJSONClipboardLayer` reach the map), never a threaded handle.
12
12
  *
13
13
  * A consumer that prefers a hard, declarative jump can instead feed the target through
14
- * {@link cameraToViewState} into a controlled `<DemoMap viewState>` and skip this component — the
14
+ * {@link cameraToViewState} into a controlled `<MapCanvas viewState>` and skip this component — the
15
15
  * `center` case has that declarative path; only `bounds` strictly requires this. Renders nothing.
16
16
  *
17
17
  * `target` is expected to be the STABLE, memoized `camera` off a `useMapPlaceRender` spec, so listing it