@loadbare/app 0.19.0 → 0.20.0
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.
- package/dist/build/assemble.d.ts.map +1 -1
- package/dist/build/assemble.js +28 -2
- package/dist/build/assemble.js.map +1 -1
- package/dist/core/lb-constants.d.ts +7 -2
- package/dist/core/lb-constants.d.ts.map +1 -1
- package/dist/core/lb-constants.js +30 -4
- package/dist/core/lb-constants.js.map +1 -1
- package/dist/hub/lb-apply.d.ts +21 -0
- package/dist/hub/lb-apply.d.ts.map +1 -1
- package/dist/hub/lb-apply.js +221 -30
- package/dist/hub/lb-apply.js.map +1 -1
- package/dist/hub/lb-hub.browser.d.ts.map +1 -1
- package/dist/hub/lb-hub.browser.js +26 -6
- package/dist/hub/lb-hub.browser.js.map +1 -1
- package/docs/comparison.md +23 -13
- package/docs/opinions.md +2 -2
- package/docs/reference/builder.md +11 -2
- package/docs/reference/chrome.md +83 -9
- package/docs/reference/css.md +0 -1
- package/docs/reference/custom-elements.md +7 -28
- package/docs/reference/data-binding.md +320 -50
- package/docs/reference/names.md +258 -0
- package/docs/reference/overview.md +6 -0
- package/docs/reference/page-files.md +47 -10
- package/docs/reference/server.md +54 -1
- package/docs/reference/widgets.md +10 -1
- package/docs/testing.md +5 -1
- package/docs/tutorials/040-displaying-data.md +1 -1
- package/package.json +1 -1
- package/skills/loadbare-app/SKILL.md +26 -14
- package/skills/loadbare-app/references/builder.md +11 -2
- package/skills/loadbare-app/references/chrome.md +83 -9
- package/skills/loadbare-app/references/css.md +0 -1
- package/skills/loadbare-app/references/custom-elements.md +7 -28
- package/skills/loadbare-app/references/data-binding.md +320 -50
- package/skills/loadbare-app/references/names.md +258 -0
- package/skills/loadbare-app/references/overview.md +6 -0
- package/skills/loadbare-app/references/page-files.md +47 -10
- package/skills/loadbare-app/references/server.md +54 -1
- package/skills/loadbare-app/references/widgets.md +10 -1
- package/docs/TECHREF-1.0.md +0 -2267
- package/skills/loadbare-app/references/TECHREF-1.0.md +0 -2267
package/docs/reference/chrome.md
CHANGED
|
@@ -60,6 +60,7 @@ Everything else is optional:
|
|
|
60
60
|
|-------------------------------------------|---------------------------------------------|
|
|
61
61
|
| `<link rel="stylesheet" href="/app.css">` | The bundled stylesheet |
|
|
62
62
|
| `<a lb-url-link>` | A link between pages |
|
|
63
|
+
| `<a lb-url-link lb-url-parm>` | A link carrying columns of its row |
|
|
63
64
|
| `lb-query="lb-url"` | Where the page is — see below |
|
|
64
65
|
| `<dialog lb-url-unknown>` | A message when a URL matches no page |
|
|
65
66
|
| Custom elements | The chrome, decomposed into element files |
|
|
@@ -103,6 +104,12 @@ server's row lands, so a chrome shows where the page is with no code:
|
|
|
103
104
|
| `lb-page-unknown` | `true` when no page's stub matches the path |
|
|
104
105
|
| Any other name | The query parm of that name, or empty when it is absent |
|
|
105
106
|
|
|
107
|
+
The path names a page, never a resource: `/accounts/42` is not a way to
|
|
108
|
+
reach account 42, and an application designs no endpoints. The query string
|
|
109
|
+
describes what that page has on screen, `/accounts?acct=23`, and never
|
|
110
|
+
commands. The server remembers nothing about the view, so a URL reloads,
|
|
111
|
+
bookmarks and mails as the same view.
|
|
112
|
+
|
|
106
113
|
A path names a page by its stub: `/members` shows `members.page.html`, and
|
|
107
114
|
`/` shows `index.page.html`. A page's title is the text of the `<title>` its
|
|
108
115
|
page file carries; see [page files](./page-files.md#the-page-title). The hub
|
|
@@ -139,11 +146,56 @@ Write `lb-url-link` on an `<a>` to move between pages:
|
|
|
139
146
|
</nav>
|
|
140
147
|
```
|
|
141
148
|
|
|
142
|
-
On a plain primary click, the
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
the browser has them behave
|
|
146
|
-
|
|
149
|
+
On a plain primary click, the first button with no modifier key and not
|
|
150
|
+
already handled, the hub pushes a history entry for the `href`, path and
|
|
151
|
+
query string both, and shows the page it names. Any other click, and a link
|
|
152
|
+
without `lb-url-link`, behave as the browser has them behave, so leaving the
|
|
153
|
+
application is the default and staying in it is the opt-in. The attribute
|
|
154
|
+
takes no value. Back and Forward show the page at the URL they arrive at.
|
|
155
|
+
|
|
156
|
+
Path space is flat: `/members` shows `members.page.html` wherever under
|
|
157
|
+
`--src` it sits. The query string is kept, so
|
|
158
|
+
`/transactions?date_begin=2026-09-01` opens the page narrowed to those
|
|
159
|
+
dates.
|
|
160
|
+
|
|
161
|
+
### A link from a row
|
|
162
|
+
|
|
163
|
+
Write `lb-url-parm` on an `<a lb-url-link>` inside a row to carry columns
|
|
164
|
+
of that row to the page the link names. It names columns, separated by
|
|
165
|
+
commas, and the hub adds each to the link's query string as the parm of the
|
|
166
|
+
same name:
|
|
167
|
+
|
|
168
|
+
```html
|
|
169
|
+
<table lb-query="topics">
|
|
170
|
+
<template>
|
|
171
|
+
<tr>
|
|
172
|
+
<td lb-column="title"></td>
|
|
173
|
+
<td><a href="/events" lb-url-link lb-url-parm="topic_id" lb-column="times_presented"></a></td>
|
|
174
|
+
</tr>
|
|
175
|
+
</template>
|
|
176
|
+
</table>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
In topic 5's row the link is `<a href="/events?topic_id=5">`. The `href` is
|
|
180
|
+
written when the row lands and rewritten when it changes, so hovering,
|
|
181
|
+
copying, a middle click and a plain click all go to the same place.
|
|
182
|
+
|
|
183
|
+
- The parm is the column. Where the names differ, the row's query renames
|
|
184
|
+
the column in its SQL: `select id as topic_id`.
|
|
185
|
+
- The hub reads the row it holds, so a column no element shows is carried
|
|
186
|
+
as well as one that is.
|
|
187
|
+
- The `href` as written is the base. Its path, its parms and its fragment
|
|
188
|
+
are kept, and a named column replaces a parm of the same name.
|
|
189
|
+
- A null, empty or missing column leaves its parm off, as an empty value
|
|
190
|
+
takes a parm out of the URL. A string is written as it is, a number or a
|
|
191
|
+
boolean as JSON writes it, and any other value is left off and reported
|
|
192
|
+
on the console, as is a named column the row does not have.
|
|
193
|
+
- The row is the nearest around the link: a live row, or an element a `row`
|
|
194
|
+
landed on.
|
|
195
|
+
|
|
196
|
+
`lb-url-parm` goes only on a link carrying `lb-url-link`, since the parms it
|
|
197
|
+
writes are the application's own; see
|
|
198
|
+
[The markup checks](./data-binding.md#the-markup-checks).
|
|
147
199
|
|
|
148
200
|
### Query parms
|
|
149
201
|
|
|
@@ -170,11 +222,28 @@ pushes one instead when the element carrying `lb-request` also carries
|
|
|
170
222
|
|
|
171
223
|
The hub answers the request itself, with no round trip, then reloads the
|
|
172
224
|
page's queries at the new URL. The page stays in place, and rows that come
|
|
173
|
-
back keep their place.
|
|
225
|
+
back keep their place. A request that leaves the URL as it was does
|
|
226
|
+
nothing. `lb-page-label` and `lb-page-unknown` are the hub's, and a request
|
|
227
|
+
never sets them.
|
|
228
|
+
|
|
229
|
+
A request that gives `lb-path` a new value enters that page, pushes a
|
|
230
|
+
history entry, and the new URL carries only the query parms the request
|
|
231
|
+
names.
|
|
174
232
|
|
|
175
233
|
A control whose column the URL does not carry lands empty, so every control
|
|
176
234
|
inside `lb-query="lb-url"` shows what the address bar says, after a reload
|
|
177
|
-
and after Back alike
|
|
235
|
+
and after Back alike
|
|
236
|
+
([miswart](../miswarts.md#lb-url-lands-every-parm-it-names)).
|
|
237
|
+
|
|
238
|
+
Loadbare assigns no parm a meaning, and a column of `lb-url` whose name
|
|
239
|
+
begins with `lb-` is never a query parm.
|
|
240
|
+
|
|
241
|
+
A query parm is user input. A query still takes no argument from the
|
|
242
|
+
browser, and a parm arrives the way the session cookie does, as part of the
|
|
243
|
+
request the context is built from, but a user who types `?acct=99999`
|
|
244
|
+
influences what a query returns. Validate it where the application reads
|
|
245
|
+
it; a per-session database role means an id outside the caller's reach
|
|
246
|
+
finds nothing.
|
|
178
247
|
|
|
179
248
|
An order or a filter the hub applies to rows the page already holds is not
|
|
180
249
|
a query parm. It is a [choice](./data-binding.md#choices), which holds until
|
|
@@ -198,8 +267,13 @@ show the path:
|
|
|
198
267
|
```
|
|
199
268
|
|
|
200
269
|
When no page's stub matches the path, `lb-page-unknown` is `true`,
|
|
201
|
-
`lb-page-label` is null, `<main>` keeps the page it had,
|
|
202
|
-
`showModal()` on the dialog.
|
|
270
|
+
`lb-page-label` is null, `<main>` keeps the page it had, the hub calls
|
|
271
|
+
`showModal()` on the dialog, and reports the path to the console. A chrome
|
|
272
|
+
with no dialog shows nothing. `lb-url` lands before the page is looked up,
|
|
273
|
+
so the dialog shows the path by naming it like any other element.
|
|
274
|
+
|
|
275
|
+
Every route gets the same document, so an unknown path is found out in the
|
|
276
|
+
browser after a successful 200, and there is no server-delivered 404.
|
|
203
277
|
|
|
204
278
|
`@loadbare/widgets` ships this dialog as `<lb-unknown-page>`, for a chrome
|
|
205
279
|
that would rather write one tag; see
|
package/docs/reference/css.md
CHANGED
|
@@ -41,7 +41,6 @@ Serve it at `/app.css` and link it from the chrome:
|
|
|
41
41
|
See [`chrome.html`](./chrome.md) for the link, [The Express
|
|
42
42
|
server](./server.md) for the route, and
|
|
43
43
|
[`loadbare-app-build`](./builder.md#running-the-builder) for `--minify`.
|
|
44
|
-
</content>
|
|
45
44
|
|
|
46
45
|
## Selecting what the hub stamps
|
|
47
46
|
|
|
@@ -250,30 +250,8 @@ takes part in data binding in one of four ways: it is a control, it renders
|
|
|
250
250
|
a value, it sends a request, or it holds rows.
|
|
251
251
|
|
|
252
252
|
Import every Loadbare name from `@loadbare/app/constants`, and never write
|
|
253
|
-
one as a string literal:
|
|
254
|
-
|
|
255
|
-
| Constant | Value |
|
|
256
|
-
|------------------------|----------------------|
|
|
257
|
-
| `ATTR_QUERY` | `lb-query` |
|
|
258
|
-
| `ATTR_COLUMN` | `lb-column` |
|
|
259
|
-
| `ATTR_SHOW` | `lb-show` |
|
|
260
|
-
| `ATTR_REQUEST` | `lb-request` |
|
|
261
|
-
| `ATTR_COLUMN_VALUE` | `lb-column-value` |
|
|
262
|
-
| `ATTR_KEY_VALUE` | `lb-key-value` |
|
|
263
|
-
| `ATTR_ROW_LIVE` | `lb-row-live` |
|
|
264
|
-
| `LIVE_ROW` | `[lb-row-live]` |
|
|
265
|
-
| `ATTR_QUERY_ROW_COUNT` | `lb-query-row-count` |
|
|
266
|
-
| `ATTR_REQUEST_PENDING` | `lb-request-pending` |
|
|
267
|
-
| `ATTR_REQUEST_ERROR` | `lb-request-error` |
|
|
268
|
-
| `REQUEST_ROW_INSERT`, `REQUEST_ROW_UPDATE`, `REQUEST_ROW_DELETE` | The requests Loadbare provides |
|
|
269
|
-
| `LB_ROW_REQUESTS` | All three, in one array |
|
|
270
|
-
| `LB_EVENT_NAME` | `lb-request`, the event every request travels as |
|
|
271
|
-
| `LB_DONE_EVENT_NAME` | `lb-request-done`, the event that says how it turned out |
|
|
272
|
-
| `SHOW_NOT` | `!`, written before a column in `lb-show` |
|
|
273
|
-
| `URL_QUERY` | `lb-url` |
|
|
274
|
-
| `CHOICES_QUERY` | `lb-choices` |
|
|
275
|
-
| `URL_COLUMN_PATH`, `URL_COLUMN_PAGE_LABEL`, `URL_COLUMN_PAGE_UNKNOWN` | `lb-path`, `lb-page-label`, `lb-page-unknown` |
|
|
276
|
-
| `LB_RESERVED_PREFIX` | `lb-` |
|
|
253
|
+
one as a string literal: `ATTR_COLUMN_VALUE` rather than `"lb-column-value"`.
|
|
254
|
+
[Constants](./names.md#constants) lists them all.
|
|
277
255
|
|
|
278
256
|
A custom element reads `lb-` attributes and never assigns one. The developer
|
|
279
257
|
writes them in markup, and the hub and the builder write their stamps.
|
|
@@ -290,7 +268,7 @@ Each direction has one mechanism for each kind of message:
|
|
|
290
268
|
|
|
291
269
|
| Direction | What | How | Today |
|
|
292
270
|
|----------------|--------------------------------------------|-----------------------------|-------|
|
|
293
|
-
| Hub to element | State that lasts | An attribute the hub stamps | `lb-column-value`, `lb-key-value`, `lb-query-row-count`, `lb-group-*`, `lb-row-*`, `lb-request-pending`, `lb-request-error`, `lb-request-refused` |
|
|
271
|
+
| Hub to element | State that lasts | An attribute the hub stamps | `lb-column-value`, `lb-key-value`, `lb-query-row-count`, `lb-query-unsorted-count`, `lb-query-order`, `lb-group-*`, `lb-row-*`, `lb-request-pending`, `lb-request-error`, `lb-request-refused` |
|
|
294
272
|
| Hub to element | State the platform already names | A property | A control's `value` |
|
|
295
273
|
| Hub to element | What the hub did | An optional `lb` method | `lbAttached`, `lbRowsLanded`, `lbRequestDone`, `lbDetached` |
|
|
296
274
|
| Hub to element | A moment an element started | A bubbling event | `lb-request-done` |
|
|
@@ -649,7 +627,8 @@ had there hears the event, and no custom element the hub has removed hears
|
|
|
649
627
|
### Holding rows
|
|
650
628
|
|
|
651
629
|
The hub lands every row template itself, places every row by the query's
|
|
652
|
-
order
|
|
630
|
+
order (see [Rows the user is working in](./data-binding.md#rows-the-user-is-working-in)
|
|
631
|
+
for when it does not), and builds every group the markup's group templates describe; see
|
|
653
632
|
[Order](./data-binding.md#order) and [Groups](./data-binding.md#groups). A
|
|
654
633
|
plain element carrying `lb-query` with a row template inside it needs no
|
|
655
634
|
code, so a custom element holds rows only to do something with them once
|
|
@@ -677,12 +656,12 @@ Everything else is the hub's:
|
|
|
677
656
|
|-------------|----------------------------------------------------------|
|
|
678
657
|
| Cloning | Clones the row template once per new key |
|
|
679
658
|
| Matching | Fills the live row already showing that key, when its values changed |
|
|
680
|
-
| Placing | Places every live row by the user's order or the query's |
|
|
659
|
+
| Placing | Places every live row by the user's order or the query's, and leaves them where they stand for an edit from inside the list |
|
|
681
660
|
| Filtering | Hides a row the user's filter does not pass, and a group whose rows are all hidden |
|
|
682
661
|
| Grouping | Builds a group where the order breaks, keeps it while its run goes on, and removes it with its last row |
|
|
683
662
|
| Removing | Marks the live rows the response says are gone as leaving, and removes them |
|
|
684
663
|
| Stamping | Stamps each live row with `lb-row-live`, `lb-key-value`, and what happened to it |
|
|
685
|
-
| Counting | Stamps `lb-query-row-count` with the number of live rows showing |
|
|
664
|
+
| Counting | Stamps `lb-query-row-count` with the number of live rows showing, `lb-query-unsorted-count` with the number out of order, and `lb-query-order` with the order placing them |
|
|
686
665
|
|
|
687
666
|
`lb-options.browser.ts` and `lb-table.browser.ts` in
|
|
688
667
|
[`@loadbare/widgets`](./widgets.md) are two uses of `lbRowsLanded`: one
|