MAPP.UI
MAPP.UI builds the interface around a MAPP mapview: layer and location views, filters, legends, dataviews, tabs, the gazetteer and mapview buttons. It lives in apps/ui (@geolytix/mapp-ui) and is bundled as public/js/lib/ui.js with public/css/ui.css. For the library split see MAPP.
The mapp global
MAPP.UI imports nothing from apps/mapp. It uses MAPP through the mapp global, eg. mapp.utils, mapp.dictionary, mapp.layer, mapp.user, mapp.hooks and mapp.host. mapp.js must load before ui.js.[1]
On load, ui.mjs assigns itself as mapp.ui and globalThis.ui, and patches MAPP:[2]
mapp.utils.alert()andconfirm()become ui dialogs.mapp.layer.drawLegend()becomes the ui legend renderer.- the ui plugins are added to
mapp.plugins.
The dependency runs one way. MAPP must work without MAPP.UI; the lint workflow fails if apps/mapp/lib references mapp.ui or imports from apps/ui.[3] MAPP therefore never calls the ui. The ui hooks in through objects MAPP already uses, listed below. Loading mapp.js again after ui.js replaces the global and drops the ui.
Module map
| Module | Role |
|---|---|
| elements/ | Generic controls: dialog, drawer, dropdown, slider, pills, searchbox, toast, login and register forms. |
| layers/ | Layer listview, layer view, panels (meta, style, filter, dataviews, draw, ...), legends and filters. |
| locations/ | Location listview, location view, infoj and entries per entry type. |
| plugins/ | Mapview buttons and tools: zoomBtn, admin, login, locator, fullscreen, dark_mode, userLayer, ... |
| utils/ | Dataview helpers, histogram, colour theme, idle logout, resize handler. |
| Dataview.mjs | Decorates a dataview: JSON, Tabulator table or ChartJS chart. |
| Tabview.mjs | Tabs and panels, eg. the dataview tabs below the map. |
| Gazetteer.mjs | Search box over mapp.utils.gazetteer. |
How the ui attaches to MAPP
- Views wire it up. A view script such as _default.html creates the
mapp.Mapview, then callsmapp.ui.layers.listview,mapp.ui.locations.listview,mapp.ui.Gazetteerandmapp.ui.Tabviewwith its own target elements. MAPP alone renders a map without these panels. - Layers. The layer listview creates a
layer.viewfor each mapview layer. The view callsmapp.ui.layers.panels[key]for each layer key with a panel, ordered byviewConfig.keyOrder.[4] A new panel is a new module inlayers/panelsnamed after its layer key. - Locations. The location listview replaces
mapview.locationswith a Proxy. When MAPP stores a location there, the proxy assigns a record symbol and colour and callsmapp.ui.locations.view.[5] The view renderslocation.infoj; each entry is drawn bymapp.ui.locations.entries[entry.type].[6] - Plugins. MAPP calls
mapp.plugins[key](locale[key], mapview)for each locale key with a plugin function.[7] Ui plugins add buttons to the mapview and need MAPP.UI loaded. See Locale plugins. - Dataviews. Chart and table dataviews need ChartJS or Tabulator loaded by a plugin;
Dataviewchecks for them. See Dataviews.
Where to change
- A new control: a module in
elements/and its export in_elements.mjs. - A new entry type: a module in
locations/entries/and_entries.mjs; document it in Entry types. - A new layer panel: a module in
layers/panels/and_panels.mjs. - A new mapview button: a plugin in
plugins/and_plugins.mjs; document its locale key in Locale plugins. - Behaviour MAPP needs without the ui belongs in
apps/mapp/lib, with a plain fallback the ui can replace, likedrawLegend. - Styles:
apps/ui/css, bundled from_ui.css.ui.cssloads the fonts and palette thatmapp.cssrelies on.
Tests
apps/ui/tests has Vitest browser module tests (*.test.mjs) mirroring lib/, and Playwright tests of the default view (*.spec.mjs), both against the testhost. Run pnpm test:ui; see TESTING.md. Many ui modules have no tests yet.