@loadbare/app 0.7.3 → 0.7.4

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.
@@ -114,6 +114,12 @@ function scope(request, el) {
114
114
  }
115
115
  /** Dispatch the bare action an element carries, for the hub to scope. */
116
116
  function dispatchAction(el) {
117
+ // Pressed again while its round trip is in flight. Ignoring it makes a
118
+ // pending native action disabled in fact, so a stylesheet only has to
119
+ // show it. A widget is not held back this way: one that sends on change
120
+ // must have its latest value sent, not dropped.
121
+ if (el.hasAttribute(ATTR_PENDING))
122
+ return;
117
123
  const detail = { action: el.getAttribute(ATTR_ACTION) };
118
124
  el.dispatchEvent(new CustomEvent(LB_EVENT_NAME, { bubbles: true, detail }));
119
125
  }
@@ -278,10 +284,13 @@ class LbHub extends HTMLElement {
278
284
  const request = e.detail;
279
285
  // The element that dispatched the request, not e.currentTarget (the
280
286
  // hub itself, since the event bubbles) — pending/error state belongs
281
- // at the origin so a widget can watch its own attributes.
287
+ // at the origin so a widget can watch its own attributes. aria-busy
288
+ // states the same fact to assistive technology, which no stylesheet
289
+ // on lb-pending reaches.
282
290
  const origin = e.target;
283
291
  origin?.removeAttribute(ATTR_ERROR);
284
292
  origin?.setAttribute(ATTR_PENDING, "");
293
+ origin?.setAttribute("aria-busy", "true");
285
294
  void fetchData(this.page, request)
286
295
  .then((data) => {
287
296
  applyData(this, data);
@@ -291,7 +300,10 @@ class LbHub extends HTMLElement {
291
300
  console.error(`lb-hub: request failed`, err);
292
301
  origin?.setAttribute(ATTR_ERROR, "");
293
302
  })
294
- .finally(() => origin?.removeAttribute(ATTR_PENDING));
303
+ .finally(() => {
304
+ origin?.removeAttribute(ATTR_PENDING);
305
+ origin?.removeAttribute("aria-busy");
306
+ });
295
307
  });
