diff --git a/.changeset/6127-location-map-fence-split.md b/.changeset/6127-location-map-fence-split.md new file mode 100644 index 0000000000..49578b3076 --- /dev/null +++ b/.changeset/6127-location-map-fence-split.md @@ -0,0 +1,29 @@ +--- +--- + +Docs only, publishes nothing: `content/docs/fields/location.mdx`'s *Integration +with Maps* fence welded two different examples into one block — an import plus a +JSX element (which needs `tsx`), immediately followed by a bare metadata object +literal at statement position (which `tsx` reads as a labelled statement, then +fails on the commas). Measured standalone with the repo's own TypeScript on +`origin/main`: **2 syntactic diagnostics as `ts`, 5 as `tsx`** — it parsed under +neither fence language, which is why `location.mdx` was excluded from objectui#5867 +batch 3 by measurement (objectui#6127). The fence is now **split in two**, each half +fenced for what it actually is: a `tsx` block holding the widget example, made +self-contained so it compiles (it renders `LocationField` with a typed +`LocationFieldMetadata` and a state-held coordinate pair, instead of spreading an +undeclared `props`), and a `jsonc` block holding the `object-map` metadata node — +which is a schema-key question `check-doc-snippet-types` explicitly says it does +not answer. Connecting prose numbers the two halves so the section still reads as +one example. The page's *Field Schema* block, the other fence triage's classifier +calls code, is re-fenced `plaintext` → `ts` in the same pass; the two genuinely +prose fences (`{` and `// Valid coordinates`) are left alone. + +Accounting, stated because splitting a fence breaks the plain "blocks-to-compile +rises by exactly the batch size" identity this card family has used across three +batches: **1 block re-fenced, plus 1 fence split into 2 of which 1 half is +TypeScript, so blocks-to-compile rises by 1 + 1 = 2** — measured 206 → 208, with +diagnostics at 0, declared fragments unmoved at 111, and the covered/ungated sets +unchanged. The page's fence count rises 4 → 5. Both blocks also stop rendering as +unstyled plaintext and pick up TypeScript and JSON-with-comments highlighting, +which is reader-visible. diff --git a/content/docs/fields/location.mdx b/content/docs/fields/location.mdx index ea17f2a1cb..50652d9a66 100644 --- a/content/docs/fields/location.mdx +++ b/content/docs/fields/location.mdx @@ -19,7 +19,7 @@ The Location Field component provides an input for geographic coordinates, stori ## Field Schema -```plaintext +```ts interface LocationFieldSchema { type: 'location'; name: string; // Field name/ID @@ -76,26 +76,46 @@ Examples: ## Integration with Maps -For full map functionality, consider integrating with map services: +For full map functionality, consider integrating with map services. The example +below has two halves: the **input** that captures a coordinate pair, and the **map +node** that plots what it stored. -```plaintext +**1. The input.** `LocationField` is the widget behind the `location` field type. +Render it directly when you build the form yourself: + +```tsx +import { useState } from 'react'; import { LocationField } from '@object-ui/fields'; +import type { LocationFieldMetadata } from '@object-ui/types'; + +const field: LocationFieldMetadata = { + type: 'location', + name: 'location', + label: 'Store location', +}; + +export function StoreLocationInput() { + const [value, setValue] = useState<{ latitude: number; longitude: number } | null>(null); + return ; +} +``` -// Basic coordinates input - +**2. The map over the same field.** With the map plugin installed, an `object-map` +node reads that field off every record. It is a metadata node, not a component +call — the keys sit on the node itself, and a `props` envelope is never read by +the renderer: -// With map visualization (using map plugin) -// Keys sit on the node — a `props` envelope is never read by the renderer +```jsonc { - type: 'object-map', // the registered type name — there is no `plugin:map` - objectName: 'store', // the records to plot - map: { // the declared config input; markers are derived from the data - locationField: 'location', // this page's field, read as { latitude, longitude } - titleField: 'name', // field used as the marker label - zoom: 12, // initial zoom level + "type": "object-map", // the registered type name — there is no `plugin:map` + "objectName": "store", // the records to plot + "map": { // the declared config input; markers are derived from the data + "locationField": "location", // this page's field, read as { latitude, longitude } + "titleField": "name", // field used as the marker label + "zoom": 12, // initial zoom level // Initial centre as [latitude, longitude]. Used only when no record // matches — with records the view fits to their bounds instead. - center: [37.7749, -122.4194] + "center": [37.7749, -122.4194] } } ```