@loadbare/app 0.13.0 → 0.15.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 +31 -1
- package/dist/build/assemble.js.map +1 -1
- package/dist/build/elements.d.ts +12 -2
- package/dist/build/elements.d.ts.map +1 -1
- package/dist/build/elements.js +44 -10
- package/dist/build/elements.js.map +1 -1
- package/dist/core/lb-constants.d.ts +13 -2
- package/dist/core/lb-constants.d.ts.map +1 -1
- package/dist/core/lb-constants.js +50 -3
- package/dist/core/lb-constants.js.map +1 -1
- package/dist/core/lb-types.d.ts +52 -8
- package/dist/core/lb-types.d.ts.map +1 -1
- package/dist/core/lb-types.js.map +1 -1
- package/dist/hub/lb-apply.d.ts +22 -3
- package/dist/hub/lb-apply.d.ts.map +1 -1
- package/dist/hub/lb-apply.js +82 -37
- 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 +382 -26
- package/dist/hub/lb-hub.browser.js.map +1 -1
- package/dist/hub/lb-lifecycle.d.ts +40 -0
- package/dist/hub/lb-lifecycle.d.ts.map +1 -0
- package/dist/hub/lb-lifecycle.js +140 -0
- package/dist/hub/lb-lifecycle.js.map +1 -0
- package/dist/server/lb-express.d.ts +13 -3
- package/dist/server/lb-express.d.ts.map +1 -1
- package/dist/server/lb-express.js +30 -12
- package/dist/server/lb-express.js.map +1 -1
- package/dist/server/lb-server.d.ts +31 -1
- package/dist/server/lb-server.d.ts.map +1 -1
- package/dist/server/lb-server.js +112 -2
- package/dist/server/lb-server.js.map +1 -1
- package/docs/TECHREF-1.0.md +343 -68
- package/docs/comparison.md +13 -9
- package/docs/possible-ideas.md +152 -26
- package/docs/reference/custom-elements.md +203 -88
- package/docs/reference/data-binding.md +310 -11
- package/docs/reference/page-files.md +76 -3
- package/docs/reference/server.md +20 -0
- package/docs/reference/widgets.md +35 -12
- package/docs/roadmap.md +9 -2
- package/docs/testing.md +2 -2
- package/package.json +1 -1
- package/skills/loadbare-app/SKILL.md +70 -23
- package/skills/loadbare-app/references/TECHREF-1.0.md +343 -68
- package/skills/loadbare-app/references/custom-elements.md +203 -88
- package/skills/loadbare-app/references/data-binding.md +310 -11
- package/skills/loadbare-app/references/page-files.md +76 -3
- package/skills/loadbare-app/references/server.md +20 -0
- package/skills/loadbare-app/references/widgets.md +35 -12
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: loadbare-app
|
|
3
|
-
description: Build server-bound web applications with Loadbare/app. Covers the file conventions the builder finds by name (`chrome.html`, `*.page.html`, `*.queries.ts`, `*.requests.ts`, `imports.ts`, `<tag>.html`, `<tag>.browser.ts`); the `lb-*` attribute vocabulary that lands query rows on HTML and issues requests (`lb-query`, `lb-column`, `lb-show`, `lb-request`); queries declared with `row(key, run)` and `rows(key, run)`; the URL as the hub's own query `lb-url`, with `lb-url-link`, `lb-url-push` and `lb-url-unknown`; build-time expansion with `exp-*` parameters, `lb-exp-slot` and `lb-exp-template`; custom elements as form-associated controls and row hosts; the Express wiring with `hubRoutes`; and the `@loadbare/widgets` library. Use whenever a task involves `@loadbare/app`, `@loadbare/widgets`, `loadbare-app-build`, an `lb-` attribute, or a page, query, request or custom element file in a Loadbare application. The model is not React, htmx or REST, and cannot be inferred from them.
|
|
3
|
+
description: Build server-bound web applications with Loadbare/app. Covers the file conventions the builder finds by name (`chrome.html`, `*.page.html`, `*.queries.ts`, `*.requests.ts`, `imports.ts`, `<tag>.html`, `<tag>.browser.ts`); the `lb-*` attribute vocabulary that lands query rows on HTML and issues requests (`lb-query`, `lb-column`, `lb-show`, `lb-request`); queries declared with `row(key, run)` and `rows(key, run)`; the URL as the hub's own query `lb-url`, with `lb-url-link`, `lb-url-push` and `lb-url-unknown`; one form pointed at a row by the `--lb-edit`, `--lb-new` and `--lb-release` commands; build-time expansion with `exp-*` parameters, `lb-exp-slot` and `lb-exp-template`; custom elements as form-associated controls and row hosts; the Express wiring with `hubRoutes`; and the `@loadbare/widgets` library. Use whenever a task involves `@loadbare/app`, `@loadbare/widgets`, `loadbare-app-build`, an `lb-` attribute, or a page, query, request or custom element file in a Loadbare application. The model is not React, htmx or REST, and cannot be inferred from them.
|
|
4
4
|
license: Apache-2.0
|
|
5
5
|
metadata:
|
|
6
6
|
package: "@loadbare/app"
|
|
@@ -178,7 +178,11 @@ from it.
|
|
|
178
178
|
query under two names. Many masters with their details is one `rows` query
|
|
179
179
|
of joined rows, ordered by the master first and shown in groups. A
|
|
180
180
|
query nested inside another query's row template receives the same rows in
|
|
181
|
-
every outer row; use it for a picker, never for per-row detail.
|
|
181
|
+
every outer row; use it for a picker, never for per-row detail. Inside a
|
|
182
|
+
form, the live rows of a query nested in the form's own are gathered as
|
|
183
|
+
`rows: { <query>: [{ key, values }] }` beside `values`, so a master and a
|
|
184
|
+
subtable of its details (one input per type, say) are entered in one
|
|
185
|
+
submit, and the master's handler writes both. A new outer
|
|
182
186
|
row is filled from the nested query's last answer, whatever order they land
|
|
183
187
|
in.
|
|
184
188
|
|
|
@@ -206,7 +210,8 @@ leaving row or group `lb-row-leaving` or `lb-group-leaving`, removing it once
|
|
|
206
210
|
its animations end. Scrolling to a row is script, in `lbRowsLanded`.
|
|
207
211
|
|
|
208
212
|
**Every request has one shape.** `lb-request` names the request, and the
|
|
209
|
-
hub sends `{ name, query, key, values }` as present
|
|
213
|
+
hub sends `{ name, query, key, values }` as present, with `keys` in place
|
|
214
|
+
of `key` for the rows the user selected: `query` from the
|
|
210
215
|
nearest ancestor `lb-query`, `key` from the nearest ancestor row of that
|
|
211
216
|
query, and `values` gathered from controls by their `lb-column`.
|
|
212
217
|
|
|
@@ -224,15 +229,27 @@ with `lb-column` gathers its own value alone. A `<form>` gathers every
|
|
|
224
229
|
control whose form owner it is. An element in a live row gathers that live
|
|
225
230
|
row. Anything else gathers its form owner's controls. A `<form>` cannot
|
|
226
231
|
wrap a `<tr>`, so an insert row in a table puts its controls in a form
|
|
227
|
-
elsewhere with the HTML `form` attribute.
|
|
228
|
-
|
|
229
|
-
|
|
232
|
+
elsewhere with the HTML `form` attribute. A checkbox is a control: checked
|
|
233
|
+
unless its column is `false` or null, and gathered as `"true"` or `"false"`.
|
|
234
|
+
Radio buttons and file inputs are not controls here: they receive no value
|
|
235
|
+
and are not gathered.
|
|
230
236
|
|
|
231
237
|
**A form that adds to a set chosen elsewhere is written once, outside every
|
|
232
238
|
row.** A form cannot sit inside another form or in a table row, so a dialog
|
|
233
239
|
that creates an account while a posting's picker is choosing one goes at the
|
|
234
240
|
end of the page, and each row opens it with `commandfor`. The dialog learns
|
|
235
|
-
the new key
|
|
241
|
+
the new key in `lbRequestDone`.
|
|
242
|
+
|
|
243
|
+
**A set the user edits has one form, pointed at a row.** Never put a form
|
|
244
|
+
in every row. Write one form naming the set's query, outside every row,
|
|
245
|
+
often in a `<dialog>`, and give it an `id`. A `type="button"` with
|
|
246
|
+
`commandfor="<id>"` and `command="--lb-edit"` in a live row fills it from
|
|
247
|
+
that row with no round trip; `--lb-new` starts it empty for an insert;
|
|
248
|
+
`--lb-release` lets it go. The form's `lb-key-value` is the row's key, empty
|
|
249
|
+
for a new row, absent when not in use, and a stylesheet shows Save or Save
|
|
250
|
+
new by it. A successful request from the form, or its dialog closing, lets
|
|
251
|
+
it go. Which row is being edited is never a query parm. A row that must be
|
|
252
|
+
fetched to be edited is another page, with that row as its master.
|
|
236
253
|
|
|
237
254
|
**Three requests are Loadbare's.** `lb-row-insert` needs `query` and
|
|
238
255
|
`values`, `lb-row-update` needs `query`, `key` and `values`, and
|
|
@@ -242,6 +259,32 @@ Each works on a `row` query as well as a `rows` query, since the element a
|
|
|
242
259
|
`row` lands on carries its key. Every other request name is a declared
|
|
243
260
|
request, under `handlers`. Anything undeclared is refused.
|
|
244
261
|
|
|
262
|
+
**An empty key is a row not yet entered.** A `row` query answering with an
|
|
263
|
+
empty key, or a form `--lb-new` pointed, carries `lb-key-value=""`. The hub
|
|
264
|
+
sends inserts and declared requests from it with no `key`, and sends no
|
|
265
|
+
update or delete at all, silently. So a control with
|
|
266
|
+
`lb-request="lb-row-update"` saves on a row on record and only holds its
|
|
267
|
+
value on a new one. Never write script to stop such an update.
|
|
268
|
+
|
|
269
|
+
**Select rows with `lb-select`, never with a column.** An
|
|
270
|
+
`<input type="checkbox" lb-select>` in a row template selects its row; the
|
|
271
|
+
hub stamps `lb-row-selected`. A request for that query naming no one row,
|
|
272
|
+
such as a form outside the rows, carries the ticked rows as `keys`.
|
|
273
|
+
`rowUpdate` and `rowDelete` then run once per key with no new code; a
|
|
274
|
+
declared request gets `keys` itself. With none ticked an update or delete
|
|
275
|
+
is not sent. Success clears the selection, and so does `lb-show` hiding a
|
|
276
|
+
selector. A selecting mode kept in the URL reaches the rows as a column the
|
|
277
|
+
query computes from the parm.
|
|
278
|
+
|
|
279
|
+
**Refuse with `refusal()`, never with a plain throw.** `throw
|
|
280
|
+
refusal("message")`, `throw refusal({ column: "message" })` or both, from
|
|
281
|
+
`@loadbare/app/server`. The whole-request message lands as the
|
|
282
|
+
`lb-request-refused` stamp on the element that committed, shown by CSS
|
|
283
|
+
`attr()`; each column's message goes on its control by
|
|
284
|
+
`setCustomValidity`, and the first is reported. Editing anything the
|
|
285
|
+
request gathered withdraws it all. Any other throw is a failure with no
|
|
286
|
+
message, so a database error never reaches the page.
|
|
287
|
+
|
|
245
288
|
**Write `rowUpdate` as a partial update.** A form sends every control it
|
|
246
289
|
owns; a single control sends its one column. Set the columns `values`
|
|
247
290
|
names, leave the rest alone, and check the names against the columns the
|
|
@@ -344,25 +387,29 @@ element (`static formAssociated = true`) with a `value` property that fires
|
|
|
344
387
|
on `change`. Any other custom element keeps its content and receives the
|
|
345
388
|
column as its `lb-column-value` attribute.
|
|
346
389
|
|
|
347
|
-
**A custom element
|
|
348
|
-
hub
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
390
|
+
**A custom element hears the hub's lifecycle, never the browser's.** The
|
|
391
|
+
hub calls `lbAttached()` once when it places the element, already filled,
|
|
392
|
+
and `lbDetached()` once when it removes it. Moving a row and turning
|
|
393
|
+
`lb-show` off and on call neither, and the instance is kept. Never write
|
|
394
|
+
`connectedCallback`, `disconnectedCallback`, `adoptedCallback` or
|
|
395
|
+
`connectedMoveCallback`; the build refuses them. Listen on the element
|
|
396
|
+
itself in the constructor, look a child up when it is needed, and put
|
|
397
|
+
once-per-instance setup in `lbAttached` with its undoing in `lbDetached`.
|
|
353
398
|
|
|
354
399
|
**The hub and a custom element talk in four ways, one per kind of
|
|
355
400
|
message.** State the hub gives an element is an attribute stamp, or `value`
|
|
356
|
-
on a control.
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
`lb-request
|
|
360
|
-
|
|
361
|
-
|
|
401
|
+
on a control. What the hub did to an element is an optional `lb` method:
|
|
402
|
+
`lbAttached`, `lbRowsLanded`, `lbRequestDone`, `lbDetached`, declared by
|
|
403
|
+
`HubLifecycle`. A moment is a bubbling event: an element sends
|
|
404
|
+
`lb-request`, and the hub answers by calling `lbRequestDone(detail,
|
|
405
|
+
origin)` on the custom elements from the committing element outward, then
|
|
406
|
+
dispatching `lb-request-done` from it, each carrying the request and the
|
|
407
|
+
response items that landed, or the error. A dialog choosing the row its
|
|
408
|
+
form just created implements `lbRequestDone`.
|
|
362
409
|
|
|
363
410
|
**A widget that holds rows may sit under `lb-show`.** Rows that land while
|
|
364
|
-
it is away are placed by the hub
|
|
365
|
-
|
|
411
|
+
it is away are placed by the hub and its `lbRowsLanded` runs, so hide a
|
|
412
|
+
table with `lb-show`, not with a stylesheet rule.
|
|
366
413
|
|
|
367
414
|
**Name a custom element script `<tag>.browser.ts`.** A plain `<tag>.ts`
|
|
368
415
|
stays on the server and the tag goes unregistered.
|
|
@@ -391,11 +438,11 @@ parser loses the tag before the build can report it.
|
|
|
391
438
|
Reach for one only when plain HTML cannot do the job. A set of rows, a form
|
|
392
439
|
and a condition need none. A custom element exists to be a control of its
|
|
393
440
|
own, or to act on rows once they land through the hook the hub calls,
|
|
394
|
-
`lbRowsLanded` (the `
|
|
441
|
+
`lbRowsLanded` (the `HubLifecycle` interface).
|
|
395
442
|
|
|
396
443
|
Before writing one, check `@loadbare/widgets`: `lb-input`, `lb-select`,
|
|
397
444
|
`lb-options`, `lb-picker`, `lb-table`, `lb-unknown-page`, `lb-confirm`,
|
|
398
|
-
`lb-form`, `lb-insert-dialog`, `lb-master`. The first four are
|
|
445
|
+
`lb-form`, `lb-insert-dialog`, `lb-master`, `lb-checkbox`. The first four are
|
|
399
446
|
form-associated controls that carry `lb-column` and `lb-request`
|
|
400
447
|
themselves. Install the package and list it in `src/imports.ts`:
|
|
401
448
|
|