@loadbare/app 0.26.0 → 0.27.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.
Files changed (40) hide show
  1. package/dist/build/assemble.d.ts.map +1 -1
  2. package/dist/build/assemble.js +37 -1
  3. package/dist/build/assemble.js.map +1 -1
  4. package/dist/core/lb-constants.d.ts +14 -2
  5. package/dist/core/lb-constants.d.ts.map +1 -1
  6. package/dist/core/lb-constants.js +42 -6
  7. package/dist/core/lb-constants.js.map +1 -1
  8. package/dist/hub/lb-apply.d.ts +5 -2
  9. package/dist/hub/lb-apply.d.ts.map +1 -1
  10. package/dist/hub/lb-apply.js +402 -78
  11. package/dist/hub/lb-apply.js.map +1 -1
  12. package/dist/hub/lb-hub.browser.d.ts.map +1 -1
  13. package/dist/hub/lb-hub.browser.js +1 -2
  14. package/dist/hub/lb-hub.browser.js.map +1 -1
  15. package/dist/hub/lb-lifecycle.d.ts +2 -2
  16. package/dist/hub/lb-lifecycle.d.ts.map +1 -1
  17. package/dist/hub/lb-lifecycle.js +6 -5
  18. package/dist/hub/lb-lifecycle.js.map +1 -1
  19. package/docs/comparison.md +29 -22
  20. package/docs/miswarts.md +2 -2
  21. package/docs/opinions.md +2 -2
  22. package/docs/reference/chrome.md +8 -10
  23. package/docs/reference/css.md +20 -8
  24. package/docs/reference/custom-elements.md +19 -14
  25. package/docs/reference/data-binding.md +163 -61
  26. package/docs/reference/names.md +23 -8
  27. package/docs/reference/page-files.md +25 -16
  28. package/docs/reference/server.md +3 -3
  29. package/docs/roadmap.md +2 -2
  30. package/docs/testing.md +8 -6
  31. package/package.json +1 -1
  32. package/skills/loadbare-app/SKILL.md +16 -7
  33. package/skills/loadbare-app/references/chrome.md +8 -10
  34. package/skills/loadbare-app/references/css.md +20 -8
  35. package/skills/loadbare-app/references/custom-elements.md +19 -14
  36. package/skills/loadbare-app/references/data-binding.md +163 -61
  37. package/skills/loadbare-app/references/miswarts.md +2 -2
  38. package/skills/loadbare-app/references/names.md +23 -8
  39. package/skills/loadbare-app/references/page-files.md +25 -16
  40. package/skills/loadbare-app/references/server.md +3 -3
@@ -68,7 +68,7 @@ gathered.
68
68
  ## Rows hidden by a filter
69
69
 
70
70
  **What.** A row that does not pass the user's filter gets the `hidden`
71
- attribute.
71
+ attribute, and so does a group whose rows are all hidden.
72
72
 
73
73
  **Rule broken.** The hub writes only its own stamps, which always
74
74
  begin with `lb-`.
@@ -78,7 +78,7 @@ over rows already on the page needs no round trip, and `hidden` is HTML's
78
78
  own word for an element that is present but not shown. A stamp of our
79
79
  own would make every stylesheet restate what the browser already does.
80
80
 
81
- **Why it terminates.** It applies only to live rows under a
81
+ **Why it terminates.** It applies only to live rows and groups under a
82
82
  filter.
83
83
 
84
84
  ## Leaving rows are inert
@@ -65,7 +65,7 @@ A widget package declares these. An application never does.
65
65
 
66
66
  ## Attributes
67
67
 
68
- The developer writes fourteen attributes in pages and the chrome, and the
68
+ The developer writes ten attributes in pages and the chrome, and the
69
69
  builder refuses any other `lb-` attribute there. `lb-exp-slot` and
70
70
  `lb-exp-template` are written for expansion, which removes them before the
71
71
  check. The hub and the builder write the rest, as stamps, and script never
