@loadbare/app 0.17.0 → 0.18.1

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.
@@ -15,39 +15,14 @@ they must be resolved before we declare 1.0.
15
15
 
16
16
  ### Data types
17
17
 
18
- Loadbare/app enforces no data types on values between the database and the
19
- browser. A uniform and useful approach is difficult to discern, and we do
20
- not want to pollute 1.0 with a potentially sub-optimal solution. Until then
21
- a value is rendered by browser coercion when it lands on an HTML text
22
- element or a control, and by whatever the custom element does with
23
- `lb-column-value` when it lands on one that is not a control.
18
+ A value renders by browser coercion when it lands on an HTML text element or
19
+ a control, and by whatever the custom element does with `lb-column-value`
20
+ when it lands on one that is not a control. A `rows` query may declare a
21
+ column's type, which the [order](#order), a [filter](#filters), `lb-min` and
22
+ `lb-max` read.
24
23
 
25
- Three places read a value's type today. The [order](#order) compares
26
- values by their JSON type, a [filter](#filters) reads its value as the
27
- column's type, and an [aggregate](#aggregates) reads a sum or an average
28
- from a JSON number or a string holding a plain decimal. A `rows` query may
29
- declare a column's type, which the order, a filter, `lb-min` and `lb-max`
30
- read the column as in place of its JSON type. No declared type changes how
31
- a value renders.
32
-
33
- We will then see if a useful solution emerges that Loadbare/app should
34
- handle.
35
-
36
- ### Form controls
37
-
38
- - **Radio buttons are not implemented.** A value does not land on one and
39
- the hub does not gather one. A radio group is several elements answering
40
- to one column.
41
-
42
- ### Custom element hooks
43
-
44
- Loadbare/app owns every method name beginning with `lb` on a custom element.
45
- That decision is firm; what the set contains is not.
46
-
47
- - **Decide whether a custom element may receive a whole row.** A column
48
- lands one element at a time and offers no escape hatch. An optional
49
- `lbAcceptRow` would sit beside `lbRowsLanded`, and this is the most likely
50
- first request from a custom element author.
24
+ - **Decide who formats a value.** The hub could own formatting, or take it
25
+ from the application as configuration or as code.
51
26
 
52
27
  ### Nested queries
53
28
 
@@ -83,18 +58,8 @@ But the allowed values may depend on other values in the row.
83
58
  repository with several applications gets one per application. `--src`
84
59
  stays a flag, since it is what locates the file. State the precedence
85
60
  between a flag and a key once. Its key names join the permanent surface,
86
- so this lands before 1.0 or not at all.
87
- - **Decide CSS pairing.** Naming a stylesheet `<tag>.css` beside its
88
- definition would let the builder ship only what survives expansion.
89
- Recommend deferring the mechanism and reserving the configuration key, so
90
- that it lands as an opt-in rather than as a silent drop.
91
- - **Decide whether the build validates HTML.** A page can be well formed and
92
- still break HTML's rules for what an element may hold, such as a `<div>`
93
- inside a `<p>`. The parser rearranges it silently, the same way at build
94
- time and in the browser, so nothing reports it. Checking those rules is a
95
- validator's job, and html-validate is one the builder could run on the
96
- source or on the expanded output. Deciding it after 1.0 is free if it
97
- lands as an opt-in, and it may need a configuration key.
61
+ so this lands before 1.0 or not at all. It reserves a key for the
62
+ roadmap's tree-shaking CSS by tag name.
98
63
  - **Confirm the three output names.** `app.html`, `client.js` and `app.css`
99
64
  are about to be fixed in `staticRoutes` as well as in the builder.
100
65
 
@@ -103,16 +68,15 @@ But the allowed values may depend on other values in the row.
103
68
  None of this is surface. It is listed here because trimming it is free
104
69
  today and breaking after 1.0.
105
70
 
106
- - **Audit what the hub does.** It appears to have routines that go beyond
107
- what the `lb-*` attribute namespace specifies.
71
+ - **Audit what the hub does.** Every routine it runs answers to an `lb-*`
72
+ attribute, a [reserved query](#reserved-queries), or a
73
+ [reserved event](#reserved-events) or [method](#reserved-methods). Trim
74
+ whatever does not, and leave what stays clean: no dead code, no routine
75
+ written twice, no comment the code contradicts.
108
76
  - **Keep the rest as constants.** The endpoint, `index` and the timeout are
109
77
  linkage between the builder and the hub rather than facts an application
110
78
  varies. Adding a knob for any of them buys a second shape of application
111
79
  to reason about.
112
- - **Give the hub a configuration channel without using it.** `<lb-hub>` reads
113
- no attributes at all, which is the free landing spot for the roadmap's
114
- static-origin split and for a timeout an application eventually outgrows.
115
- Reserve the idea, build nothing.
116
80
 
117
81
  ## The build
118
82
 
@@ -220,7 +184,8 @@ it is sent to the browser on initial page load, no HTML is ever sent
220
184
  again.
221
185
 
222
186
  The developer writes `lb-*` attributes in markup. Script never assigns
223
- them. The hub and the builder write only their stamps. See
187
+ them. The hub and the builder write only their stamps, and the hub writes
188
+ the `name` of a radio button in a row template. See
224
189
  [The markup checks](#the-markup-checks).
225
190
 
226
191
  ### Expansion
@@ -457,8 +422,8 @@ unless its name begins with `lb-`.
457
422
  | Any other element | Its text content |
458
423
 
459
424
  A control is an `<input>`, `<select>` or `<textarea>`, or a form-associated
460
- custom element with a `value` property that fires `change`. A checkbox is a
461
- control too, by the rule below. A
425
+ custom element with a `value` property that fires `change`. A checkbox and
426
+ a radio button are controls too, by the rules below. A
462
427
  form-associated custom element declares `static formAssociated = true`.
463
428
 
464
429
  The hub stamps `lb-column-value` with the value on every element it sets.
@@ -481,9 +446,18 @@ attribute means nothing to the hub.
481
446
  <input type="checkbox" lb-column="active" lb-request="lb-row-update" />
482
447
  ```
483
448
 
484
- An `<input>` of type `radio` or `file` receives nothing, not even
485
- `lb-column-value`, and the hub reports it to the console. The hub does not
486
- gather one either.
449
+ A radio button's state is `checked` as well. The hub checks it when its
450
+ `value` attribute equals the value as a string, and unchecks it otherwise,
451
+ `null` included. Of the radio buttons naming one column, the hub gathers
452
+ the `value` of the one checked, or `""` when none is.
453
+
454
+ ```html
455
+ <input type="radio" lb-column="shift" value="day" lb-request="lb-row-update" />
456
+ <input type="radio" lb-column="shift" value="night" lb-request="lb-row-update" />
457
+ ```
458
+
459
+ An `<input>` of type `file` receives nothing, not even `lb-column-value`,
460
+ and the hub reports it to the console. The hub does not gather one either.
487
461
 
488
462
  A `<select>` with no option for the value shows no selection.
489
463
 
@@ -1583,6 +1557,26 @@ whose name begins with `lb` and a capital and is not in
1583
1557
  Script never assigns an `lb-` attribute, so the markup states every one
1584
1558
  that exists, and checking the markup is sound.
1585
1559
 
1560
+ ### Uncommon layouts
1561
+
1562
+ The hub supports these layouts and adds no check to refuse them. They are
1563
+ uncommon, and Loadbare/app does not shape itself around them.
1564
+
1565
+ - **A radio button in a row template.** The browser groups radio buttons
1566
+ by `name`, and a row template repeats one `name` in every live row. The
1567
+ hub stamps each radio button's `name` with the `name` written, or its
1568
+ column when none is, followed by `-` and the live row's key, so each live
1569
+ row holds a group of its own.
1570
+ - **Several rows not yet entered, each holding radio buttons.** A
1571
+ [row not yet entered](#a-row-not-yet-entered) has an empty key, so the
1572
+ radio buttons of every such row share one `name` and form one group.
1573
+ - **Radio buttons populated from a query.** A radio button in a query's row
1574
+ template answers to that query's row, as any element there does, so which
1575
+ row and column it lands from and gathers to follows from where the layout
1576
+ puts it. The result is the same as in any framework that populates radio
1577
+ buttons from a query. A choice among a query's rows is better made with a
1578
+ form-associated control, such as `lb-options` in `@loadbare/widgets`.
1579
+
1586
1580
  ## Application files
1587
1581
 
1588
1582
  ### Chrome
@@ -1854,12 +1848,12 @@ the refreshed ones. That is how a delta reaches the browser: wrap it in
1854
1848
  `patch()`, naming the rows that arrived or changed and the keys that went.
1855
1849
 
1856
1850
  A refreshed `rows` query sends every row to say what changed. An update or
1857
- a delete names its row by key, so its handler always knows what changed and
1858
- answers with a patch, which the hub places by the query's [order](#order):
1859
- `createHub` refuses at startup a `crud` `rowUpdate` or `rowDelete` on a
1851
+ a delete names its row by key, and an insert has the new row's key once it
1852
+ has written it, so each handler knows what changed and answers with a
1853
+ patch, which the hub places by the query's [order](#order): `createHub`
1854
+ refuses at startup a `crud` `rowInsert`, `rowUpdate` or `rowDelete` on a
1860
1855
  `rows` query whose `refresh` names that same query. A `row` query sends one
1861
- row and may refresh itself. An insert may refresh its own query, since its
1862
- key exists only once the row does.
1856
+ row and may refresh itself.
1863
1857
 
1864
1858
  `run` may instead return `url()`, a new row for `lb-url`, naming query parms
1865
1859
  only the write can know, such as the key of a row it inserted. The page
@@ -124,6 +124,7 @@ no row fills.
124
124
  |------------------------------------------------------|-----------------------------------------|
125
125
  | `<input>`, `<select>`, `<textarea>` | Its `value`, and `lb-column-value` |
126
126
  | `<input type="checkbox">` | Its `checked`, and `lb-column-value` |
127
+ | `<input type="radio">` | Its `checked`, and `lb-column-value` |
127
128
  | A form-associated custom element with `value` | Its `value`, and `lb-column-value` |
128
129
  | Any other custom element | `lb-column-value` only |
129
130
  | Any other element | Its text content, and `lb-column-value` |
@@ -135,8 +136,7 @@ element that is not a control keeps the content the builder placed in it
135
136
  from its element file, and renders `lb-column-value` itself; see
136
137
  [Custom Elements](./custom-elements.md#receiving-a-value).
137
138
 
138
- A radio button and a file input receive nothing, and the hub reports it to
139
- the console.
139
+ A file input receives nothing, and the hub reports it to the console.
140
140
 
141
141
  The hub hands every value to the browser as the server sent it. What a
142
142
  number, a date or a null looks like is decided in the query.
@@ -155,6 +155,27 @@ boolean, and the string `"false"` is checked. Unchecked sends `"false"`
155
155
  rather than nothing, so a flag can be set back. The checkbox's `value`
156
156
  attribute means nothing to the hub.
157
157
 
158
+ ### Radio buttons
159
+
160
+ A radio button is a control. It is checked when its `value` is the
161
+ column's value as a string, and unchecked otherwise. Of the radio buttons
162
+ naming one column, the hub gathers the `value` of the one checked, or `""`
163
+ when none is:
164
+
165
+ ```html
166
+ <input type="radio" lb-column="shift" value="day" lb-request="lb-row-update" />
167
+ <input type="radio" lb-column="shift" value="night" lb-request="lb-row-update" />
168
+ ```
169
+
170
+ In a row template, the hub stamps each radio button's `name` with the
171
+ `name` written, or its column when none is, followed by `-` and the live
172
+ row's key, so each live row holds a group of its own. Rows not yet entered
173
+ share the empty key, and so share one group.
174
+
175
+ A radio button in a query's row template answers to that query's row, as
176
+ any element there does. A choice among a query's rows is better made with
177
+ a form-associated control, such as `lb-options` in `@loadbare/widgets`.
178
+
158
179
  ### Rows
159
180
 
160
181
  Write a `<template>` inside the element carrying `lb-query`, holding one
@@ -337,10 +337,11 @@ A change that seems to need a refresh usually has a patch:
337
337
  delete and drop them too.
338
338
 
339
339
  An update or a delete always has a patch, since it names its row by key and
340
- removing a row never reorders the rest. `createHub` refuses at startup a
341
- `crud` `rowUpdate` or `rowDelete` on a `rows` query whose `refresh` names
342
- that same query. An insert may refresh its own query: where a new row goes
343
- depends on whether its host places it, which the server cannot see.
340
+ removing a row never reorders the rest. So does an insert, which has the new
341
+ row's key once it has written it, and the hub places the new row by the
342
+ query's order. `createHub` refuses at startup a `crud` `rowInsert`,
343
+ `rowUpdate` or `rowDelete` on a `rows` query whose `refresh` names that same
344
+ query.
344
345
 
345
346
  Each request's `refresh` is its own, and every query in it needs its own
346
347
  reason. A list shared by several requests is a warning sign.
@@ -78,6 +78,7 @@ writes the row template inside the widget:
78
78
  | Parameter | Fills |
79
79
  |-------------|----------------------------|
80
80
  | `exp-label` | The visible `<label>` text |
81
+ | `exp-size` | The `<select>`'s `size`, an open list rather than a drop-down |
81
82
 
82
83
  - Each option's `value` is its row's key, the `lb-key-value` the hub stamps
83
84
  on the live row, so the widget holds a key and shows a label.
@@ -90,6 +91,9 @@ writes the row template inside the widget:
90
91
  <optgroup><template><option lb-column="label"></option></template></optgroup>
91
92
  </template>
92
93
  ```
94
+ - A heading option marked `data-group-label` in the `<optgroup>`, `hidden`
95
+ and `disabled`, labels the group with its text instead, so the label can
96
+ be a column of the group's first row.
93
97
  - Its `value` selects the option with that key, including an option that
94
98
  arrives after the value did.
95
99
 
@@ -167,6 +171,9 @@ row, the row template, and optionally a footer, each as a `<template>`:
167
171
  cursor back in it once an insert from it succeeds.
168
172
  - After rows land, the widget scrolls the row the page's own request created
169
173
  or moved into view.
174
+ - Text selected in a cell whose `lb-column` the table's `lb-filter` names
175
+ becomes that column's filter in `lb-choices`: `=` for the whole text,
176
+ `^=` from its start, `$=` up to its end, `*=` otherwise.
170
177
 
171
178
  ## `lb-confirm`
172
179
 
@@ -207,6 +214,10 @@ with `commandfor` and `command="show-modal"`. Save is the form's
207
214
  `lb-options` around the button that opened it, and closes. The handler
208
215
  answers with a patch holding the new row.
209
216
 
217
+ While open, the button that opened it carries `insert-dialog-opener` and the
218
+ widget carries `anchored`, for a stylesheet to place the dialog beside the
219
+ button with CSS anchor positioning.
220
+
210
221
  | Parameter | Fills |
211
222
  |-------------|---------------------------------------------------|
212
223
  | `exp-id` | The dialog's `id` |