From b704429112cdf6dd6a0c12f73e27cce2bf3e2fdb Mon Sep 17 00:00:00 2001 From: MobileMage Date: Sun, 4 Oct 2026 02:07:42 +0100 Subject: [PATCH 1/4] chore: pin the js and spec submodules to the field release The js repo now holds the postcode field and its React wrapper, and the spec repo defines the field and its message catalogue in version 0.3.0. The glossary of the spec gained three terms, so the local copy follows it. Signed-off-by: MobileMage --- CONTEXT.md | 12 ++++++++++++ js | 2 +- spec | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CONTEXT.md b/CONTEXT.md index fcc8182..4b82f5f 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -169,6 +169,18 @@ _Avoid_: input, widget, picker To show the user what a postcode points to before the app stores it. _Avoid_: verify, validate (for this step) +**Check status**: +What the WooCommerce plugin learned about the postcode of an order: `valid`, `invalid`, `unchecked` or `error`. The order meta `_gatepost_postcode_check` holds it. +_Avoid_: verification status, validation result + +**Form value**: +The text that a field gives its form when the form is sent: the canonical form of a postcode, the 6 digits of a legacy postcode, or the text without white space at the start and the end. +_Avoid_: submitted value, output + +**Message catalogue**: +A data file that holds the text of a UI in one language, one message for each key. +_Avoid_: strings file, translations, locale file + **Tell**: A habit that makes code look machine-written, such as very long lines. _Avoid_: smell (smells are design problems), anti-pattern diff --git a/js b/js index 3ba7fc4..0003151 160000 --- a/js +++ b/js @@ -1 +1 @@ -Subproject commit 3ba7fc43c4f1c15685987e88ce20cd190f95065d +Subproject commit 00031516fc5b313e2ea2870fd3ae537a4c309f4a diff --git a/spec b/spec index 9e20f87..db359cd 160000 --- a/spec +++ b/spec @@ -1 +1 @@ -Subproject commit 9e20f87addb2a2b238cea82d65b9bd071bedc3f6 +Subproject commit db359cde28a7c5c549f1a3069f20078f19f05a58 From 63b21f45e6222c9a294ca764693087e9a1b13f35 Mon Sep 17 00:00:00 2001 From: MobileMage Date: Sun, 4 Oct 2026 02:07:42 +0100 Subject: [PATCH 2/4] docs: add the quickstarts for the HTML field and React Most sites add a postcode through a form, so the field and the React wrapper need their own quickstarts. Each HTML, TSX and CSS block on these pages is a README example that the js repo runs in its CI, and a test fails when a page shows a block that no README holds. A browser test also loads each HTML example against the built element, with the mock gateway and no other host. The API reference now covers both packages, and the spec section shows the field spec. Signed-off-by: MobileMage --- astro.config.mjs | 11 +- package.json | 2 +- scripts/spec-pages.ts | 6 ++ src/content/docs/guides/html.md | 152 ++++++++++++++++++++++++++++ src/content/docs/guides/react.md | 84 +++++++++++++++ src/content/docs/start.md | 2 + test/browser/field-examples.spec.ts | 86 ++++++++++++++++ test/site/reference.test.ts | 2 +- test/support/examples.ts | 2 +- test/unit/examples.test.ts | 31 +++++- test/unit/release-state.test.ts | 2 +- test/unit/spec-pages.test.ts | 4 +- 12 files changed, 376 insertions(+), 8 deletions(-) create mode 100644 src/content/docs/guides/html.md create mode 100644 src/content/docs/guides/react.md create mode 100644 test/browser/field-examples.spec.ts diff --git a/astro.config.mjs b/astro.config.mjs index 205daad..17cc43f 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -14,6 +14,8 @@ const base = '/docs'; const [coreTypeDoc, coreTypeDocGroup] = createStarlightTypeDocPlugin(); const [clientTypeDoc, clientTypeDocGroup] = createStarlightTypeDocPlugin(); +const [fieldTypeDoc, fieldTypeDocGroup] = createStarlightTypeDocPlugin(); +const [reactTypeDoc, reactTypeDocGroup] = createStarlightTypeDocPlugin(); // The API pages of a package, generated from the TSDoc comments of its source. function typeDocOf(name) { @@ -95,7 +97,12 @@ export default defineConfig({ // A code block that scrolls sideways needs a focus stop for keyboard users. Wrapped lines // need none, and they fit a phone screen. expressiveCode: { defaultProps: { wrap: true } }, - plugins: [coreTypeDoc(typeDocOf('core')), clientTypeDoc(typeDocOf('client'))], + plugins: [ + coreTypeDoc(typeDocOf('core')), + clientTypeDoc(typeDocOf('client')), + fieldTypeDoc(typeDocOf('field')), + reactTypeDoc(typeDocOf('react')), + ], sidebar: [ { label: 'Start', items: ['start', 'playground'] }, { label: 'Guides', items: [{ autogenerate: { directory: 'guides' } }] }, @@ -105,6 +112,8 @@ export default defineConfig({ items: [ coreTypeDocGroup, clientTypeDocGroup, + fieldTypeDocGroup, + reactTypeDocGroup, { label: 'gatepost/postcode', collapsed: true, diff --git a/package.json b/package.json index a754834..6f0be2b 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "scripts": { "sdk": "run-s sdk:js sdk:js:build sdk:php", "sdk:js": "pnpm --dir js install --frozen-lockfile", - "sdk:js:build": "pnpm --dir js --filter @gatepost/core --filter @gatepost/client run build", + "sdk:js:build": "pnpm --dir js --filter './packages/{core,client,field,react}' run build", "sdk:php": "composer --working-dir=php install --no-interaction --no-progress", "dev": "ASTRO_TELEMETRY_DISABLED=1 astro dev", "build": "ASTRO_TELEMETRY_DISABLED=1 astro build", diff --git a/scripts/spec-pages.ts b/scripts/spec-pages.ts index 9fcd76f..0726596 100644 --- a/scripts/spec-pages.ts +++ b/scripts/spec-pages.ts @@ -25,6 +25,12 @@ const SOURCES = [ title: 'Client contract', description: "How every Gatepost client calls NIPOST's gateway: results, errors and retries.", }, + { + file: 'field.md', + slug: 'field', + title: 'Field', + description: 'How every Gatepost postcode field behaves: settings, events, states and privacy.', + }, { file: 'CONTEXT.md', slug: 'glossary', diff --git a/src/content/docs/guides/html.md b/src/content/docs/guides/html.md new file mode 100644 index 0000000..3851c90 --- /dev/null +++ b/src/content/docs/guides/html.md @@ -0,0 +1,152 @@ +--- +title: Add a postcode field to a web form +description: Use the gatepost-postcode-field element in any HTML form, with or without a framework. +sidebar: + label: HTML field + order: 4 +--- + +`@gatepost/field` adds ``, a form field for Nigeria's digital postcode. It works in a plain HTML form. It checks the form of the postcode while the user types, and it can ask NIPOST's gateway about the postcode. + +## Install + +The first alpha is not published yet. This page will say when it is. + +```sh +pnpm add @gatepost/field +``` + +Until the release, the CDN address in the examples below does not work. Import `@gatepost/field` once in your app, and the page can use the element. A page with no build step can load the one-file build from a CDN instead. After a release exists, pin its version in the CDN address of a production page. + +## Add the field + +```html + +
+ + +
+``` + +The element is empty until the script runs, so the layout moves when it loads. A page with no JavaScript sends no postcode. + +A `