296
308
  /**
297
309
  * A native element carrying an action. The hub dispatches the bare action
@@ -1 +1 @@
1
- {"version":3,"file":"lb-hub.browser.js","sourceRoot":"","sources":["../../hub/lb-hub.browser.ts"],"names":[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n\nimport {\n ACTION_CELL_CHANGE,\n ACTION_ROW_DELETE,\n ACTION_ROW_INSERT,\n ACTION_ROW_UPDATE,\n ATTR_ACTION,\n ATTR_CELL,\n ATTR_ERROR,\n ATTR_KEY_VALUE,\n ATTR_LIST,\n ATTR_NAV_LINK,\n ATTR_PAGE,\n ATTR_PENDING,\n ATTR_ROW,\n ATTR_UNKNOWN_PAGE,\n ATTR_VALUE,\n LB_ACTIONS,\n LB_RESERVED_PREFIX,\n HUB_TAG_NAME,\n NAV_CELL_LABEL,\n NAV_CELL_URI,\n NAV_ROW,\n LB_EVENT_NAME,\n LB_ENDPOINT,\n LB_REQUEST_TIMEOUT_MS,\n} from \"../core/lb-constants.js\";\nimport type { HubData, HubRequest } from \"../core/lb-types.js\";\nimport { applyData, isValueControl, within } from \"./lb-apply.js\";\n\nexport { applyData, applyRow } from \"./lb-apply.js\";\n\n/** What each operation takes from scope, and what it cannot be sent without. */\nconst OPERATIONS: Record<\n string,\n { fills: readonly string[]; requires: readonly string[] }\n> = {\n [ACTION_CELL_CHANGE]: {\n fills: [\"list\", \"key\", \"cell\"],\n requires: [\"list\", \"key\", \"cell\", \"value\"],\n },\n [ACTION_ROW_INSERT]: { fills: [\"list\"], requires: [\"list\", \"values\"] },\n [ACTION_ROW_DELETE]: { fills: [\"list\", \"key\"], requires: [\"list\", \"key\"] },\n [ACTION_ROW_UPDATE]: {\n fills: [\"list\", \"key\"],\n requires: [\"list\", \"key\", \"values\"],\n },\n};\n\n/**\n * Complete a request from where its element sits — see docs/TECHREF-1.0.md,\n * \"Requests\". Every request passes through here, whoever built it, so a\n * widget states what it did and never where it is.\n *\n * The scope field is `list` or `row`, whichever attribute scoped the nearest\n * ancestor, so a declared action fired inside a single-row scope says so and\n * the wire never needs a noun for the addressable thing. A field the request\n * already carries is the dispatcher's to decide and is left as it is.\n *\n * False when the request cannot be sent, having said why.\n */\nfunction scope(request: HubRequest | undefined, el: Element): boolean {\n if (!request?.action) {\n console.warn(`lb-hub: event without an action, ignoring`, request);\n return false;\n }\n const { action } = request;\n const reserved = action.startsWith(LB_RESERVED_PREFIX);\n // The reserved prefix is the whole of the discriminant, so a reserved\n // name that is not one of the four operations is a typo rather than\n // something to forward. Refused here, where the widget can see why: a\n // server would only report that it declares no such action.\n if (reserved && !(LB_ACTIONS as readonly string[]).includes(action)) {\n console.error(\n `lb-hub: '${action}' begins with '${LB_RESERVED_PREFIX}' ` +\n `but names no operation, ignoring`,\n );\n return false;\n }\n\n const fields = request as unknown as Record<string, unknown>;\n // The element's own lb-list or lb-row is what it displays. Where it sits\n // is its ancestors', the way a control belongs to the form around it.\n const parent = el.parentElement;\n const enclosing = parent?.closest(`[${ATTR_LIST}], [${ATTR_ROW}]`);\n const row = parent?.closest(`[${ATTR_KEY_VALUE}]`);\n const inScope: Record<string, string | null | undefined> = {\n list: enclosing?.getAttribute(ATTR_LIST),\n row: enclosing?.hasAttribute(ATTR_LIST)\n ? null\n : enclosing?.getAttribute(ATTR_ROW),\n // Only a row of that scope: a key from outside it names a row of some\n // other list.\n key:\n row && enclosing?.contains(row) ? row.getAttribute(ATTR_KEY_VALUE) : null,\n cell: el.getAttribute(ATTR_CELL),\n };\n const fill = (name: string) => {\n const value = inScope[name];\n if (fields[name] === undefined && value !== null && value !== undefined) {\n fields[name] = value;\n }\n };\n\n const operation = OPERATIONS[action];\n if (!operation) {\n // A declared action names one scope or the other, never both.\n if (fields.list === undefined && fields.row === undefined) {\n fill(\"list\");\n fill(\"row\");\n }\n fill(\"key\");\n fill(\"cell\");\n return true;\n }\n\n for (const name of operation.fills) fill(name);\n // Gathered from the record the element belongs to, the way a button\n // submits its form owner: the nearest form, table row or live row around\n // it, the element itself included. A <tr> counts because it is the one\n // place a form cannot go around a row's controls. What else sits beside\n // the element never decides it. The record is the scope's, so it is never\n // the scope itself nor outside it; with none, there is nothing to say which\n // cells are meant. Outside every scope the list is what is missing, and\n // that is what gets reported.\n if (fields.values === undefined && operation.requires.includes(\"values\")) {\n const owner = el.closest(`form, tr, [${ATTR_KEY_VALUE}]`);\n const ours =\n !enclosing || (owner !== enclosing && enclosing.contains(owner));\n if (owner && ours) {\n const { values, read } = gatherValues(owner);\n if (read.length > 0) {\n fields.values = values;\n if (action === ACTION_ROW_INSERT) gathered.set(request, read);\n }\n } else if (enclosing) {\n console.error(\n `lb-hub: '${action}' from <${el.localName}> is in no form, table ` +\n `row or live row to gather values from, not sent; put its cells ` +\n `in a <form>`,\n el,\n );\n return false;\n }\n }\n const missing = operation.requires.filter((f) => fields[f] === undefined);\n if (missing.length > 0) {\n console.error(\n `lb-hub: '${action}' from <${el.localName}> has no ` +\n `${missing.join(\", \")} in scope, not sent`,\n el,\n );\n return false;\n }\n return true;\n}\n\n/** Dispatch the bare action an element carries, for the hub to scope. */\nfunction dispatchAction(el: Element): void {\n const detail = { action: el.getAttribute(ATTR_ACTION)! } as HubRequest;\n el.dispatchEvent(new CustomEvent(LB_EVENT_NAME, { bubbles: true, detail }));\n}\n\n/** A form control whose state is its `value`. */\ntype ValueControl = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;\n\n/** One cell a request read, the control it read, and the value it read. */\ninterface Read {\n cell: Element;\n control: ValueControl;\n value: string;\n}\n\n/**\n * What each insert gathered, until its round trip succeeds. Keyed by the\n * request itself, so a request an ancestor stops leaves nothing behind.\n */\nconst gathered = new WeakMap<HubRequest, Read[]>();\n\n/**\n * The control a cell reads from, for gathering rather than landing.\n *\n * A cell is always either a native form control itself (a bare\n * `<input lb-cell>`) or a widget that wraps one (`<lb-input>`, `<lb-select>`)\n * — that wrapping is structural, not incidental, which is what lets this be\n * one rule instead of one per widget type. The controls are the ones a value\n * lands on, so what is read back is what landed.\n */\nfunction controlOf(el: Element): ValueControl | undefined {\n return isValueControl(el)\n ? el\n : [...el.querySelectorAll(\"input, select, textarea\")].find(isValueControl);\n}\n\n/**\n * Every lb-cell of an element's scope, gathered into one values map. Shared\n * by lb-row-insert and lb-row-update — both submit a batch of cells, and\n * differ only in whether a key comes with them. What was read comes back\n * beside the map, so an insert can reset it once it succeeds.\n *\n * Found the way a row lands, so a cell inside a nested scope is that scope's\n * and is not read: the options of a picker in the row are the picker's rows,\n * while the picker's own cell is the row's.\n */\nfunction gatherValues(el: Element): {\n values: Record<string, string>;\n read: Read[];\n} {\n const values: Record<string, string> = {};\n const read: Read[] = [];\n for (const cell of within(el, `[${ATTR_CELL}]`)) {\n const name = cell.getAttribute(ATTR_CELL)!;\n const control = controlOf(cell);\n if (control === undefined) {\n console.warn(\n `lb-hub: lb-cell '${name}' has no input, select or textarea to ` +\n `read, ignoring it`,\n cell,\n );\n continue;\n }\n values[name] = control.value;\n read.push({ cell, control, value: control.value });\n }\n return { values, read };\n}\n\n/**\n * After an insert succeeds, what it gathered goes back to its default, the\n * way `form.reset()` resets a form: the row those cells held now lives in the\n * list. A control showing something other than what was read holds an edit\n * made during the round trip, which was not sent, and is left alone.\n *\n * Where a value landed, `lb-value` comes off the cell first, so a widget that\n * renders from it sees the attribute go and returns to its default. The\n * control is reset after, so it ends at its default whatever the widget did.\n * Nothing is dispatched, as `form.reset()` fires no `change`.\n */\nfunction resetGathered(read: Read[]): void {\n for (const { cell, control, value } of read) {\n if (control.value !== value) continue;\n cell.removeAttribute(ATTR_VALUE);\n control.removeAttribute(ATTR_VALUE);\n if (control.localName === \"select\") {\n for (const option of (control as HTMLSelectElement).options) {\n option.selected = option.defaultSelected;\n }\n } else {\n const text = control as HTMLInputElement | HTMLTextAreaElement;\n text.value = text.defaultValue;\n }\n }\n}\n\n/**\n * A path names a page host, and nothing finer. The bare path resolves to\n * `index`, the same convention a static file server follows — an\n * application names its landing page that way rather than the hub singling\n * one out.\n */\nfunction pageNameFor(path: string): string {\n const name = path.replace(/^\\/+|\\/+$/g, \"\");\n return name === \"\" ? \"index\" : name;\n}\n\n/**\n * The `<template>` a page's markup ships in. The builder guarantees one per\n * page name (build/locations.ts refuses two page files sharing a stub), so\n * a second match here means the document was assembled by something else,\n * and is worth saying out loud rather than resolving by document order.\n */\nfunction pageHostFor(page: string): HTMLTemplateElement | null {\n const hosts: HTMLTemplateElement[] = [];\n for (const el of document.querySelectorAll(`template[${ATTR_PAGE}]`)) {\n if (el.getAttribute(ATTR_PAGE) === page) {\n hosts.push(el as HTMLTemplateElement);\n }\n }\n if (hosts.length === 0) {\n console.error(`lb-hub: no page host for '${page}'`);\n return null;\n }\n if (hosts.length > 1) {\n console.error(\n `lb-hub: ${hosts.length} page hosts carry ${ATTR_PAGE}=\"${page}\", ` +\n `using the first`,\n );\n }\n return hosts[0]!;\n}\n\n/**\n * Fetch one round trip against the client-side deadline. Throws — rather\n * than swallowing — on a non-ok response, a network failure, or a timeout,\n * so a caller that needs to know the request failed (as opposed to one that\n * only ever wants the freshest data, like navigate()) can tell the two\n * apart from a genuinely empty result.\n */\nasync function fetchData(page: string, request?: HubRequest): Promise<HubData> {\n const url = `${LB_ENDPOINT}?page=${encodeURIComponent(page)}`;\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), LB_REQUEST_TIMEOUT_MS);\n try {\n // An empty body is how the hub asks for the page's whole query set.\n const res = await fetch(url, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(request ?? {}),\n signal: controller.signal,\n });\n if (!res.ok) {\n throw new Error(`lb-hub: server responded ${res.status} for ${url}`);\n }\n return (await res.json()) as HubData;\n } finally {\n clearTimeout(timeout);\n }\n}\n\n/**\n * The hub is a singleton outside <main>. It survives every page change,\n * so it needs no id to disambiguate it.\n */\nclass LbHub extends HTMLElement {\n private main!: HTMLElement;\n\n /**\n * The page currently in <main>. A page declares its own requests, so a request\n * has to say which page it came from. The page rides on the URL rather\n * than in the request, leaving the operation set closed.\n */\n private page = \"\";\n\n connectedCallback() {\n this.main = this.querySelector(\"main\")!;\n\n // Scoped in the capture phase, on the way down, so every ancestor that\n // sees the request on its way back up sees it whole. A request that\n // cannot be sent is stopped here, before anything sees it at all.\n this.addEventListener(\n LB_EVENT_NAME,\n (e: Event) => {\n const origin = e.target as Element;\n const request = (e as CustomEvent<HubRequest>).detail;\n if (!scope(request, origin)) e.stopPropagation();\n },\n { capture: true },\n );\n\n this.addEventListener(LB_EVENT_NAME, (e: Event) => {\n const request = (e as CustomEvent<HubRequest>).detail;\n // The element that dispatched the request, not e.currentTarget (the\n // hub itself, since the event bubbles) — pending/error state belongs\n // at the origin so a widget can watch its own attributes.\n const origin = e.target as Element | null;\n origin?.removeAttribute(ATTR_ERROR);\n origin?.setAttribute(ATTR_PENDING, \"\");\n void fetchData(this.page, request)\n .then((data) => {\n applyData(this, data);\n resetGathered(gathered.get(request) ?? []);\n })\n .catch((err) => {\n console.error(`lb-hub: request failed`, err);\n origin?.setAttribute(ATTR_ERROR, \"\");\n })\n .finally(() => origin?.removeAttribute(ATTR_PENDING));\n });\n\n /**\n * A native element carrying an action. The hub dispatches the bare action\n * from that element as the ordinary bubbling event, rather than sending\n * it directly, so it is scoped exactly as a widget's is and an ancestor\n * widget can still stop it and confirm. A native action button and a\n * hand-written widget therefore produce identical events.\n *\n * A widget carrying an action is left alone — it owns its own interaction\n * and decides what counts as performing it, which for a <select> is a\n * change rather than a click. The test is the same lexical one applyData\n * uses: a hyphen in the tag name.\n */\n this.addEventListener(\"click\", (e: MouseEvent) => {\n const el = (e.target as Element | null)?.closest(`[${ATTR_ACTION}]`);\n if (!el || el.localName.includes(\"-\")) return;\n // A form performs its action on submit, whatever was clicked in it.\n if (el instanceof HTMLFormElement) return;\n // A button beside the cells is pressed once they are done. An element\n // holding them has no such moment: a click into one of its own inputs\n // would send the row.\n const action = el.getAttribute(ATTR_ACTION);\n if (\n (action === ACTION_ROW_INSERT || action === ACTION_ROW_UPDATE) &&\n el.querySelector(`[${ATTR_CELL}]`)\n ) {\n console.error(\n `lb-hub: '${action}' on <${el.localName}> holds its own cells, ` +\n `so a click inside it is not sent; put it on a <form> or a button`,\n el,\n );\n return;\n }\n e.preventDefault();\n dispatchAction(el);\n });\n\n // The same delegation for the event a form owns.\n this.addEventListener(\"submit\", (e: SubmitEvent) => {\n const form = e.target as Element | null;\n if (!form || !form.hasAttribute(ATTR_ACTION)) return;\n e.preventDefault();\n dispatchAction(form);\n });\n\n // Only anchors that opted in. Everything else is a real link.\n this.addEventListener(\"click\", (e: MouseEvent) => {\n const link = (e.target as Element | null)?.closest(`a[${ATTR_NAV_LINK}]`);\n if (!link) return;\n e.preventDefault();\n const path = new URL((link as HTMLAnchorElement).href).pathname;\n history.pushState(null, \"\", path);\n void this.navigate(path);\n });\n\n addEventListener(\"popstate\", () => void this.navigate(location.pathname));\n\n void this.navigate(location.pathname);\n }\n\n /**\n * Navigation is the one operation that replaces host DOM. The host is\n * already in the document, so selecting a page is getElementById() and\n * there is no fetching mechanism on the host channel.\n */\n private async navigate(path: string): Promise<void> {\n const page = pageNameFor(path);\n this.landNavigation(path, page);\n const template = pageHostFor(page);\n if (!template) {\n this.reportUnknownPage();\n this.reveal();\n return;\n }\n this.page = page;\n // Insert the page shell before fetching its data, not after: the\n // template is already in the document, so holding it back behind a\n // network round trip only leaves <main> empty for no reason.\n this.main.replaceChildren(template.content.cloneNode(true));\n this.reveal();\n let data: HubData = {};\n try {\n data = await fetchData(page);\n } catch (err) {\n console.error(`lb-hub: failed to load data for '${page}'`, err);\n }\n applyData(this, data);\n }\n\n /**\n * An app that ships `<body hidden>` (see docs/reference/chrome.md) is\n * asking to stay invisible until there is something coherent to show,\n * rather than flash the chrome before `<main>` has real content. This is\n * a no-op for an app that doesn't use that convention.\n */\n private reveal(): void {\n document.body.hidden = false;\n }\n\n /**\n * The hub's own row: where the page is, in the vocabulary a server\n * answer arrives in, so a chrome displays it the way it displays anything\n * — `lb-row=\"lb-navigation\"` on a subtree, `lb-cell` on what shows a\n * value. Landed before the page host is looked up, so a miss has it too;\n * the unknown-page dialog is one consumer among whatever others the\n * chrome writes.\n *\n * The label is the nav's: the text of the first lb-nav-link anchor whose\n * href names this page. Taken from the nav rather than from a click, so a\n * click, a reload and the back button all land the same label — and a\n * path no anchor names lands an empty one, explicitly, so a consumer is\n * never left showing the previous page's.\n *\n * Landed only where a subtree names it. applyData() warns about a query\n * with no scope, and a chrome that displays no navigation has nothing to\n * be warned about.\n */\n private landNavigation(path: string, page: string): void {\n if (!this.querySelector(`[${ATTR_ROW}=\"${NAV_ROW}\"]`)) return;\n let label = \"\";\n for (const a of this.querySelectorAll<HTMLAnchorElement>(\n `a[${ATTR_NAV_LINK}]`,\n )) {\n if (pageNameFor(new URL(a.href).pathname) !== page) continue;\n label = a.textContent?.trim() ?? \"\";\n break;\n }\n applyData(this, {\n [NAV_ROW]: { [NAV_CELL_LABEL]: label, [NAV_CELL_URI]: path },\n });\n }\n\n /**\n * A path that resolves to no page host is discovered client-side, after a\n * successful 200 — every route gets the same document, so there is no\n * HTTP 404 to report (see docs/tutorials/010-pages-and-navigation.md).\n * lb-unknown-page is optional: an application that declares none gets\n * nothing beyond navigate()'s console.error. The builder guarantees the\n * element it's on is a <dialog> (build/assemble.ts), so this can call\n * showModal() without checking the tag here.\n *\n * Only opens it. What the dialog says it gets from landNavigation(),\n * already run, by naming the hub's row in lb-row like any subtree.\n *\n * Scoped to the hub, like every other lookup here, so that one rule holds\n * without exception: what the hub acts on is inside the hub.\n */\n private reportUnknownPage(): void {\n const dialog = this.querySelector(`[${ATTR_UNKNOWN_PAGE}]`);\n if (!dialog) return;\n const modal = dialog as HTMLDialogElement;\n if (!modal.open) modal.showModal();\n }\n}\n\ncustomElements.define(HUB_TAG_NAME, LbHub);\n"]}
1
+ {"version":3,"file":"lb-hub.browser.js","sourceRoot":"","sources":["../../hub/lb-hub.browser.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,UAAU,EACV,cAAc,EACd,SAAS,EACT,aAAa,EACb,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,iBAAiB,EACjB,UAAU,EACV,UAAU,E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K,CAAC,CAAC","sourcesContent":["/// <reference lib=\"dom\" />\n\nimport {\n ACTION_CELL_CHANGE,\n ACTION_ROW_DELETE,\n ACTION_ROW_INSERT,\n ACTION_ROW_UPDATE,\n ATTR_ACTION,\n ATTR_CELL,\n ATTR_ERROR,\n ATTR_KEY_VALUE,\n ATTR_LIST,\n ATTR_NAV_LINK,\n ATTR_PAGE,\n ATTR_PENDING,\n ATTR_ROW,\n ATTR_UNKNOWN_PAGE,\n ATTR_VALUE,\n LB_ACTIONS,\n LB_RESERVED_PREFIX,\n HUB_TAG_NAME,\n NAV_CELL_LABEL,\n NAV_CELL_URI,\n NAV_ROW,\n LB_EVENT_NAME,\n LB_ENDPOINT,\n LB_REQUEST_TIMEOUT_MS,\n} from \"../core/lb-constants.js\";\nimport type { HubData, HubRequest } from \"../core/lb-types.js\";\nimport { applyData, isValueControl, within } from \"./lb-apply.js\";\n\nexport { applyData, applyRow } from \"./lb-apply.js\";\n\n/** What each operation takes from scope, and what it cannot be sent without. */\nconst OPERATIONS: Record<\n string,\n { fills: readonly string[]; requires: readonly string[] }\n> = {\n [ACTION_CELL_CHANGE]: {\n fills: [\"list\", \"key\", \"cell\"],\n requires: [\"list\", \"key\", \"cell\", \"value\"],\n },\n [ACTION_ROW_INSERT]: { fills: [\"list\"], requires: [\"list\", \"values\"] },\n [ACTION_ROW_DELETE]: { fills: [\"list\", \"key\"], requires: [\"list\", \"key\"] },\n [ACTION_ROW_UPDATE]: {\n fills: [\"list\", \"key\"],\n requires: [\"list\", \"key\", \"values\"],\n },\n};\n\n/**\n * Complete a request from where its element sits — see docs/TECHREF-1.0.md,\n * \"Requests\". Every request passes through here, whoever built it, so a\n * widget states what it did and never where it is.\n *\n * The scope field is `list` or `row`, whichever attribute scoped the nearest\n * ancestor, so a declared action fired inside a single-row scope says so and\n * the wire never needs a noun for the addressable thing. A field the request\n * already carries is the dispatcher's to decide and is left as it is.\n *\n * False when the request cannot be sent, having said why.\n */\nfunction scope(request: HubRequest | undefined, el: Element): boolean {\n if (!request?.action) {\n console.warn(`lb-hub: event without an action, ignoring`, request);\n return false;\n }\n const { action } = request;\n const reserved = action.startsWith(LB_RESERVED_PREFIX);\n // The reserved prefix is the whole of the discriminant, so a reserved\n // name that is not one of the four operations is a typo rather than\n // something to forward. Refused here, where the widget can see why: a\n // server would only report that it declares no such action.\n if (reserved && !(LB_ACTIONS as readonly string[]).includes(action)) {\n console.error(\n `lb-hub: '${action}' begins with '${LB_RESERVED_PREFIX}' ` +\n `but names no operation, ignoring`,\n );\n return false;\n }\n\n const fields = request as unknown as Record<string, unknown>;\n // The element's own lb-list or lb-row is what it displays. Where it sits\n // is its ancestors', the way a control belongs to the form around it.\n const parent = el.parentElement;\n const enclosing = parent?.closest(`[${ATTR_LIST}], [${ATTR_ROW}]`);\n const row = parent?.closest(`[${ATTR_KEY_VALUE}]`);\n const inScope: Record<string, string | null | undefined> = {\n list: enclosing?.getAttribute(ATTR_LIST),\n row: enclosing?.hasAttribute(ATTR_LIST)\n ? null\n : enclosing?.getAttribute(ATTR_ROW),\n // Only a row of that scope: a key from outside it names a row of some\n // other list.\n key:\n row && enclosing?.contains(row) ? row.getAttribute(ATTR_KEY_VALUE) : null,\n cell: el.getAttribute(ATTR_CELL),\n };\n const fill = (name: string) => {\n const value = inScope[name];\n if (fields[name] === undefined && value !== null && value !== undefined) {\n fields[name] = value;\n }\n };\n\n const operation = OPERATIONS[action];\n if (!operation) {\n // A declared action names one scope or the other, never both.\n if (fields.list === undefined && fields.row === undefined) {\n fill(\"list\");\n fill(\"row\");\n }\n fill(\"key\");\n fill(\"cell\");\n return true;\n }\n\n for (const name of operation.fills) fill(name);\n // Gathered from the record the element belongs to, the way a button\n // submits its form owner: the nearest form, table row or live row around\n // it, the element itself included. A <tr> counts because it is the one\n // place a form cannot go around a row's controls. What else sits beside\n // the element never decides it. The record is the scope's, so it is never\n // the scope itself nor outside it; with none, there is nothing to say which\n // cells are meant. Outside every scope the list is what is missing, and\n // that is what gets reported.\n if (fields.values === undefined && operation.requires.includes(\"values\")) {\n const owner = el.closest(`form, tr, [${ATTR_KEY_VALUE}]`);\n const ours =\n !enclosing || (owner !== enclosing && enclosing.contains(owner));\n if (owner && ours) {\n const { values, read } = gatherValues(owner);\n if (read.length > 0) {\n fields.values = values;\n if (action === ACTION_ROW_INSERT) gathered.set(request, read);\n }\n } else if (enclosing) {\n console.error(\n `lb-hub: '${action}' from <${el.localName}> is in no form, table ` +\n `row or live row to gather values from, not sent; put its cells ` +\n `in a <form>`,\n el,\n );\n return false;\n }\n }\n const missing = operation.requires.filter((f) => fields[f] === undefined);\n if (missing.length > 0) {\n console.error(\n `lb-hub: '${action}' from <${el.localName}> has no ` +\n `${missing.join(\", \")} in scope, not sent`,\n el,\n );\n return false;\n }\n return true;\n}\n\n/** Dispatch the bare action an element carries, for the hub to scope. */\nfunction dispatchAction(el: Element): void {\n // Pressed again while its round trip is in flight. Ignoring it makes a\n // pending native action disabled in fact, so a stylesheet only has to\n // show it. A widget is not held back this way: one that sends on change\n // must have its latest value sent, not dropped.\n if (el.hasAttribute(ATTR_PENDING)) return;\n const detail = { action: el.getAttribute(ATTR_ACTION)! } as HubRequest;\n el.dispatchEvent(new CustomEvent(LB_EVENT_NAME, { bubbles: true, detail }));\n}\n\n/** A form control whose state is its `value`. */\ntype ValueControl = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;\n\n/** One cell a request read, the control it read, and the value it read. */\ninterface Read {\n cell: Element;\n control: ValueControl;\n value: string;\n}\n\n/**\n * What each insert gathered, until its round trip succeeds. Keyed by the\n * request itself, so a request an ancestor stops leaves nothing behind.\n */\nconst gathered = new WeakMap<HubRequest, Read[]>();\n\n/**\n * The control a cell reads from, for gathering rather than landing.\n *\n * A cell is always either a native form control itself (a bare\n * `<input lb-cell>`) or a widget that wraps one (`<lb-input>`, `<lb-select>`)\n * — that wrapping is structural, not incidental, which is what lets this be\n * one rule instead of one per widget type. The controls are the ones a value\n * lands on, so what is read back is what landed.\n */\nfunction controlOf(el: Element): ValueControl | undefined {\n return isValueControl(el)\n ? el\n : [...el.querySelectorAll(\"input, select, textarea\")].find(isValueControl);\n}\n\n/**\n * Every lb-cell of an element's scope, gathered into one values map. Shared\n * by lb-row-insert and lb-row-update — both submit a batch of cells, and\n * differ only in whether a key comes with them. What was read comes back\n * beside the map, so an insert can reset it once it succeeds.\n *\n * Found the way a row lands, so a cell inside a nested scope is that scope's\n * and is not read: the options of a picker in the row are the picker's rows,\n * while the picker's own cell is the row's.\n */\nfunction gatherValues(el: Element): {\n values: Record<string, string>;\n read: Read[];\n} {\n const values: Record<string, string> = {};\n const read: Read[] = [];\n for (const cell of within(el, `[${ATTR_CELL}]`)) {\n const name = cell.getAttribute(ATTR_CELL)!;\n const control = controlOf(cell);\n if (control === undefined) {\n console.warn(\n `lb-hub: lb-cell '${name}' has no input, select or textarea to ` +\n `read, ignoring it`,\n cell,\n );\n continue;\n }\n values[name] = control.value;\n read.push({ cell, control, value: control.value });\n }\n return { values, read };\n}\n\n/**\n * After an insert succeeds, what it gathered goes back to its default, the\n * way `form.reset()` resets a form: the row those cells held now lives in the\n * list. A control showing something other than what was read holds an edit\n * made during the round trip, which was not sent, and is left alone.\n *\n * Where a value landed, `lb-value` comes off the cell first, so a widget that\n * renders from it sees the attribute go and returns to its default. The\n * control is reset after, so it ends at its default whatever the widget did.\n * Nothing is dispatched, as `form.reset()` fires no `change`.\n */\nfunction resetGathered(read: Read[]): void {\n for (const { cell, control, value } of read) {\n if (control.value !== value) continue;\n cell.removeAttribute(ATTR_VALUE);\n control.removeAttribute(ATTR_VALUE);\n if (control.localName === \"select\") {\n for (const option of (control as HTMLSelectElement).options) {\n option.selected = option.defaultSelected;\n }\n } else {\n const text = control as HTMLInputElement | HTMLTextAreaElement;\n text.value = text.defaultValue;\n }\n }\n}\n\n/**\n * A path names a page host, and nothing finer. The bare path resolves to\n * `index`, the same convention a static file server follows — an\n * application names its landing page that way rather than the hub singling\n * one out.\n */\nfunction pageNameFor(path: string): string {\n const name = path.replace(/^\\/+|\\/+$/g, \"\");\n return name === \"\" ? \"index\" : name;\n}\n\n/**\n * The `<template>` a page's markup ships in. The builder guarantees one per\n * page name (build/locations.ts refuses two page files sharing a stub), so\n * a second match here means the document was assembled by something else,\n * and is worth saying out loud rather than resolving by document order.\n */\nfunction pageHostFor(page: string): HTMLTemplateElement | null {\n const hosts: HTMLTemplateElement[] = [];\n for (const el of document.querySelectorAll(`template[${ATTR_PAGE}]`)) {\n if (el.getAttribute(ATTR_PAGE) === page) {\n hosts.push(el as HTMLTemplateElement);\n }\n }\n if (hosts.length === 0) {\n console.error(`lb-hub: no page host for '${page}'`);\n return null;\n }\n if (hosts.length > 1) {\n console.error(\n `lb-hub: ${hosts.length} page hosts carry ${ATTR_PAGE}=\"${page}\", ` +\n `using the first`,\n );\n }\n return hosts[0]!;\n}\n\n/**\n * Fetch one round trip against the client-side deadline. Throws — rather\n * than swallowing — on a non-ok response, a network failure, or a timeout,\n * so a caller that needs to know the request failed (as opposed to one that\n * only ever wants the freshest data, like navigate()) can tell the two\n * apart from a genuinely empty result.\n */\nasync function fetchData(page: string, request?: HubRequest): Promise<HubData> {\n const url = `${LB_ENDPOINT}?page=${encodeURIComponent(page)}`;\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), LB_REQUEST_TIMEOUT_MS);\n try {\n // An empty body is how the hub asks for the page's whole query set.\n const res = await fetch(url, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(request ?? {}),\n signal: controller.signal,\n });\n if (!res.ok) {\n throw new Error(`lb-hub: server responded ${res.status} for ${url}`);\n }\n return (await res.json()) as HubData;\n } finally {\n clearTimeout(timeout);\n }\n}\n\n/**\n * The hub is a singleton outside <main>. It survives every page change,\n * so it needs no id to disambiguate it.\n */\nclass LbHub extends HTMLElement {\n private main!: HTMLElement;\n\n /**\n * The page currently in <main>. A page declares its own requests, so a request\n * has to say which page it came from. The page rides on the URL rather\n * than in the request, leaving the operation set closed.\n */\n private page = \"\";\n\n connectedCallback() {\n this.main = this.querySelector(\"main\")!;\n\n // Scoped in the capture phase, on the way down, so every ancestor that\n // sees the request on its way back up sees it whole. A request that\n // cannot be sent is stopped here, before anything sees it at all.\n this.addEventListener(\n LB_EVENT_NAME,\n (e: Event) => {\n const origin = e.target as Element;\n const request = (e as CustomEvent<HubRequest>).detail;\n if (!scope(request, origin)) e.stopPropagation();\n },\n { capture: true },\n );\n\n this.addEventListener(LB_EVENT_NAME, (e: Event) => {\n const request = (e as CustomEvent<HubRequest>).detail;\n // The element that dispatched the request, not e.currentTarget (the\n // hub itself, since the event bubbles) — pending/error state belongs\n // at the origin so a widget can watch its own attributes. aria-busy\n // states the same fact to assistive technology, which no stylesheet\n // on lb-pending reaches.\n const origin = e.target as Element | null;\n origin?.removeAttribute(ATTR_ERROR);\n origin?.setAttribute(ATTR_PENDING, \"\");\n origin?.setAttribute(\"aria-busy\", \"true\");\n void fetchData(this.page, request)\n .then((data) => {\n applyData(this, data);\n resetGathered(gathered.get(request) ?? []);\n })\n .catch((err) => {\n console.error(`lb-hub: request failed`, err);\n origin?.setAttribute(ATTR_ERROR, \"\");\n })\n .finally(() => {\n origin?.removeAttribute(ATTR_PENDING);\n origin?.removeAttribute(\"aria-busy\");\n });\n });\n\n /**\n * A native element carrying an action. The hub dispatches the bare action\n * from that element as the ordinary bubbling event, rather than sending\n * it directly, so it is scoped exactly as a widget's is and an ancestor\n * widget can still stop it and confirm. A native action button and a\n * hand-written widget therefore produce identical events.\n *\n * A widget carrying an action is left alone — it owns its own interaction\n * and decides what counts as performing it, which for a <select> is a\n * change rather than a click. The test is the same lexical one applyData\n * uses: a hyphen in the tag name.\n */\n this.addEventListener(\"click\", (e: MouseEvent) => {\n const el = (e.target as Element | null)?.closest(`[${ATTR_ACTION}]`);\n if (!el || el.localName.includes(\"-\")) return;\n // A form performs its action on submit, whatever was clicked in it.\n if (el instanceof HTMLFormElement) return;\n // A button beside the cells is pressed once they are done. An element\n // holding them has no such moment: a click into one of its own inputs\n // would send the row.\n const action = el.getAttribute(ATTR_ACTION);\n if (\n (action === ACTION_ROW_INSERT || action === ACTION_ROW_UPDATE) &&\n el.querySelector(`[${ATTR_CELL}]`)\n ) {\n console.error(\n `lb-hub: '${action}' on <${el.localName}> holds its own cells, ` +\n `so a click inside it is not sent; put it on a <form> or a button`,\n el,\n );\n return;\n }\n e.preventDefault();\n dispatchAction(el);\n });\n\n // The same delegation for the event a form owns.\n this.addEventListener(\"submit\", (e: SubmitEvent) => {\n const form = e.target as Element | null;\n if (!form || !form.hasAttribute(ATTR_ACTION)) return;\n e.preventDefault();\n dispatchAction(form);\n });\n\n // Only anchors that opted in. Everything else is a real link.\n this.addEventListener(\"click\", (e: MouseEvent) => {\n const link = (e.target as Element | null)?.closest(`a[${ATTR_NAV_LINK}]`);\n if (!link) return;\n e.preventDefault();\n const path = new URL((link as HTMLAnchorElement).href).pathname;\n history.pushState(null, \"\", path);\n void this.navigate(path);\n });\n\n addEventListener(\"popstate\", () => void this.navigate(location.pathname));\n\n void this.navigate(location.pathname);\n }\n\n /**\n * Navigation is the one operation that replaces host DOM. The host is\n * already in the document, so selecting a page is getElementById() and\n * there is no fetching mechanism on the host channel.\n */\n private async navigate(path: string): Promise<void> {\n const page = pageNameFor(path);\n this.landNavigation(path, page);\n const template = pageHostFor(page);\n if (!template) {\n this.reportUnknownPage();\n this.reveal();\n return;\n }\n this.page = page;\n // Insert the page shell before fetching its data, not after: the\n // template is already in the document, so holding it back behind a\n // network round trip only leaves <main> empty for no reason.\n this.main.replaceChildren(template.content.cloneNode(true));\n this.reveal();\n let data: HubData = {};\n try {\n data = await fetchData(page);\n } catch (err) {\n console.error(`lb-hub: failed to load data for '${page}'`, err);\n }\n applyData(this, data);\n }\n\n /**\n * An app that ships `<body hidden>` (see docs/reference/chrome.md) is\n * asking to stay invisible until there is something coherent to show,\n * rather than flash the chrome before `<main>` has real content. This is\n * a no-op for an app that doesn't use that convention.\n */\n private reveal(): void {\n document.body.hidden = false;\n }\n\n /**\n * The hub's own row: where the page is, in the vocabulary a server\n * answer arrives in, so a chrome displays it the way it displays anything\n * — `lb-row=\"lb-navigation\"` on a subtree, `lb-cell` on what shows a\n * value. Landed before the page host is looked up, so a miss has it too;\n * the unknown-page dialog is one consumer among whatever others the\n * chrome writes.\n *\n * The label is the nav's: the text of the first lb-nav-link anchor whose\n * href names this page. Taken from the nav rather than from a click, so a\n * click, a reload and the back button all land the same label — and a\n * path no anchor names lands an empty one, explicitly, so a consumer is\n * never left showing the previous page's.\n *\n * Landed only where a subtree names it. applyData() warns about a query\n * with no scope, and a chrome that displays no navigation has nothing to\n * be warned about.\n */\n private landNavigation(path: string, page: string): void {\n if (!this.querySelector(`[${ATTR_ROW}=\"${NAV_ROW}\"]`)) return;\n let label = \"\";\n for (const a of this.querySelectorAll<HTMLAnchorElement>(\n `a[${ATTR_NAV_LINK}]`,\n )) {\n if (pageNameFor(new URL(a.href).pathname) !== page) continue;\n label = a.textContent?.trim() ?? \"\";\n break;\n }\n applyData(this, {\n [NAV_ROW]: { [NAV_CELL_LABEL]: label, [NAV_CELL_URI]: path },\n });\n }\n\n /**\n * A path that resolves to no page host is discovered client-side, after a\n * successful 200 — every route gets the same document, so there is no\n * HTTP 404 to report (see docs/tutorials/010-pages-and-navigation.md).\n * lb-unknown-page is optional: an application that declares none gets\n * nothing beyond navigate()'s console.error. The builder guarantees the\n * element it's on is a <dialog> (build/assemble.ts), so this can call\n * showModal() without checking the tag here.\n *\n * Only opens it. What the dialog says it gets from landNavigation(),\n * already run, by naming the hub's row in lb-row like any subtree.\n *\n * Scoped to the hub, like every other lookup here, so that one rule holds\n * without exception: what the hub acts on is inside the hub.\n */\n private reportUnknownPage(): void {\n const dialog = this.querySelector(`[${ATTR_UNKNOWN_PAGE}]`);\n if (!dialog) return;\n const modal = dialog as HTMLDialogElement;\n if (!modal.open) modal.showModal();\n }\n}\n\ncustomElements.define(HUB_TAG_NAME, LbHub);\n"]}
@@ -10,8 +10,8 @@ to be true, then revise the code, docs, and tests to ensure it is true.
10
10
  We cannot declare 1.0 until we determine if these blockers can be
11
11
  added later w/o breaking changes. If we are reasonably confident
12
12
  that they can be decided later w/o breaking changes, then we rename
13
- them to "Out of Scope". Otherwise, they must be resolved before
14
- we declare 1.0.
13
+ them to "Out of Scope" or move them to the roadmap. Otherwise,
14
+ they must be resolved before we declare 1.0.
15
15
 
16
16
  ### Data types
17
17
 
@@ -59,6 +59,15 @@ That decision is firm; what the set contains is not.
59
59
 
60
60
  ### Lists
61
61
 
62
+ Imagine we have an HTML `<select>` that displays a fixed list for all
63
+ rows in a table, such as `customer_type` for a table of customers. When
64
+ all customers can be any customer type, our system as written today
65
+ is fine, because all HTML `<select>` elements get the same list.
66
+
67
+ But it may be that the list of allowed values is dependent on other values
68
+ in the row.
69
+
70
+
62
71
  - **Decide how a new row fills a nested list.** A row added to the outer
63
72
  list starts with an empty nested list, which fills only when the nested
64
73
  list's name lands again. See [Master-detail](#master-detail) for what a
@@ -210,7 +219,7 @@ the whole of `--src` is one flat namespace, as stated in
210
219
  Three kinds of file hold HTML.
211
220
 
212
221
  | File | Holds | Found in |
213
- |--------------------|--------------------------------------|--------------|
222
+ | ------------------ | ------------------------------------ | ------------ |
214
223
  | `chrome.html` | The one HTML document | `--src` |
215
224
  | `<stub>.page.html` | One page's markup, as a fragment | `--src` |
216
225
  | `<tag-name>.html` | One widget definition, as a fragment | Every origin |
@@ -277,13 +286,13 @@ A definition states a default with `{{name|default}}`, as in
277
286
  `{{button-label|OK}}`. Whitespace around the name and around the default is
278
287
  discarded. The default is a literal.
279
288
 
280
- | The attribute is assigned | Expansion defines | Result |
281
- |---------------------------|--------------------|----------------------------------|
282
- | `exp-name="text"` | `{{name}}` | `text` |
283
- | `exp-name=""` | `{{name}}` | An empty string |
284
- | Nothing | `{{name|default}}` | `default` |
285
- | Nothing | `{{name}}` | Nothing, and the attribute drops |
286
- | `exp-name` | No `{{name}}` | A build error |
289
+ | The attribute is assigned | Expansion defines | Result |
290
+ | ------------------------- | ------------------- | -------------------------------- |
291
+ | `exp-name="text"` | `{{name}}` | `text` |
292
+ | `exp-name=""` | `{{name}}` | An empty string |
293
+ | Nothing | `{{name\|default}}` | `default` |
294
+ | Nothing | `{{name}}` | Nothing, and the attribute drops |
295
+ | `exp-name` | No `{{name}}` | A build error |
287
296
 
288
297
  Attributes without the `exp-` prefix are ignored during expansion.
289
298
 
@@ -370,20 +379,19 @@ These are build errors:
370
379
 
371
380
  ### Binding
372
381
 
373
- ---- UNEDITED ----
374
-
375
382
  Binding attributes determine how the hub updates the DOM, either by
376
383
  directly updating a plain HTML element or instructing
377
384
  custom widgets to update themselves.
378
385
 
379
386
 
380
- | Attribute | Assigned By | Behavior |
381
- |--------------|-------------|-------------------------------------------------------------------------------------------|
382
- | lb-list | Developer | Scopes DOM children to a named set of rows; a nested lb-list or lb-row begins a new scope |
383
- | lb-row | Developer | Scopes DOM children to one named row; a nested lb-list or lb-row begins a new scope |
384
- | lb-cell | Developer | This DOM node displays this column of the row in scope |
385
- | lb-key | Developer | Names the column that identifies a row, on the row template inside an lb-list |
386
- | lb-key-value | Hub | Stamped on a live row: that row's value of `lb-key` |
387
+ | Attribute | Assigned By | Behavior |
388
+ | ------------ | ----------- | ----------------------------------------------------------------------------------------------- |
389
+ | lb-list | Developer | Scopes DOM children to a named set of rows; a nested lb-list or lb-row begins a new scope |
390
+ | lb-row | Developer | Scopes DOM children to one named row; a nested lb-list or lb-row begins a new scope |
391
+ | lb-cell | Developer | This DOM node displays this column of the row in scope |
392
+ | lb-show | Developer | This DOM node is present when this column of the row in scope is neither null nor false |
393
+ | lb-key | Developer | Names the column that identifies a row, on the row template inside an lb-list |
394
+ | lb-key-value | Hub | Stamped on a live row: that row's value of `lb-key` |
387
395
  | lb-value | Hub | The value that landed on a cell; a widget updates itself from it and a stylesheet selects on it |
388
396
 
389
397
  #### How a value lands
@@ -391,11 +399,11 @@ custom widgets to update themselves.
391
399
  A cell lands one of three ways, and the element decides which. Every cell
392
400
  that receives a value also carries it as `lb-value`.
393
401
 
394
- | Element | Receives the value as |
395
- |-----------------------------------------------------|--------------------------------------|
396
- | A custom element, tag hyphenated | Its `lb-value` attribute |
397
- | `<select>`, `<textarea>`, or `<input>` | Its `value`, and `lb-value` |
398
- | Any other native element | Its `textContent`, and `lb-value` |
402
+ | Element | Receives the value as |
403
+ | -------------------------------------- | --------------------------------- |
404
+ | A custom element, tag hyphenated | Its `lb-value` attribute |
405
+ | `<select>`, `<textarea>`, or `<input>` | Its `value`, and `lb-value` |
406
+ | Any other native element | Its `textContent`, and `lb-value` |
399
407
 
400
408
  A widget owns whatever control it wraps, so it is handed the value and
401
409
  renders it itself. A form control shows its state as its `value`, so a
@@ -433,30 +441,44 @@ A widget sees `attributeChangedCallback` for an `lb-value` already present
433
441
  when it upgrades, so a widget cannot tell a first landing from a refresh,
434
442
  and does not need to.
435
443
 
436
- #### Displaying by value
444
+ #### Displaying by condition
437
445
 
438
- A stylesheet selects on `lb-value` to show or hide part of a page according
439
- to a value that landed. A column the page does not display is bound to a
440
- hidden element.
446
+ `lb-show` names the column that decides whether an element is present.
447
+ `null` and `false` are off, and every other value is on. No string is read,
448
+ so `"false"` is on, and a query spells a condition as a boolean or a null.
441
449
 
442
450
  ```html
443
451
  <template lb-key="id">
444
452
  <tr>
445
453
  <td lb-cell="name"></td>
446
- <td lb-cell="locked" hidden></td>
447
- <td><button lb-action="lb-row-delete">Remove</button></td>
454
+ <td><button lb-action="lb-row-delete" lb-show="removable">Remove</button></td>
448
455
  </tr>
449
456
  </template>
450
457
  ```
451
458
 
452
- ```css
453
- tr:has([lb-cell="locked"][lb-value="true"]) button { display: none; }
454
- ```
459
+ It binds as `lb-cell` does, to the row on the nearest scoped ancestor, and on
460
+ an element that is itself a scope the column belongs to the row around it. A row
461
+ that does not carry the column leaves the element as it is.
455
462
 
456
- `lb-value` holds the string the query sent, so the query decides the spelling
457
- a selector matches. A hidden control is out of reach, keyboard included; a
458
- stylesheet cannot disable one, which is a widget's job. Hiding is
459
- presentation, and the server still refuses what a request may not do.
463
+ An element that is off is moved into a `<template lb-show="column">` standing
464
+ where it stood, and moved back out when the column turns on. It is not
465
+ rendered, focused, clicked, announced or gathered. It is moved and never
466
+ rebuilt, so a widget keeps its instance. Landing reaches into that template,
467
+ and nothing else does, so the element and every cell and scope inside it
468
+ return current. A custom element sees `disconnectedCallback` then
469
+ `adoptedCallback` going in, and `adoptedCallback` then `connectedCallback`
470
+ coming out, and still receives `lb-value` while it is away.
471
+
472
+ The builder ships every `lb-show` element already inside its template, so
473
+ nothing conditional shows until its row lands. An absent element's template
474
+ keeps its place among its siblings, and a position selector counts it.
475
+
476
+ These are build errors: `lb-show` on a row template's root, with no row
477
+ around it (outside every scope, on a scope with none around it, or in a list
478
+ scope outside its row template), or on a `<template>`.
479
+
480
+ Hiding is presentation, and the server still refuses what a request may not
481
+ do.
460
482
 
461
483
  #### Master-detail
462
484
 
@@ -504,7 +526,7 @@ name, the same test that decides how a value lands — see
504
526
  [How a value lands](#how-a-value-lands).
505
527
 
506
528
  | lb-action | Written on |
507
- |----------------|---------------------------------------------------|
529
+ | -------------- | ------------------------------------------------- |
508
530
  | lb-row-insert | a `<form>`, or a button in a `<tr>`, in a list |
509
531
  | lb-row-delete | anything inside a live row |
510
532
  | lb-row-update | a `<form>`, or a button in a live row |
@@ -520,13 +542,13 @@ dispatched it. It reads the scope from the dispatching element before any
520
542
  ancestor sees the event, and never overwrites a field the request already
521
543
  carries.
522
544
 
523
- | `action` | Filled from scope | Required |
524
- |------------------|--------------------------------|----------------------------|
525
- | a declared name | `list` or `row`, `key`, `cell` | nothing |
526
- | `lb-cell-change` | `list`, `key`, `cell` | all three, and `value` |
527
- | `lb-row-insert` | `list` | `list`, and `values` |
528
- | `lb-row-delete` | `list`, `key` | both |
529
- | `lb-row-update` | `list`, `key` | both, and `values` |
545
+ | `action` | Filled from scope | Required |
546
+ | ---------------- | ------------------------------ | ---------------------- |
547
+ | a declared name | `list` or `row`, `key`, `cell` | nothing |
548
+ | `lb-cell-change` | `list`, `key`, `cell` | all three, and `value` |
549
+ | `lb-row-insert` | `list` | `list`, and `values` |
550
+ | `lb-row-delete` | `list`, `key` | both |
551
+ | `lb-row-update` | `list`, `key` | both, and `values` |
530
552
 
531
553
  An element's own `lb-list` or `lb-row` names what it displays, never where
532
554
  its request goes. A request belongs to the scope around the element, the
@@ -624,7 +646,7 @@ other link, so leaving the application is the default and staying in it is
624
646
  the opt-in.
625
647
 
626
648
  | Attribute | Assigned By | Behavior |
627
- |-------------|-------------|-----------------------------------------------------------------------------------------|
649
+ | ----------- | ----------- | --------------------------------------------------------------------------------------- |
628
650
  | lb-nav-link | Developer | On an `<a>`: the hub shows the page the anchor's path names, without loading a document |
629
651
 
630
652
  The attribute takes no value. The hub looks for the nearest ancestor
@@ -677,7 +699,7 @@ Current page, published by the hub as a row. Can be bound anywhere just
677
699
  like a server-produced result.
678
700
 
679
701
  | Cell | Holds |
680
- |--------------|---------------------------------------------------------------------|
702
+ | ------------ | ------------------------------------------------------------------- |
681
703
  | `page-label` | The text of the link to the current page, empty if no link names it |
682
704
  | `page-uri` | The path as the browser has it, such as `/members` |
683
705
 
@@ -799,7 +821,7 @@ client script, the stylesheet, the hub's data channel, and the one HTML
799
821
  document.
800
822
 
801
823
  | Handle | With |
802
- |------------------------------|---------------------|
824
+ | ---------------------------- | ------------------- |
803
825
  | `/client.js` | `dist/client.js` |
804
826
  | `/app.css` | `dist/app.css` |
805
827
  | `hubRoutes(hub, contextFor)` | The hub's own route |
@@ -888,7 +910,7 @@ as explained in the next section.
888
910
  It has three optional keys.
889
911
 
890
912
  | Key | Keyed by | Answers |
891
- |---------------|-----------------------|----------------------------------------------------|
913
+ | ------------- | --------------------- | -------------------------------------------------- |
892
914
  | `actions` | The `lb-action` value | Anything the page chooses to declare |
893
915
  | `crud` | A query name | The four reserved `lb-action` values |
894
916
  | `onPageEnter` | Nothing | Runs once on entering the page, before its queries |
@@ -945,7 +967,7 @@ are one vocabulary. All four operate on a list, because each needs a key and
945
967
  a key exists only on a live row.
946
968
 
947
969
  | `lb-action` | Key under `crud` | `where` carries |
948
- |------------------|------------------|------------------------|
970
+ | ---------------- | ---------------- | ---------------------- |
949
971
  | `lb-cell-change` | `cellChange` | `key`, `cell`, `value` |
950
972
  | `lb-row-delete` | `rowDelete` | `key` |
951
973
  | `lb-row-insert` | `rowInsert` | `values` |
@@ -988,21 +1010,31 @@ The hub stamps these on the element that dispatched a request, which is the
988
1010
  widget itself when a widget fired it. A widget observes them and reacts; it
989
1011
  must name them in `observedAttributes` to see them change.
990
1012
 
991
- | Attribute | Written on | Holds |
992
- |----------------|-------------------------|-------------------------------------------------|
993
- | `lb-pending` | The dispatching element | The round trip is in flight |
1013
+ | Attribute | Written on | Holds |
1014
+ | -------------- | ----------------------- | --------------------------------------------------------------------------------------- |
1015
+ | `lb-pending` | The dispatching element | The round trip is in flight |
994
1016
  | `lb-error` | The dispatching element | The last round trip failed, cleared on the next — see [The round trip](#the-round-trip) |
995
- | `lb-row-count` | A list scope | How many rows the scope is showing |
1017
+ | `lb-row-count` | A list scope | How many rows the scope is showing |
1018
+
1019
+ They are also stamped on plain HTML, where a stylesheet is the only
1020
+ consumer: dim a pending button, mark a failed one, and style an empty list
1021
+ against `lb-row-count` rather than carrying an empty-state element.
1022
+
1023
+ The hub reads one of them. A native `lb-action` element, a button or a
1024
+ form, that is performed again while it carries `lb-pending` is ignored: the
1025
+ click or submit is cancelled and nothing is sent. A pending native action is
1026
+ therefore disabled in fact, and a stylesheet only has to show it. A widget is
1027
+ not held back this way, because a widget that sends on change must have its
1028
+ latest value sent rather than dropped.
996
1029
 
997
- The hub writes all three and never reads them. They are also stamped on
998
- plain HTML, where a stylesheet is the only consumer: dim a pending button,
999
- mark a failed one, and style an empty list against `lb-row-count` rather than
1000
- carrying an empty-state element.
1030
+ Alongside `lb-pending` the hub sets `aria-busy="true"` on the same element and
1031
+ removes it when the round trip settles, so assistive technology hears the
1032
+ state a stylesheet shows.
1001
1033
 
1002
1034
  #### Row hooks
1003
1035
 
1004
1036
  | Name | Implemented By | Behavior |
1005
- |---------------------------------|----------------|-------------------------------------------------------------|
1037
+ | ------------------------------- | -------------- | ----------------------------------------------------------- |
1006
1038
  | `applyRow(root, row)` | Loadbare | Fills one scope from one row |
1007
1039
  | `lbPlaceRow(el, row, template)` | Developer | Optional on a list scope: where a row goes |
1008
1040
  | `lbRowsLanded()` | Developer | Optional on a list scope: scaffolding derived from the rows |
@@ -1027,7 +1059,7 @@ that defines it. The definition lives there and only there.
1027
1059
  Loadbare/app owns every flag in this table.
1028
1060
 
1029
1061
  | Flag | Default | Names | Defined in |
1030
- |------------|---------|-------------------------------------------|---------------------------------------------------|
1062
+ | ---------- | ------- | ----------------------------------------- | ------------------------------------------------- |
1031
1063
  | `--src` | `src` | The application's own tree, scanned whole | [What the builder scans](#what-the-builder-scans) |
1032
1064
  | `--out` | `dist` | Where the builder writes | [Running the builder](#running-the-builder) |
1033
1065
  | `--watch` | off | Rebuild on change under `--src` | [Running the builder](#running-the-builder) |
@@ -1040,7 +1072,7 @@ named carries its meaning wherever it sits in the `--src` tree, so an
1040
1072
  application must not use one of these names for anything else.
1041
1073
 
1042
1074
  | File | How many | Holds | Defined in |
1043
- |-------------------------|------------------------|----------------------------------------------------------|---------------------------------------------------------|
1075
+ | ----------------------- | ---------------------- | -------------------------------------------------------- | ------------------------------------------------------- |
1044
1076
  | `chrome.html` | Exactly one | The application's one HTML document | [Chrome](#chrome) |
1045
1077
  | `imports.ts` | Zero or one | Default-exports an array of widget library package names | [Imported widget libraries](#imported-widget-libraries) |
1046
1078
  | `<stub>.page.html` | One per page | One page's markup, as a fragment | [Pages](#pages) |
@@ -1058,7 +1090,7 @@ only when some origin has a stylesheet, `pages.ts` only when some page has a
1058
1090
  `.queries.ts` or a `.requests.ts`.
1059
1091
 
1060
1092
  | Path | Written | Holds | Read by | Defined in |
1061
- |--------------------|-------------------|--------------------------------------------------------------------|------------|---------------------------------------------|
1093
+ | ------------------ | ----------------- | ------------------------------------------------------------------ | ---------- | ------------------------------------------- |
1062
1094
  | `/app.html` | Always | The chrome, built | The server | [Chrome](#chrome) |
1063
1095
  | `/client.js` | Always | `<lb-hub>` and every widget the application uses | The chrome | [Chrome](#chrome) |
1064
1096
  | `/client-entry.ts` | Always | The generated entry `client.js` is bundled from | Nothing | [Running the builder](#running-the-builder) |
@@ -1071,7 +1103,7 @@ Loadbare/app owns every key in this table. A widget library declares them.
1071
1103
  An application never does.
1072
1104
 
1073
1105
  | Key | Value | Means | Defined in |
1074
- |--------------------|---------------------------|------------------------------------------------------------------------------|---------------------------------------------------------|
1106
+ | ------------------ | ------------------------- | ---------------------------------------------------------------------------- | ------------------------------------------------------- |
1075
1107
  | `loadbare.widgets` | A path inside the package | Where this package's widgets are. Absent means the whole installed directory | [Imported widget libraries](#imported-widget-libraries) |
1076
1108
 
1077
1109
  ### Reserved namespaces
@@ -1079,11 +1111,11 @@ An application never does.
1079
1111
  Loadbare/app owns every namespace in this table. Ownership of a name and
1080
1112
  ownership of its behavior are stated separately, because they differ.
1081
1113
 
1082
- | Namespace | Applies to | Loadbare owns | Defined in |
1083
- |-----------|----------------------------|----------------------------------------------|---------------------------------------------------|
1084
- | `lb-*` | HTML attributes | The names and their behavior | [The lb-* namespace](#the-lb--namespace) |
1085
- | `exp-*` | HTML attributes | The behavior; widget authors pick the values | [Build time parameters](#build-time-parameters) |
1086
- | `lb*` | Methods on custom elements | The names and their behavior | [Row hooks](#row-hooks) |
1114
+ | Namespace | Applies to | Loadbare owns | Defined in |
1115
+ | --------- | -------------------------- | -------------------------------------------- | ----------------------------------------------- |
1116
+ | `lb-*` | HTML attributes | The names and their behavior | [The lb-* namespace](#the-lb--namespace) |
1117
+ | `exp-*` | HTML attributes | The behavior; widget authors pick the values | [Build time parameters](#build-time-parameters) |
1118
+ | `lb*` | Methods on custom elements | The names and their behavior | [Row hooks](#row-hooks) |
1087
1119
 
1088
1120
  #### The lb-* namespace
1089
1121
 
@@ -1097,23 +1129,24 @@ actions on the wire — see [Page Queries](#page-queries).
1097
1129
 
1098
1130
  Each attribute is defined in one section, and this table says which.
1099
1131
 
1100
- | Attribute | Written by | Defined in |
1101
- |------------------|-------------|---------------------------------------------------|
1102
- | `lb-list` | Developer | [Binding](#binding) |
1103
- | `lb-row` | Developer | [Binding](#binding) |
1104
- | `lb-cell` | Developer | [Binding](#binding) |
1105
- | `lb-key` | Developer | [Binding](#binding) |
1106
- | `lb-key-value` | Hub | [Binding](#binding) |
1107
- | `lb-value` | Hub | [How a value lands](#how-a-value-lands) |
1108
- | `lb-action` | Developer | [Requests](#requests) |
1109
- | `lb-nav-link` | Developer | [Links](#links) |
1110
- | `lb-pending` | Hub | [Request state](#request-state) |
1111
- | `lb-error` | Hub | [Request state](#request-state) |
1112
- | `lb-row-count` | Hub | [Request state](#request-state) |
1113
- | `lb-unknown-page`| Developer | [Chrome](#chrome) |
1114
- | `lb-slot` | Widget author | [Slots and templates](#slots-and-templates) |
1115
- | `lb-template` | Widget author | [Slots and templates](#slots-and-templates) |
1116
- | `lb-page` | Builder | [Pages](#pages) |
1132
+ | Attribute | Written by | Defined in |
1133
+ | ----------------- | ------------- | --------------------------------------------------- |
1134
+ | `lb-list` | Developer | [Binding](#binding) |
1135
+ | `lb-row` | Developer | [Binding](#binding) |
1136
+ | `lb-cell` | Developer | [Binding](#binding) |
1137
+ | `lb-show` | Developer | [Displaying by condition](#displaying-by-condition) |
1138
+ | `lb-key` | Developer | [Binding](#binding) |
1139
+ | `lb-key-value` | Hub | [Binding](#binding) |
1140
+ | `lb-value` | Hub | [How a value lands](#how-a-value-lands) |
1141
+ | `lb-action` | Developer | [Requests](#requests) |
1142
+ | `lb-nav-link` | Developer | [Links](#links) |
1143
+ | `lb-pending` | Hub | [Request state](#request-state) |
1144
+ | `lb-error` | Hub | [Request state](#request-state) |
1145
+ | `lb-row-count` | Hub | [Request state](#request-state) |
1146
+ | `lb-unknown-page` | Developer | [Chrome](#chrome) |
1147
+ | `lb-slot` | Widget author | [Slots and templates](#slots-and-templates) |
1148
+ | `lb-template` | Widget author | [Slots and templates](#slots-and-templates) |
1149
+ | `lb-page` | Builder | [Pages](#pages) |
1117
1150
 
1118
1151
  An attribute the builder does not recognize is left alone today. Refusing
1119
1152
  one is on the list of validations still to land — see
@@ -1125,7 +1158,7 @@ Loadbare/app owns every tag in this table. An application writes them and
1125
1158
  never defines them.
1126
1159
 
1127
1160
  | Tag | Written in | Means | Defined in |
1128
- |------------|------------|--------------------------------|-------------------|
1161
+ | ---------- | ---------- | ------------------------------ | ----------------- |
1129
1162
  | `<lb-hub>` | The chrome | The application's live element | [Chrome](#chrome) |
1130
1163
 
1131
1164
  ### Reserved events
@@ -1134,7 +1167,7 @@ Loadbare/app owns every DOM event in this table, both the name and what its
1134
1167
  `detail` carries.
1135
1168
 
1136
1169
  | Event | Dispatched from | Bubbles | Cancelable | Defined in |
1137
- |--------------|------------------------|---------|------------|-----------------------------------------|
1170
+ | ------------ | ---------------------- | ------- | ---------- | --------------------------------------- |
1138
1171
  | `lb-request` | The element that acted | Yes | No | [The request event](#the-request-event) |
1139
1172
 
1140
1173
  ### Reserved attributes
@@ -1143,6 +1176,6 @@ Loadbare/app owns every attribute in this table, both the name and its
1143
1176
  behavior.
1144
1177
 
1145
1178
  | Attribute | Written on | Takes a value | Defined in |
1146
- |-------------------|-------------------------------------|---------------|-------------------|
1179
+ | ----------------- | ----------------------------------- | ------------- | ----------------- |
1147
1180
  | `lb-unknown-page` | A `<dialog>` in chrome | No | [Chrome](#chrome) |
1148
1181
  | `lb-page` | A `<template>`, by the builder only | Yes | [Pages](#pages) |