Part of [Design system](https://docs.mapcairn.com/design.md), which is built from [DESIGN.md](https://github.com/MapCairn/mapcairn/blob/main/DESIGN.md) in the repository, where it is edited.

| Component                              | Contract                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Switch`, `Slider`, `SegmentedControl` | Radix primitives wrapped in our own components, with visible labels and values. A checked `Switch` draws its thumb in `accentContrast` on the `accent` track and its tick in `accent` on the thumb, so both reach the `accentContrast` on `accent` pair (about 7.2:1 light and 10.3:1 dark), above the 3:1 WCAG 2.2 1.4.11 asks of the parts of a control that show state; an unchecked one draws the `controlBoundary` thumb and edge on the raised surface, a pair the table holds to 3:1. `switch-contrast.spec.ts` reads the rendered colours in both themes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| Map shape                              | A `SegmentedControl` named "Map shape" in Settings, between Units and Show zoom buttons, with Flat and Globe (`data-testid` `projection-option-flat` and `projection-option-globe`). Flat is the default and the choice is stored with the other settings. The control behaves as any other segmented control (a radio group, arrow keys move between the two) and announces the change once, politely, through `LiveRegion` ("Map shape: globe"). Choosing Globe redraws the map as a globe at the same view and zoom, still north-up, with the space around it in map-globe-space. A stored globe is known before the app mounts (the pre-paint script marks the root with `data-map-shape="globe"`), so the placeholder is that colour from the first paint and never flashes the flat map's pale ground. Long measure lines and drawn edges follow the great circle on a globe and stop at the horizon; the pin, vertices, handles and directions stops are left out where they are on the far side, and a shape is filled only while all of its outline is in sight. On either shape, a line across the antimeridian is drawn the short way. The scale bar reads the same on both shapes at the same view.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| Language                               | A `SegmentedControl` named "Language" in Settings, after Map shape, with Automatic (follow the browser) and one item per language the host offers (`data-testid` `language-option-auto` and `language-option-<tag>`). It shows only when the host offers more than one language. Each language is named in its own language (an endonym, from the host's `LanguageCatalogue`) and its item carries `lang`, so a screen reader pronounces it correctly whichever language the interface is in; Automatic is written in the interface's language. A stored language the host no longer offers shows as Automatic. Changing it swaps the interface text without a reload and sets `<html lang>`. When the messages for the chosen language fail to load, the interface stays in the language it was in and that language shows as selected, and under the control sits a status (`data-testid` `language-status`): a warning icon and "Afrikaans could not be loaded." in the danger colour, then a secondary "Try again" button (`language-retry`). The words are in the language still on screen and name the failed language by its own name. The status is plain text; the failure is announced once, politely, through `LiveRegion` (sent with `keep`) when it first appears while the Language control is on screen (a failure while Settings is closed is announced when it opens), and a second failure of the same language is not announced again. Try again stays in place while it retries, busy, so focus stays on it; when the language loads the status goes, the interface changes language, and focus moves to the selected language if Try again had it and the person has not moved it elsewhere. Choosing the failed language in the control again retries it too, and stores it as the choice when the failure came from Automatic. The status shows only for a failed load, never for a host with no languages.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `Tooltip`                              | Supplements a name, never replaces one. Opens on focus and hover, closes on Escape, absent on touch.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `LayersSection`                        | A region named "Layers" with an h4 per group and a list of layers. Each layer is a `Switch` (name and description). While it is on: a status line (Loading, "Updated 14:05, 43 shown", the layer's empty text, an error with an icon, words and Try again (a network failure that happened while the browser said the device was offline reads "Could not load. You are offline." and says it politely, once, because the connection notice has already said the rest; it reads as the plain network failure again once the connection returns, and a response that was wrong keeps its wording), for a layer outside its zoom window the level to zoom to (see "Zoom window status" below), or for a tile layer that is still waiting for its first tile or none of whose tiles loaded, the tile layer status below), its controls (segmented, switch, a native date input bounded by `min` and `max`, a date and time control, an opacity slider, a range slider), a legend list named "Key for ..." with the same glyphs as the map, then, for a layer that is on, has an `identify` block and shows imagery (the same tests `identifyAt` makes before it looks at `bounds`, in `answersTap`), the muted line "Tap the map to see details for this layer.", the disclaimer with an icon, and a `details` list of what loaded. When more than `MAX_IDENTIFY_LAYERS` (4) such layers are on, one muted line above the groups says "Only the first 4 layers are asked on one tap.". Both are drawn from the definitions, so they are approximate in two ways: a tap outside a layer's `bounds` does not ask it, and a host that defines an identify layer without calling `identifyAt` (the SDK does not know whether it did) still shows them. Controls whose condition is not met are disabled, not hidden. Loads, empty feeds and failures are announced once each through `LiveRegion`. Above the groups sits "Turn off all layers", a secondary button that shows how many layers are on ("3 on", in `tabular-nums`) and is disabled with `aria-disabled`, never hidden, when none is; each group's heading has "Turn off N in `<group name>`" at its end, shown only while the group has layers on. Neither asks for confirmation, and the buttons stay while the Undo shows. Pressing one turns its layers off in one change (one redraw, one address update) and announces once ("3 layers turned off. Undo available", "1 layer turned off. Undo available"). Below the button the section then shows plain text, "Turned off 3 layers." or "Turned off 2 in `<group name>`.", with an "Undo" button named for what it undoes ("Undo turning off 3 layers", which begins with the visible word); the text is not a live region, so nothing is read twice. Focus stays on "Turn off all layers", with Undo the next stop; a group's button leaves when its group has nothing on, so focus moves to its Undo, and returns to the group's button when Undo is used. Undo stays for 10 seconds (`UNDO_TIMEOUT_MS`) and is replaced by the next batch. The countdown waits while a mouse is over the status and while keyboard focus is inside it, each tracked on its own, and starts again in full when both have left; a tap does not hold it. A layer of the batch that the person turns on again leaves the offer and lowers its count, and the offer ends when none is left. Undo turns the remaining layers back on, with the control values they kept while off, and announces once ("3 layers turned back on"); a layer no longer in the catalogue is skipped. There is no "turn on all", because each layer on is a request to its provider. A host hides the action, the group actions and Undo with `showTurnOffAll={false}` (on `SheetContent` too). The line above the layers is the optional `intro` prop (on `SheetContent` too), "Open data from public providers. Nothing is requested until you turn a layer on." by default, which a host whose layers are not public replaces; an empty string leaves it out. Between that line and the layers sits the catalogue status below. While there are no layers (the catalogue is loading, has failed or is empty) there is no "Turn off all layers" and there are no groups, and a host whose catalogue was ready with no layers when the page opened has no Layers section at all. |
| Catalogue status                       | Plain text in the Layers section, drawn by `CatalogueStatus` from `DataLayers.catalogue`, in the muted small type of a layer's status line. It is not a live region: `useDataLayers` announces each transition once through `LiveRegion`, and the text is not read a second time. Loading: a loader icon and "Loading layers", and the section is `aria-busy`. Failed: a warning icon and "Layers could not be loaded." in the danger colour, and a secondary "Try again" button. Empty: "No layers are available.", for a list that was awaited. Skipped definitions: "1 layer could not be shown" or "3 layers could not be shown", above the layers. A failed refresh: the warning icon, "Layers could not be updated. Showing the last list." and Try again, with the last list still below. Try again asks the catalogue to load again; it stays in place while it retries, busy (`aria-busy`, a loader in place of its icon) with "Loading layers" in place of the failure, so keyboard focus stays on it. When the catalogue recovers the button goes, and focus moves to the Layers heading if the button had focus or had just been pressed, unless the person has moved it elsewhere (this holds for a refresh the host started as well); when a retry fails again the button keeps focus. There is no general refresh button, and a refresh that only loads shows nothing. Announcements: each state once, when it is entered. A new list is one polite message in a fixed order (layers turned off, layers in the link that are not available, the skipped count, "Layers updated: 1 added, 1 removed.", then "No layers are available." for an empty first list); "Loading layers" is said only while a layer named in the link is waiting; a failed load or refresh is its own assertive message, except that a failed refresh says nothing while the section is hidden. The skipped count is said each time it changes to a number above zero. Each of these is sent with the announcer's `keep` option, so a later message queues behind it and does not replace it, except "Loading layers", which a later message may replace.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| Feature list                           | Rows are full-width buttons named by the feature and ", show on map"; a row brings the sheet to half, centres the feature in the part of the map the sheet or side panel leaves free, rings it, scrolls its card into view and opens it (a tap on a point does the same, moving the map only if the point would be hidden), the keyboard and screen-reader equivalent of tapping the point. Sorts are a segmented control; long lists show 50 rows and "Show all". Host-keyed row templates use the active message catalogue.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