@@ -76,9 +76,10 @@ assigns one.
76
76
  | `lb-query` | Developer | [Landing](./data-binding.md#landing) |
77
77
  | `lb-column` | Developer | [Landing](./data-binding.md#landing) |
78
78
  | `lb-show` | Developer | [Conditional rendering](./data-binding.md#conditional-rendering) |
79
- | `lb-order` | Developer | [Order](./data-binding.md#order) |
80
79
  | `lb-filter` | Developer | [Filters](./data-binding.md#filters) |
81
80
  | `lb-manual` | Developer | [Placing by hand](./data-binding.md#placing-by-hand) |
81
+ | `lb-group` | Developer | [Groups](./data-binding.md#groups) |
82
+ | `lb-aggregate` | Developer | [Aggregates](./data-binding.md#aggregates) |
82
83
  | `lb-request` | Developer | [Requests](./data-binding.md#requests) |
83
84
  | `lb-url-link` | Developer | [Links](./chrome.md#links) |
84
85
  | `lb-url-parm` | Developer | [A link from a row](./chrome.md#a-link-from-a-row) |
@@ -92,8 +93,9 @@ assigns one.
92
93
  | `lb-query-row-count` | Hub | [Counting rows](./data-binding.md#counting-rows) |
93
94
  | `lb-query-unplaced-count`, `lb-row-unplaced` | Hub | [Placing by hand](./data-binding.md#placing-by-hand) |
94
95
  | `lb-query-order` | Hub | [Order](./data-binding.md#order) |
96
+ | `lb-group-live`, `lb-group-column`, `lb-group-value` | Hub | [Groups](./data-binding.md#groups) |
95
97
  | `lb-row-created`, `lb-row-changed`, `lb-row-moved`, `lb-row-requested` | Hub | [What happened to a row](./data-binding.md#what-happened-to-a-row) |
96
- | `lb-row-leaving` | Hub | [What happened to a row](./data-binding.md#what-happened-to-a-row) |
98
+ | `lb-row-leaving`, `lb-group-leaving` | Hub | [What happened to a row](./data-binding.md#what-happened-to-a-row) |
97
99
  | `lb-row-editing` | Hub | [Editing a row in one form](./data-binding.md#editing-a-row-in-one-form) |
98
100
  | `lb-request-pending` | Hub | [Request state](./data-binding.md#request-state) |
99
101
  | `lb-request-error` | Hub | [Request state](./data-binding.md#request-state) |
@@ -111,7 +113,8 @@ them, and a page declares none.
111
113
  | Query | Kind | Key | Columns | Defined in |
112
114
  | ------------ | ----- | --------- | --------------------------------------------------------------- | ------------------------------------- |
113
115
  | `lb-url` | `row` | `lb-path` | `lb-path`, `lb-page-label`, every query parm | [The URL](./chrome.md#the-url) |
114
- | `lb-choices` | `row` | `lb-path` | `lb-path`, every choice | [Choices](./data-binding.md#choices) |
116
+ | `lb-sort` | `rows` | `query` | `query`, `order` | [Sort and filters](./data-binding.md#sort-and-filters) |
117
+ | `lb-filters` | `rows` | `query` | `query`, every filter column | [Sort and filters](./data-binding.md#sort-and-filters) |
115
118
  | `lb-hub-status` | `row` | `lb-path` | `lb-path`, `lb-load-state`, `lb-server-state`, `lb-error`, `lb-pending`, `lb-as-of` | [The hub's state](./chrome.md#the-hubs-state) |
116
119
 
117
120
  No query parm is reserved: a column of `lb-url` whose name begins with
@@ -170,7 +173,7 @@ accessor or field named `lb` and a capital.
170
173
 
171
174
  | Entry point | Exports | Defined in |
172
175
  | -------------------------- | ---------------------------------------------------------------- | ---------------------------------------------- |
173
- | `@loadbare/app/server` | `row`, `rows`, `patch`, `url`, `choices`, `refusal`, `createHub`, and the types `Queries`, `Requests`, `HubContext`, `Hub` | [Page Files](./page-files.md), [The data channel](./server.md#the-data-channel) |
176
+ | `@loadbare/app/server` | `row`, `rows`, `patch`, `url`, `sort`, `filters`, `refusal`, `createHub`, and the types `Queries`, `Requests`, `HubContext`, `Hub` | [Page Files](./page-files.md), [The data channel](./server.md#the-data-channel) |
174
177
  | `@loadbare/app/express` | `hubRoutes` | [The Express Server](./server.md) |
175
178
  | `@loadbare/app/dev` | `devServer`, `appServer`, `gate`, `devProxy`, `DOWN_MESSAGE` | [The Dev Server](./dev-server.md) |
176
179
  | `@loadbare/app/build` | `buildApp`, `watchApp` | [Assembling your own](./dev-server.md#assembling-your-own) |
@@ -196,10 +199,21 @@ imports them rather than writing a string.
196
199
  | `ATTR_QUERY_ROW_COUNT` | `lb-query-row-count` |
197
200
  | `ATTR_QUERY_UNPLACED_COUNT` | `lb-query-unplaced-count` |
198
201
  | `ATTR_QUERY_ORDER` | `lb-query-order` |
202
+ | `ATTR_GROUP` | `lb-group` |
203
+ | `ATTR_GROUP_LIVE` | `lb-group-live` |
204
+ | `ATTR_GROUP_COLUMN` | `lb-group-column` |
205
+ | `ATTR_GROUP_VALUE` | `lb-group-value` |
206
+ | `LIVE_GROUP` | `[lb-group-live]`, the selector for a group's element |
207
+ | `ATTR_AGGREGATE` | `lb-aggregate` |
208
+ | `AGGREGATE_COUNT`, `AGGREGATE_SUM`, `AGGREGATE_AVG`, `AGGREGATE_MIN`, `AGGREGATE_MAX` | `count`, `sum`, `avg`, `min`, `max` |
209
+ | `AGGREGATES` | All five aggregate functions |
199
210
  | `ORDER_DESCENDING` | `-`, written before a column in an order |
200
211
  | `COLUMN_TYPES` | `number`, `boolean`, `text` |
201
- | `CHOICES_QUERY` | `lb-choices` |
202
- | `ATTR_ORDER` | `lb-order` |
212
+ | `SORT_QUERY` | `lb-sort` |
213
+ | `SORT_COLUMN_QUERY` | `query` |
214
+ | `SORT_COLUMN_ORDER` | `order` |
215
+ | `FILTERS_QUERY` | `lb-filters` |
216
+ | `FILTERS_COLUMN_QUERY` | `query` |
203
217
  | `ATTR_FILTER` | `lb-filter` |
204
218
  | `ATTR_MANUAL` | `lb-manual` |
205
219
  | `MANUAL_ORDER`, `MANUAL_FILTER` | `order`, `filter`: the sides `lb-manual` names |
@@ -211,6 +225,7 @@ imports them rather than writing a string.
211
225
  | `REQUESTED_CREATED`, `REQUESTED_CHANGED`, `REQUESTED_MOVED` | `created`, `changed`, `moved` |
212
226
  | `ATTR_ROW_UNPLACED` | `lb-row-unplaced` |
213
227
  | `ATTR_ROW_LEAVING` | `lb-row-leaving` |
228
+ | `ATTR_GROUP_LEAVING` | `lb-group-leaving` |
214
229
  | `ATTR_REQUEST` | `lb-request` |
215
230
  | `LB_EVENT_NAME` | `lb-request`, the event every request travels as |
216
231
  | `LB_DONE_EVENT_NAME` | `lb-request-done` |
@@ -252,7 +267,7 @@ imports them rather than writing a string.
252
267
  | `ATTR_EXP_TEMPLATE` | `lb-exp-template` |
253
268
  | `ATTR_PAGE` | `lb-page` |
254
269
  | `ATTR_PAGE_TITLE` | `lb-page-title` |
255
- | `DEVELOPER_ATTRIBUTES` | The fourteen attributes a developer writes |
270
+ | `DEVELOPER_ATTRIBUTES` | The ten attributes a developer writes |
256
271
  | `HUB_TAG_NAME` | `lb-hub` |
257
272
  | `LB_ENDPOINT` | `/lb` |
258
273
  | `LB_REQUEST_TIMEOUT_MS` | `10000` |
@@ -152,8 +152,8 @@ optional:
152
152
 
153
153
  | Key | Runs |
154
154
  |---------------|--------------------------------------------------------|
155
- | `onPageEnter` | Before the page's queries, when the page loads; may move the URL or restore choices |
156
- | `onChoices` | Each time the user makes a choice |
155
+ | `onPageEnter` | Before the page's queries, when the page loads; may move the URL or restore the user's order and filters |
156
+ | `onChoices` | Each time the user changes the order or a filter |
157
157
  | `handlers` | The page's declared requests, by request name |
158
158
  | `crud` | The requests Loadbare provides, by query name |
159
159
 
@@ -190,34 +190,41 @@ loads there in the same round trip, and that load does not follow
190
190
  `onPageEnter` again. A `url()` leading to the parms already in hand is
191
191
  ignored. See [Moving the URL](#moving-the-url).
192
192
 
193
- It may return `choices()`, alone or beside `url()`, to restore the user's
194
- [choices](./data-binding.md#choices) for the page:
193
+ It may return `sort()` and `filters()`, alone or beside `url()`, to restore
194
+ the user's [order and filters](./data-binding.md#sort-and-filters) for the
195
+ page:
195
196
 
196
197
  ```ts
197
198
  // src/pages/directory.requests.ts
198
- import { choices, url, type Requests } from "@loadbare/app/server";
199
+ import { sort, filters, url, type Requests } from "@loadbare/app/server";
199
200
 
200
201
  export const requests: Requests = {
201
202
  onPageEnter: async (ctx) => {
202
203
  const saved = await ctx.db.savedView("directory");
203
- if (saved) return { ...url(saved.parms), ...choices(saved.choices) };
204
+ if (saved) {
205
+ return {
206
+ ...url(saved.parms),
207
+ ...sort(saved.order),
208
+ ...filters(saved.filters),
209
+ };
210
+ }
204
211
  },
205
- onChoices: (ctx, chosen) => ctx.db.saveChoices("directory", chosen),
212
+ onChoices: (ctx, change) => ctx.db.saveChoices(change),
206
213
  };
207
214
  ```
208
215
 
209
- The page load answers `lb-choices` first, so the rows land by the choices.
210
- When `url()` moves the page, the choices arrive with the load at the new
211
- URL. `choices()`, like `url()`, takes columns whose values are strings, at
212
- least one of them; anything else is reported on the server console and
213
- ignored.
216
+ The page load answers `lb-sort` and `lb-filters` first, so the rows land by
217
+ the order and the filters. When `url()` moves the page, the choices arrive
218
+ with the load at the new URL. `sort()` and `filters()`, like `url()`, take
219
+ columns whose values are strings, at least one of them; anything else is
220
+ reported on the server console and ignored.
214
221
 
215
222
  ### onChoices
216
223
 
217
- `onChoices` runs each time the user makes a choice, with every choice made
218
- on the page, by column, as strings. It is how an application keeps them for
219
- `onPageEnter` to restore, and answers nothing, by convention. Whatever it
220
- returns lands. A page without it is not told.
224
+ `onChoices` runs each time the user changes the order or a filter, with the
225
+ query and its new `sort` or `filters`, as strings. It is how an application
226
+ keeps them for `onPageEnter` to restore, and answers nothing, by
227
+ convention. Whatever it returns lands. A page without it is not told.
221
228
 
222
229
  ### handlers
223
230
 
@@ -377,6 +384,8 @@ A change that seems to need a refresh usually has a patch:
377
384
  [order](./data-binding.md#order), or leaves it where it stands under the
378
385
  list's [`lb-manual`](./data-binding.md#placing-by-hand); a refresh would do
379
386
  the same.
387
+ - A group that appears or goes: the hub makes a group with its first row
388
+ and removes it with its last, so no row stands in for an empty one.
380
389
  - A row whose other columns change with the edit: re-read the row and patch
381
390
  it.
382
391
  - Rows the database removes with a deleted one: select their keys before the
@@ -228,9 +228,9 @@ in `drop` are removed, and every other row is left alone. A `rows` item on
228
228
  the answer that loads the page also carries the query's declared `order`
229
229
  and `types`, which the hub keeps for every answer after it.
230
230
 
231
- A choice is sent as `lb-row-update` for `lb-choices`, keyed by the path,
232
- with every choice made on the page as `values`; see
233
- [Choices](./data-binding.md#choices).
231
+ A sort or a filter is sent as `lb-row-update` for `lb-sort` or `lb-filters`,
232
+ keyed by the query's name, with the new order or filter as `values`; see
233
+ [Sort and filters](./data-binding.md#sort-and-filters).
234
234
 
235
235
  `createHub(pages)` builds the `Hub`, which has two calls, both answering
236
236
  with response items: `dataForPage(page, ctx, options)` for a page load, and