@loadbare/app 0.22.0 → 0.24.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 -1
- package/dist/build/assemble.js.map +1 -1
- package/dist/build/build.d.ts +16 -0
- package/dist/build/build.d.ts.map +1 -1
- package/dist/build/build.js +77 -5
- package/dist/build/build.js.map +1 -1
- package/dist/core/lb-constants.d.ts +8 -5
- package/dist/core/lb-constants.d.ts.map +1 -1
- package/dist/core/lb-constants.js +20 -11
- package/dist/core/lb-constants.js.map +1 -1
- package/dist/core/lb-types.d.ts +19 -3
- package/dist/core/lb-types.d.ts.map +1 -1
- package/dist/core/lb-types.js +35 -5
- package/dist/core/lb-types.js.map +1 -1
- package/dist/hub/lb-apply.d.ts +18 -22
- package/dist/hub/lb-apply.d.ts.map +1 -1
- package/dist/hub/lb-apply.js +127 -57
- 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 +15 -22
- package/dist/hub/lb-hub.browser.js.map +1 -1
- package/dist/server/lb-server.d.ts +2 -2
- package/dist/server/lb-server.d.ts.map +1 -1
- package/dist/server/lb-server.js +29 -9
- package/dist/server/lb-server.js.map +1 -1
- package/docs/comparison.md +11 -11
- package/docs/miswarts.md +7 -5
- package/docs/reference/chrome.md +42 -0
- package/docs/reference/custom-elements.md +9 -4
- package/docs/reference/data-binding.md +89 -67
- package/docs/reference/dev-server.md +10 -3
- package/docs/reference/names.md +10 -7
- package/docs/reference/page-files.md +8 -4
- package/docs/temp-proposals.md +251 -0
- package/docs/testing.md +3 -3
- package/package.json +1 -1
- package/skills/loadbare-app/SKILL.md +24 -12
- package/skills/loadbare-app/references/chrome.md +42 -0
- package/skills/loadbare-app/references/custom-elements.md +9 -4
- package/skills/loadbare-app/references/data-binding.md +89 -67
- package/skills/loadbare-app/references/dev-server.md +10 -3
- package/skills/loadbare-app/references/miswarts.md +7 -5
- package/skills/loadbare-app/references/names.md +10 -7
- package/skills/loadbare-app/references/page-files.md +8 -4
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
# Proposals
|
|
2
|
+
|
|
3
|
+
Working notes for changes not yet made. Not part of the skill.
|
|
4
|
+
|
|
5
|
+
## The mental model
|
|
6
|
+
|
|
7
|
+
A `row` maps to an HTML form. It supports select, insert, update and delete.
|
|
8
|
+
The hub handles the basics, such as resetting a form after an insert, and
|
|
9
|
+
lifecycle methods let a custom element add behavior of its own.
|
|
10
|
+
|
|
11
|
+
`rows` treats each of its rows as a `row`, and allows insert, update and
|
|
12
|
+
delete of several rows at once. It also places its rows by sorting and
|
|
13
|
+
filtering, each with an automatic or a manual flag.
|
|
14
|
+
|
|
15
|
+
A form sends a parent `row` with its nested `rows` in one submit, and the
|
|
16
|
+
handler writes them together. This is the foreign key.
|
|
17
|
+
|
|
18
|
+
The URL names the page, and its query parms are the server's filters. The
|
|
19
|
+
user's own sorts and filters are choices, held in `lb-choices`.
|
|
20
|
+
|
|
21
|
+
Requests go up, from the element that committed through its ancestors to the
|
|
22
|
+
hub, which completes them from what surrounds the element. Commands go
|
|
23
|
+
sideways, by id to the element they name, carrying the button that sent them,
|
|
24
|
+
and never reach the server. Lifecycle methods go down, from the hub to the
|
|
25
|
+
custom elements it placed.
|
|
26
|
+
|
|
27
|
+
What lies past this belongs to the application. It reaches the hub as fields
|
|
28
|
+
a custom element supplies on a request, and through lifecycle methods the hub
|
|
29
|
+
calls on a custom element.
|
|
30
|
+
|
|
31
|
+
## 1. Values kept across inserts
|
|
32
|
+
|
|
33
|
+
Package: `@loadbare/widgets`. No change to `@loadbare/app`.
|
|
34
|
+
|
|
35
|
+
### Today
|
|
36
|
+
|
|
37
|
+
After an insert succeeds, the hub resets the form the insert was gathered
|
|
38
|
+
from, then calls `lbRequestDone` on the attached custom elements from the
|
|
39
|
+
committing element outward. `detail.request.values` holds the values the
|
|
40
|
+
insert sent, by column. A ghost row starts over empty, and each control
|
|
41
|
+
returns to its HTML default.
|
|
42
|
+
|
|
43
|
+
A page that wants some columns to carry over to the next row, such as a date
|
|
44
|
+
or an account during a run of entries, has no way to say so.
|
|
45
|
+
|
|
46
|
+
### Proposal
|
|
47
|
+
|
|
48
|
+
A widget around the list, `lb-keep` or similar, names the columns to keep:
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<lb-keep exp-columns="date, account">
|
|
52
|
+
<lb-table lb-query="entries">
|
|
53
|
+
...
|
|
54
|
+
</lb-table>
|
|
55
|
+
</lb-keep>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
In `lbRequestDone`, after a successful `lb-row-insert`, the widget sets each
|
|
59
|
+
named column's control in the committing row back to the value the insert
|
|
60
|
+
sent. The hub's reset and the refill run in one synchronous stretch, so the
|
|
61
|
+
empty row is never painted.
|
|
62
|
+
|
|
63
|
+
- A column not named returns to its HTML default: `value` on an input,
|
|
64
|
+
`selected` on an option. A control with no default comes back blank.
|
|
65
|
+
- A reset the user asks for, with a reset button, sends no request and is
|
|
66
|
+
not followed by `lbRequestDone`. It clears every column.
|
|
67
|
+
- Kept values live in the controls. A reload starts the row empty.
|
|
68
|
+
|
|
69
|
+
### Open
|
|
70
|
+
|
|
71
|
+
- A starting value taken from the page, not from the last insert: ef's
|
|
72
|
+
paychecks page enters a paycheck while showing a series, and the new
|
|
73
|
+
paycheck's series is the one showing. A possible form is a default named
|
|
74
|
+
as `query.column`.
|
|
75
|
+
- Whether every wrapped control in `@loadbare/widgets` takes an HTML
|
|
76
|
+
default.
|
|
77
|
+
|
|
78
|
+
## 2. Sorted and filtered placement
|
|
79
|
+
|
|
80
|
+
Package: `@loadbare/app`.
|
|
81
|
+
|
|
82
|
+
### Today
|
|
83
|
+
|
|
84
|
+
When a patch lands on a list, the hub either places the rows by the order and
|
|
85
|
+
the filter, or holds them where they stand. It holds them when the request
|
|
86
|
+
was sent from inside the list: the list is the nearest element carrying
|
|
87
|
+
`lb-query` around the element that committed, or the request came from a form
|
|
88
|
+
that `--lb-edit` pointed at one of its rows.
|
|
89
|
+
|
|
90
|
+
Where the committing element sits is the only input to that decision. Two
|
|
91
|
+
cases in ef come out wrong:
|
|
92
|
+
|
|
93
|
+
- Matching. "Create rule and apply it" is a form in a side panel. Its answer
|
|
94
|
+
patches the rows the rule matched, and under the filter "Unmatched only"
|
|
95
|
+
they disappear. The user wants them to stay showing for review. An offset
|
|
96
|
+
chosen with the form `--lb-edit` points at a row is held, so the two ways of
|
|
97
|
+
matching a transaction behave differently.
|
|
98
|
+
- Paychecks. "Change from here…" is a form pointed with `--lb-edit`, so its
|
|
99
|
+
answer is held. The answer replaces the rest of the year, and the new
|
|
100
|
+
paychecks land after the last row of the series, out of date order. The
|
|
101
|
+
page carries a Re-sort button for this.
|
|
102
|
+
|
|
103
|
+
Neither table has edits in its rows. Every edit on both is made in a form
|
|
104
|
+
outside the table.
|
|
105
|
+
|
|
106
|
+
### Proposal
|
|
107
|
+
|
|
108
|
+
The element carrying `lb-query` declares each kind of placement, `auto` or
|
|
109
|
+
`manual`. Both default to `auto`. Spelling is open; for illustration:
|
|
110
|
+
|
|
111
|
+
```html
|
|
112
|
+
<lb-table lb-query="entries" lb-order="entries_order"
|
|
113
|
+
lb-filter="description, txn_date, is_unmatched"
|
|
114
|
+
lb-order-placement="manual" lb-filter-placement="manual">
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The rule about where a request was sent from is removed.
|
|
118
|
+
|
|
119
|
+
Each line of today's held behavior falls under one flag:
|
|
120
|
+
|
|
121
|
+
| The answer | `manual` | Flag |
|
|
122
|
+
| -------------------------------------- | ---------------------------------- | ------ |
|
|
123
|
+
| Changes a column the order reads | The row stays where it stands | order |
|
|
124
|
+
| Creates a row | The row goes last in its group | order |
|
|
125
|
+
| Changes the column its group breaks on | The row stays under its heading | order |
|
|
126
|
+
| Changes a row so the filter hides it | The row stays showing | filter |
|
|
127
|
+
| Drops a row | The row leaves, under either value | — |
|
|
128
|
+
|
|
129
|
+
Under `auto`, the rows are placed by the order and the filter on every
|
|
130
|
+
landing.
|
|
131
|
+
|
|
132
|
+
Every combination has a use:
|
|
133
|
+
|
|
134
|
+
| Order | Filter | Example |
|
|
135
|
+
| -------- | -------- | -------------------------------------------------------- |
|
|
136
|
+
| `auto` | `auto` | Paychecks: a regenerated schedule lands in date order |
|
|
137
|
+
| `manual` | `manual` | Matching: answered rows stay in place for review |
|
|
138
|
+
| `auto` | `manual` | Answered rows stay showing and move into the order |
|
|
139
|
+
| `manual` | `auto` | A to-do list: an edit does not move a row, done hides it |
|
|
140
|
+
|
|
141
|
+
A row left where the order or the filter would not leave it is stamped, as
|
|
142
|
+
`lb-row-unsorted` is today, and counted in `lb-query-unsorted-count`. The rows
|
|
143
|
+
are placed by both again when the page loads, when the user's order or filter
|
|
144
|
+
changes, and on `--lb-sort`.
|
|
145
|
+
|
|
146
|
+
### The command
|
|
147
|
+
|
|
148
|
+
`--lb-sort` today places the rows by both the order and the filter, so a row
|
|
149
|
+
kept despite the filter leaves on it. Under the flags it is renamed for what
|
|
150
|
+
it does, `--lb-place` or similar.
|
|
151
|
+
|
|
152
|
+
A side set to `auto` is in place after every landing, so one command does
|
|
153
|
+
what each list needs:
|
|
154
|
+
|
|
155
|
+
| Order | Filter | The command |
|
|
156
|
+
| -------- | -------- | ----------------- |
|
|
157
|
+
| `manual` | `auto` | Sorts |
|
|
158
|
+
| `auto` | `manual` | Filters |
|
|
159
|
+
| `manual` | `manual` | Sorts and filters |
|
|
160
|
+
| `auto` | `auto` | Changes nothing |
|
|
161
|
+
|
|
162
|
+
Separate `--lb-sort` and `--lb-filter` differ from it only when both sides are
|
|
163
|
+
`manual` and the user applies one without the other. No case for that is in
|
|
164
|
+
hand.
|
|
165
|
+
|
|
166
|
+
### Effect on ef
|
|
167
|
+
|
|
168
|
+
- Matching declares both `manual`. The rule's answer and the offset form
|
|
169
|
+
behave alike, wherever the form sits.
|
|
170
|
+
- Paychecks declares nothing. The Re-sort button and its comment are removed.
|
|
171
|
+
|
|
172
|
+
### Effect on other pages
|
|
173
|
+
|
|
174
|
+
A list that relies on being held today, such as an editable `lb-table` with a
|
|
175
|
+
ghost row, declares `manual` to keep its behavior. Under `auto`, a row edited
|
|
176
|
+
in place moves into the order, and a row entered in the ghost row is placed by
|
|
177
|
+
the order.
|
|
178
|
+
|
|
179
|
+
### Open
|
|
180
|
+
|
|
181
|
+
- The attribute names.
|
|
182
|
+
- One stamp for both kinds of out-of-place row, or one for each, so a page can
|
|
183
|
+
style a row out of order apart from a row kept despite the filter. The
|
|
184
|
+
commands follow the stamps. One stamp has one count, one button shown while
|
|
185
|
+
it is not 0, and one command. Two stamps let a page show Re-sort and
|
|
186
|
+
Re-filter apart, each with its own command, `--lb-sort` and `--lb-filter`,
|
|
187
|
+
beside the one for both. Every name carries the `--` prefix, or the
|
|
188
|
+
browser ignores it.
|
|
189
|
+
|
|
190
|
+
## 3. Child rows entered with their parent
|
|
191
|
+
|
|
192
|
+
Package: `@loadbare/app`.
|
|
193
|
+
|
|
194
|
+
### Today
|
|
195
|
+
|
|
196
|
+
A form gathers the live rows of a query nested in its own, and sends them in
|
|
197
|
+
`rows` beside its own `values`. The handler writes the parent and its child
|
|
198
|
+
rows together. A live row is one the nested query answered, so the child rows
|
|
199
|
+
exist before the form is sent: ef's paycheck form sends one amount per
|
|
200
|
+
deduction type, and the types come from the database.
|
|
201
|
+
|
|
202
|
+
A row not yet entered, carrying `lb-key-value=""`, arises only as a single
|
|
203
|
+
row: a `row` query answering with an empty key, or a form pointed by
|
|
204
|
+
`--lb-new`. A list holds no row not yet entered.
|
|
205
|
+
|
|
206
|
+
ptracking's flight page enters a flight, then its arrivals. The arrivals
|
|
207
|
+
section shows once the flight is on record, and each arrival is its own
|
|
208
|
+
`lb-row-insert` from the ghost row, keyed by the `flight_id` parm. The
|
|
209
|
+
arrivals handler refuses an insert with no flight: "Save the flight first."
|
|
210
|
+
Most flights have one arrival, and pattern work is one arrival with a
|
|
211
|
+
quantity, so the usual entry is two saves and a second form.
|
|
212
|
+
|
|
213
|
+
### Proposal
|
|
214
|
+
|
|
215
|
+
A list may hold rows not yet entered.
|
|
216
|
+
|
|
217
|
+
1. Inside a parent not yet entered, the list's Add puts a row not yet entered
|
|
218
|
+
into the list, and sends nothing.
|
|
219
|
+
2. The parent's form gathers those rows with its insert, each with no key,
|
|
220
|
+
under the nested query's name in `rows`.
|
|
221
|
+
3. The parent's handler inserts the parent and its child rows in one
|
|
222
|
+
transaction, and answers both. The rows not yet entered are replaced by
|
|
223
|
+
the rows the answer lands.
|
|
224
|
+
4. Once the parent is on record, the list's Add inserts as it does today.
|
|
225
|
+
|
|
226
|
+
A row not yet entered in a list follows the existing rules for one:
|
|
227
|
+
|
|
228
|
+
- Its controls carrying `lb-request="lb-row-update"` send nothing and hold
|
|
229
|
+
what the parent's submit gathers. Once the row is on record, they save as
|
|
230
|
+
they change.
|
|
231
|
+
- A delete from it sends nothing. The row is removed from the list.
|
|
232
|
+
- A refusal of the parent's insert leaves it in place, and a column's message
|
|
233
|
+
goes on its control, as for any control the request gathered.
|
|
234
|
+
|
|
235
|
+
### Effect on ptracking
|
|
236
|
+
|
|
237
|
+
- The arrivals list moves inside the flight's form, and loses
|
|
238
|
+
`lb-show="on_record"`.
|
|
239
|
+
- The flight's `rowInsert` accepts `rows.arrivals` and inserts both.
|
|
240
|
+
`detailCrud` writes the parent alone today.
|
|
241
|
+
- A flight with one arrival is one save. A flight with three approaches is
|
|
242
|
+
three rows not yet entered and one save.
|
|
243
|
+
|
|
244
|
+
### Open
|
|
245
|
+
|
|
246
|
+
- The command that adds a row not yet entered: the ghost row's insert,
|
|
247
|
+
changing meaning while the parent is not on record, or a command of its own.
|
|
248
|
+
- `lb-table` joins the ghost row's controls to a form of its own, outside the
|
|
249
|
+
table, with the `form` attribute. A ghost row inside a parent's form then
|
|
250
|
+
belongs to the ghost row's form, not the parent's.
|
|
251
|
+
- One level only, as for a form over a set of rows today.
|
package/docs/testing.md
CHANGED
|
@@ -208,9 +208,9 @@ evidence here.
|
|
|
208
208
|
- `lb-query-row-count` counts the rows showing, so all rows and a patch
|
|
209
209
|
ending in the same state report the same number, and a row a filter hides
|
|
210
210
|
is not counted
|
|
211
|
-
- the order
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
- the order and the filter place all rows and a patch alike, except where
|
|
212
|
+
the list's `lb-manual` leaves a side to the user, which keeps its rows
|
|
213
|
+
standing and stamped until they are placed again; groups come and go with
|
|
214
214
|
their rows to any depth, aggregates follow every landing, and every change
|
|
215
215
|
leaves a stamp a stylesheet can see (`lb-order.test.ts`)
|
|
216
216
|
- a filter's text reads and passes values as documented, and a choice of
|
package/package.json
CHANGED
|
@@ -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-parm`, `lb-url-push` and `lb-url-unknown`; the user's order and filters as the hub's query `lb-choices`, read by `lb-order` and `lb-filter`; whether the page loaded and the server answers as the hub's query `lb-hub`; one form pointed at a row by the `--lb-edit`, `--lb-new` and `--lb-release` commands;
|
|
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-parm`, `lb-url-push` and `lb-url-unknown`; the user's order and filters as the hub's query `lb-choices`, read by `lb-order` and `lb-filter`; whether the page loaded and the server answers as the hub's query `lb-hub`; one form pointed at a row by the `--lb-edit`, `--lb-new` and `--lb-release` commands; rows that hold still under `lb-manual` and are placed again with `--lb-place`; 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"
|
|
@@ -194,11 +194,17 @@ row is filled from the nested query's last answer, whatever order they land
|
|
|
194
194
|
in.
|
|
195
195
|
|
|
196
196
|
**A `rows` query declares its order, and the hub places every row by it.**
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
197
|
+
It places them by the order and the user's filter on every landing. A list
|
|
198
|
+
whose rows must hold still while the user works through them carries
|
|
199
|
+
`lb-manual="order"`, `"filter"` or `"order filter"`: an answer to any
|
|
200
|
+
request, from wherever it was sent, then leaves that side alone, so an
|
|
201
|
+
edited row stays where it stands, a new row goes last in its group, and a
|
|
202
|
+
row the filter would hide stays showing. A row left out of place is
|
|
203
|
+
stamped `lb-row-unplaced` until the page loads, the user's order or filter
|
|
204
|
+
changes, or a button with `commandfor` naming the list sends
|
|
205
|
+
`command="--lb-place"`, which places them with no round trip; show it by
|
|
206
|
+
`[lb-query-unplaced-count]`. An editable list with a ghost row usually
|
|
207
|
+
wants `lb-manual="order"`. Never refresh to make rows hold
|
|
202
208
|
still, and never to put them back in order.
|
|
203
209
|
`rows("id", run, { order: "category_order,name" })`; a column after `-` sorts
|
|
204
210
|
descending, and values compare by JSON type, so a numeric sort column is a
|
|
@@ -265,7 +271,9 @@ control whose form owner it is. An element in a live row gathers that live
|
|
|
265
271
|
row. Anything else gathers its form owner's controls. A `<form>` cannot
|
|
266
272
|
wrap a `<tr>`, so an insert row in a table puts its controls in a form
|
|
267
273
|
elsewhere with the HTML `form` attribute. A checkbox is a control: checked
|
|
268
|
-
unless its column is `false
|
|
274
|
+
unless its column is `false`, null, `"false"` or `""`, and gathered as
|
|
275
|
+
`"true"` or `"false"`; one carrying `value` is instead one of a set
|
|
276
|
+
holding a repeated query parm.
|
|
269
277
|
A radio button is a control: checked when its `value` is the column's
|
|
270
278
|
value, and the group gathers the one checked, or `""`. In a row template
|
|
271
279
|
the hub stamps its `name` with the row's key, so each row is its own group.
|
|
@@ -283,7 +291,7 @@ in every row. Write one form naming the set's query, outside every row,
|
|
|
283
291
|
often in a `<dialog>`, and give it an `id`. A `type="button"` with
|
|
284
292
|
`commandfor="<id>"` and `command="--lb-edit"` in a live row fills it from
|
|
285
293
|
that row with no round trip; `--lb-new` starts it empty for an insert;
|
|
286
|
-
`--lb-release` lets it go. (`--lb-
|
|
294
|
+
`--lb-release` lets it go. (`--lb-place` is the fourth command, for a list,
|
|
287
295
|
not a form.) The form's `lb-key-value` is the row's key, empty
|
|
288
296
|
for a new row, absent when not in use, and a stylesheet shows Save or Save
|
|
289
297
|
new by it. A successful request from the form, or its dialog closing, lets
|
|
@@ -341,7 +349,7 @@ fills a new row from the last one.
|
|
|
341
349
|
|
|
342
350
|
**The usual reasons for a refresh each have a patch.**
|
|
343
351
|
- A row whose position changes: the hub places it by the query's order, or
|
|
344
|
-
holds it where
|
|
352
|
+
holds it where it stands under `lb-manual`; a refresh changes neither.
|
|
345
353
|
- A group that appears or goes: the hub makes it with its first row and
|
|
346
354
|
removes it with its last.
|
|
347
355
|
- A row whose other columns change with the edit: re-read the row and patch
|
|
@@ -378,7 +386,11 @@ keyed by `lb-path`, with `lb-page-label`, `lb-page-unknown`, and one column
|
|
|
378
386
|
per query parm. A control inside `lb-query="lb-url"` carrying
|
|
379
387
|
`lb-request="lb-row-update"` writes its parm; the hub replaces the history
|
|
380
388
|
entry, or pushes one when the control carries `lb-url-push`, and reloads the
|
|
381
|
-
page's queries with no request to the server.
|
|
389
|
+
page's queries with no request to the server. A parm the URL repeats,
|
|
390
|
+
`?band=3&band=5`, is one column holding an array of strings: a
|
|
391
|
+
`<select multiple>`, or checkboxes carrying `value` and naming one column,
|
|
392
|
+
write it, `url()` takes an array, and `contextFor` reads it with
|
|
393
|
+
`parms.getAll`. Only a query parm holds several values. An `<a lb-url-link>` moves
|
|
382
394
|
to its `href`; inside a row, `lb-url-parm="topic_id"` adds that column of
|
|
383
395
|
the row to the `href` as the parm of the same name, so a link to another
|
|
384
396
|
page narrowed by the row is a link, never a request or script. Queries still take no arguments: `contextFor(req, parms)`
|
|
@@ -415,8 +427,8 @@ whole data channel.
|
|
|
415
427
|
|
|
416
428
|
**The developer writes `lb-*` attributes in markup, and script never
|
|
417
429
|
assigns them.** The builder refuses any `lb-` attribute other than the
|
|
418
|
-
|
|
419
|
-
`lb-column`, `lb-show`, `lb-order`, `lb-filter`, `lb-group`, `lb-count`,
|
|
430
|
+
eighteen in [Attributes](references/names.md#attributes): `lb-query`,
|
|
431
|
+
`lb-column`, `lb-show`, `lb-order`, `lb-filter`, `lb-manual`, `lb-group`, `lb-count`,
|
|
420
432
|
`lb-sum`, `lb-avg`, `lb-min`, `lb-max`, `lb-select`, `lb-request`,
|
|
421
433
|
`lb-url-link`, `lb-url-parm`, `lb-url-push` and `lb-url-unknown`. `lb-exp-slot` and
|
|
422
434
|
`lb-exp-template` are expansion's, and never reach the page. Everything
|
|
@@ -238,6 +238,48 @@ and after Back alike
|
|
|
238
238
|
Loadbare assigns no parm a meaning, and a column of `lb-url` whose name
|
|
239
239
|
begins with `lb-` is never a query parm.
|
|
240
240
|
|
|
241
|
+
### Several values
|
|
242
|
+
|
|
243
|
+
A URL may repeat a parm, `/statements?band=3&band=5`, as an HTML form does
|
|
244
|
+
for a `<select multiple>` or for checkboxes sharing a name. That column of
|
|
245
|
+
`lb-url` holds every value, in order, as an array of strings. A parm the URL
|
|
246
|
+
carries once is a string, as it always is. Two controls hold several values:
|
|
247
|
+
|
|
248
|
+
```html
|
|
249
|
+
<div lb-query="lb-url">
|
|
250
|
+
<select multiple lb-column="band" lb-request="lb-row-update">
|
|
251
|
+
<option value="3">Cash</option>
|
|
252
|
+
<option value="5">Investments</option>
|
|
253
|
+
</select>
|
|
254
|
+
</div>
|
|
255
|
+
|
|
256
|
+
<form lb-query="lb-url" lb-request="lb-row-update">
|
|
257
|
+
<label><input type="checkbox" lb-column="band" value="3" /> Cash</label>
|
|
258
|
+
<label><input type="checkbox" lb-column="band" value="5" /> Investments</label>
|
|
259
|
+
<button>Show</button>
|
|
260
|
+
</form>
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
- A `<select multiple>` selects each option whose `value` is among the
|
|
264
|
+
column's, and writes the values of the options selected.
|
|
265
|
+
- A checkbox carrying `value` is one of a set naming the column. It is
|
|
266
|
+
checked when its `value` is among the column's, and the set writes the
|
|
267
|
+
values of the ones checked. A checkbox without `value` is a flag; see
|
|
268
|
+
[Checkboxes](./data-binding.md#checkboxes).
|
|
269
|
+
- Writing no value takes the parm out of the URL.
|
|
270
|
+
- Either control carries the values as a JSON array in `lb-column-value`.
|
|
271
|
+
- A control that holds one value, and any other element, shows the first,
|
|
272
|
+
as `URLSearchParams.get` reads it. A form-associated custom element
|
|
273
|
+
receives the value as it is, a string or an array, and may give an array
|
|
274
|
+
back; see [Being a control](./custom-elements.md#being-a-control).
|
|
275
|
+
- A handler's `url()` writes several values as an array of strings, and
|
|
276
|
+
`contextFor` reads them with `parms.getAll`.
|
|
277
|
+
|
|
278
|
+
Only a column of `lb-url` holds several values. Every other column holds
|
|
279
|
+
one, so the builder refuses a control holding several anywhere but inside
|
|
280
|
+
`lb-query="lb-url"`, and the server ignores a request that carries several
|
|
281
|
+
for a column of its own.
|
|
282
|
+
|
|
241
283
|
A query parm is user input. A query still takes no argument from the
|
|
242
284
|
browser, and a parm arrives the way the session cookie does, as part of the
|
|
243
285
|
request the context is built from, but a user who types `?acct=99999`
|
|
@@ -268,7 +268,7 @@ Each direction has one mechanism for each kind of message:
|
|
|
268
268
|
|
|
269
269
|
| Direction | What | How | Today |
|
|
270
270
|
|----------------|--------------------------------------------|-----------------------------|-------|
|
|
271
|
-
| Hub to element | State that lasts | An attribute the hub stamps | `lb-column-value`, `lb-key-value`, `lb-query-row-count`, `lb-query-
|
|
271
|
+
| Hub to element | State that lasts | An attribute the hub stamps | `lb-column-value`, `lb-key-value`, `lb-query-row-count`, `lb-query-unplaced-count`, `lb-query-order`, `lb-group-*`, `lb-row-*`, `lb-request-pending`, `lb-request-error`, `lb-request-refused` |
|
|
272
272
|
| Hub to element | State the platform already names | A property | A control's `value` |
|
|
273
273
|
| Hub to element | What the hub did | An optional `lb` method | `lbAttached`, `lbRowsLanded`, `lbRequestDone`, `lbDetached` |
|
|
274
274
|
| Hub to element | A moment an element started | A bubbling event | `lb-request-done` |
|
|
@@ -404,6 +404,11 @@ customElements.define("star-rating", StarRating);
|
|
|
404
404
|
Dispatch `change` with `bubbles: true`, as a native control's does, when the
|
|
405
405
|
user commits an edit. Setting `value` from the hub fires nothing.
|
|
406
406
|
|
|
407
|
+
Inside `lb-query="lb-url"`, a control may hold several values. The hub sets
|
|
408
|
+
its `value` to a string, or to an array of strings when the URL repeats the
|
|
409
|
+
parm, and gathers an array back when `value` gives one; see
|
|
410
|
+
[Several values](./chrome.md#several-values).
|
|
411
|
+
|
|
407
412
|
A form owns a form-associated custom element the way it owns an `<input>`,
|
|
408
413
|
including through the HTML `form` attribute, so a form gathers it on submit.
|
|
409
414
|
Write `formResetCallback` to restore the default value: the hub resets a form
|
|
@@ -627,7 +632,7 @@ had there hears the event, and no custom element the hub has removed hears
|
|
|
627
632
|
### Holding rows
|
|
628
633
|
|
|
629
634
|
The hub lands every row template itself, places every row by the query's
|
|
630
|
-
order (see [
|
|
635
|
+
order (see [Placing by hand](./data-binding.md#placing-by-hand)
|
|
631
636
|
for when it does not), and builds every group the markup's group templates describe; see
|
|
632
637
|
[Order](./data-binding.md#order) and [Groups](./data-binding.md#groups). A
|
|
633
638
|
plain element carrying `lb-query` with a row template inside it needs no
|
|
@@ -656,12 +661,12 @@ Everything else is the hub's:
|
|
|
656
661
|
|-------------|----------------------------------------------------------|
|
|
657
662
|
| Cloning | Clones the row template once per new key |
|
|
658
663
|
| Matching | Fills the live row already showing that key, when its values changed |
|
|
659
|
-
| Placing | Places every live row by the user's order or the query's, and leaves them where they stand for an
|
|
664
|
+
| Placing | Places every live row by the user's order or the query's, and leaves them where they stand for an answer under `lb-manual` |
|
|
660
665
|
| Filtering | Hides a row the user's filter does not pass, and a group whose rows are all hidden |
|
|
661
666
|
| Grouping | Builds a group where the order breaks, keeps it while its run goes on, and removes it with its last row |
|
|
662
667
|
| Removing | Marks the live rows the response says are gone as leaving, and removes them |
|
|
663
668
|
| Stamping | Stamps each live row with `lb-row-live`, `lb-key-value`, and what happened to it |
|
|
664
|
-
| Counting | Stamps `lb-query-row-count` with the number of live rows showing, `lb-query-
|
|
669
|
+
| Counting | Stamps `lb-query-row-count` with the number of live rows showing, `lb-query-unplaced-count` with the number out of place, and `lb-query-order` with the order placing them |
|
|
665
670
|
|
|
666
671
|
`lb-options.browser.ts` and `lb-table.browser.ts` in
|
|
667
672
|
[`@loadbare/widgets`](./widgets.md) are two uses of `lbRowsLanded`: one
|