@loadbare/widgets 0.4.0 → 0.6.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 (54) hide show
  1. package/README.md +9 -5
  2. package/dist/control.d.ts +54 -0
  3. package/dist/control.d.ts.map +1 -0
  4. package/dist/control.js +100 -0
  5. package/dist/control.js.map +1 -0
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +3 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/lb-confirm.browser.d.ts +2 -0
  11. package/dist/lb-confirm.browser.d.ts.map +1 -0
  12. package/dist/lb-confirm.browser.js +36 -0
  13. package/dist/lb-confirm.browser.js.map +1 -0
  14. package/dist/lb-confirm.html +27 -0
  15. package/dist/lb-form.browser.d.ts +2 -0
  16. package/dist/lb-form.browser.d.ts.map +1 -0
  17. package/dist/lb-form.browser.js +28 -0
  18. package/dist/lb-form.browser.js.map +1 -0
  19. package/dist/lb-form.html +7 -0
  20. package/dist/lb-input.browser.js +9 -37
  21. package/dist/lb-input.browser.js.map +1 -1
  22. package/dist/lb-input.html +1 -1
  23. package/dist/lb-insert-dialog.browser.d.ts +2 -0
  24. package/dist/lb-insert-dialog.browser.d.ts.map +1 -0
  25. package/dist/lb-insert-dialog.browser.js +59 -0
  26. package/dist/lb-insert-dialog.browser.js.map +1 -0
  27. package/dist/lb-insert-dialog.html +25 -0
  28. package/dist/lb-master.html +51 -0
  29. package/dist/lb-options.browser.d.ts +38 -11
  30. package/dist/lb-options.browser.d.ts.map +1 -1
  31. package/dist/lb-options.browser.js +50 -80
  32. package/dist/lb-options.browser.js.map +1 -1
  33. package/dist/lb-options.html +1 -1
  34. package/dist/lb-picker.browser.js +9 -11
  35. package/dist/lb-picker.browser.js.map +1 -1
  36. package/dist/lb-picker.html +2 -2
  37. package/dist/lb-select.browser.js +7 -39
  38. package/dist/lb-select.browser.js.map +1 -1
  39. package/dist/lb-select.html +1 -1
  40. package/dist/lb-table.browser.js +63 -90
  41. package/dist/lb-table.browser.js.map +1 -1
  42. package/dist/lb-table.html +4 -3
  43. package/dist/lb-unknown-page.html +2 -4
  44. package/docs/lb-confirm.md +45 -0
  45. package/docs/lb-form.md +33 -0
  46. package/docs/lb-input.md +42 -40
  47. package/docs/lb-insert-dialog.md +50 -0
  48. package/docs/lb-master.md +53 -0
  49. package/docs/lb-options.md +54 -34
  50. package/docs/lb-picker.md +24 -24
  51. package/docs/lb-select.md +37 -19
  52. package/docs/lb-table.md +63 -29
  53. package/docs/lb-unknown-page.md +11 -13
  54. package/package.json +4 -4
package/docs/lb-select.md CHANGED
@@ -1,14 +1,14 @@
1
1
  # `lb-select`
2
2
 
3
- A wrapper for HTML Select, with the `<option>`s written by hand.
3
+ A control wrapping an HTML `<select>`, with the `<option>`s written by hand.
4
4
 
5
- Apply the `lb-cell` attribute to name the column, and `lb-action` to name the
6
- action a change sends.
5
+ Apply the `lb-column` attribute to name the column, and `lb-request` to name the
6
+ request a change issues.
7
7
 
8
8
  Provide `exp-label`.
9
9
 
10
10
  ```html
11
- <lb-select lb-cell="status" exp-label="Status" lb-action="setStatus">
11
+ <lb-select lb-column="status" exp-label="Status" lb-request="setStatus">
12
12
  <option value="open">Open</option>
13
13
  <option value="closed">Closed</option>
14
14
  </lb-select>
@@ -22,30 +22,48 @@ improvements through iterative use.
22
22
  ## Parameters
23
23
 
24
24
  | Parameter | Fills |
25
- |-------------|----------------------------|
25
+ | ----------- | -------------------------- |
26
26
  | `exp-label` | the visible `<label>` text |
27
27
 
28
- ## Binding
28
+ ## Attributes
29
29
 
30
- | Attribute | Read from | Names |
31
- |-------------|--------------------|-----------------------------|
32
- | `lb-cell` | the element itself | the column the select shows |
33
- | `lb-action` | the element itself | the action a change sends |
34
- | `lb-query-parm` | the element itself | the query parm a change writes |
30
+ | Attribute | Names |
31
+ | ------------ | ------------------------------------------ |
32
+ | `lb-column` | the column the select shows and gathers to |
33
+ | `lb-request` | the request a change issues |
34
+
35
+ ## The control
36
+
37
+ `lb-select` is a form-associated custom element. Its `value` property gets
38
+ and sets the value of the `<select>` inside it, and it fires `change` on itself
39
+ when that `<select>` fires `change`. A form reset selects the option marked
40
+ `selected`, or the first option.
35
41
 
36
42
  ## Choosing
37
43
 
38
- Choosing an option notifies the hub, which fires a request to the server: the
39
- action named by `lb-action`, carrying the chosen option's value. Declare that
40
- action on the server.
44
+ With `lb-request`, the `lb-select` commits on `change`. The hub gathers its
45
+ value alone and sends the request with the `query` and `key` of the row around
46
+ it, and `values` holding the chosen option's value under its column. Declare
47
+ that request on the server, or name `lb-row-update`.
48
+
49
+ Without `lb-request`, a change commits nothing, and the form or live row around
50
+ the `lb-select` gathers its value.
41
51
 
42
- `lb-action` is required, unless the select carries `lb-query-parm`, in which
43
- case the hub writes the choice into the URL and the select sends nothing.
44
- Without either, a change does nothing.
52
+ Inside `lb-query="lb-url"`, `lb-request="lb-row-update"` writes the choice as a
53
+ query parm, and the hub answers with no round trip.
54
+
55
+ ```html
56
+ <div lb-query="lb-url">
57
+ <lb-select lb-column="status" exp-label="Status" lb-request="lb-row-update">
58
+ <option value="">All</option>
59
+ <option value="open">Open</option>
60
+ </lb-select>
61
+ </div>
62
+ ```
45
63
 
46
64
  While the request is in flight the hub marks the `lb-select` with
47
- `lb-pending`, and on failure with `lb-error`. Both are there for a
48
- stylesheet to read.
65
+ `lb-request-pending`, and on failure with `lb-request-error`. Both are there
66
+ for a stylesheet to read.
49
67
 
50
68
  For a `<select>` whose options come from a query, see
51
69
  [`lb-options`](./lb-options.md) and [`lb-picker`](./lb-picker.md).
package/docs/lb-table.md CHANGED
@@ -2,24 +2,28 @@
2
2
 
3
3
  A wrapper for HTML Table, supplying the `<table>` itself.
4
4
 
5
- Apply the `lb-list` attribute to name the query. Write three `<template>`s
6
- inside the tag: one marked `lb-template="head"` for the heading row, one
7
- carrying `lb-key` for the row, and optionally one marked `lb-template="foot"`
8
- for the footer. Apply `data-sort` and `data-group` to the row template to order
9
- and section the rows.
5
+ Apply the `lb-query` attribute to name the query. Write three `<template>`s
6
+ inside the tag: one marked `lb-exp-template="head"` for the heading row, one
7
+ unmarked for the row, or a group template holding it, and optionally one
8
+ marked `lb-exp-template="ghost"` for a ghost row and one marked
9
+ `lb-exp-template="foot"` for the footer. The query's order places the
10
+ rows.
10
11
 
11
12
  Provide `exp-caption`.
12
13
 
13
14
  ```html
14
- <lb-table lb-list="ledger" exp-caption="Ledger">
15
- <template lb-template="head">
15
+ <lb-table lb-query="ledger" exp-caption="Ledger">
16
+ <template lb-exp-template="head">
16
17
  <tr><th>Date</th><th>Amount</th></tr>
17
18
  </template>
18
- <template lb-key="id" data-sort="date" data-group="month">
19
- <tr><td lb-cell="date"></td><td lb-cell="amount"></td></tr>
19
+ <template lb-group>
20
+ <tr><th colspan="2" lb-column="month"></th></tr>
21
+ <template>
22
+ <tr><td lb-column="date"></td><td lb-column="amount"></td></tr>
23
+ </template>
20
24
  </template>
21
- <template lb-template="foot">
22
- <tr lb-row="ledger-total"><td>Total</td><td lb-cell="total"></td></tr>
25
+ <template lb-exp-template="foot">
26
+ <tr><td>Total</td><td lb-sum="amount"></td></tr>
23
27
  </template>
24
28
  </lb-table>
25
29
  ```
@@ -35,35 +39,65 @@ improvements through iterative use.
35
39
  ## Parameters
36
40
 
37
41
  | Parameter | Fills |
38
- |---------------|----------------------|
42
+ | ------------- | -------------------- |
39
43
  | `exp-caption` | the `<caption>` text |
40
44
 
41
- ## Binding
45
+ ## Attributes
42
46
 
43
- | Attribute | Read from | Names |
44
- |------------|----------------------------------|------------------------------------|
45
- | `lb-list` | the element itself | the query whose rows fill the body |
46
- | `lb-key` | the row template | the column that identifies a row |
47
- | `data-sort` | the row template | the column rows are ordered by |
48
- | `data-group` | the row template | the column rows are sectioned by |
49
- | `lb-cell` | elements inside the row template | the column each element shows |
47
+ | Attribute | On | Names |
48
+ | ----------- | -------------------------------- | ---------------------------------- |
49
+ | `lb-query` | the element itself | the query whose rows fill the body |
50
+ | `lb-group` | a template holding the row template | a group, one per run of the order's leading term |
51
+ | `lb-column` | elements inside the row template | the column each element shows |
50
52
 
51
- ## Sorting and grouping
53
+ The server declares the query's key and its order.
52
54
 
53
- `data-sort` names the column rows are ordered by, comparing the text each row
54
- shows. `data-group` names the column they are sectioned by: each distinct value
55
- gets a heading row of its own, spanning the width of the row template, and
56
- rows sort within their section.
55
+ ## Order and groups
56
+
57
+ The hub places the rows by the query's order and builds its groups. The
58
+ rows land in the table's one `<tbody>`, and a `<tbody>` cannot hold another,
59
+ so a group here is a heading row with its rows after it. For a `<tbody>` per
60
+ group, write a plain `<table lb-query>` whose group template is the
61
+ `<tbody>`.
62
+
63
+ ## The ghost row
64
+
65
+ The `ghost` template is a blank row for entering a new one, in a `<tbody>` of
66
+ its own between the rows and the footer. It is not a live row: the hub never
67
+ reconciles it and never counts it, and lands on whatever in it names a query.
68
+
69
+ ```html
70
+ <template lb-exp-template="ghost">
71
+ <tr>
72
+ <td><lb-input lb-column="name" exp-label="Name"></lb-input></td>
73
+ <td><button lb-request="lb-row-insert">Save</button></td>
74
+ </tr>
75
+ </template>
76
+ ```
77
+
78
+ A `<form>` cannot wrap a `<tr>`, so the widget makes one outside the table
79
+ and joins the row's controls and buttons to it with the `form` attribute. A
80
+ button carrying `lb-row-insert` submits that form, the hub gathers what the
81
+ form owns, and resets it once the insert succeeds. The widget then puts the
82
+ cursor back in the row's first control. A refused insert leaves the cursor
83
+ where it was.
84
+
85
+ ## Scrolling
86
+
87
+ After rows land, the widget scrolls into view the row the page's own request
88
+ created, or moved by changing a column the order reads.
57
89
 
58
90
  ## The footer
59
91
 
60
92
  The footer is an ordinary part of the page, not a row from the table's query.
61
- Give it its own `lb-row` — a grand total is a second query, declared on the
62
- server like any other.
93
+ An aggregate there covers every row. A figure that is not a sum of the rows,
94
+ such as a budget, is an element with its own `lb-query`, a query of kind
95
+ `row` declared on the server like any other.
63
96
 
64
97
  ## Styling an empty table
65
98
 
66
- `lb-table` carries `lb-row-count` with the number of rows showing, for a
99
+ `lb-table` carries `lb-query-row-count` with the number of rows showing, for a
67
100
  stylesheet to read.
68
101
 
69
- For a repeater with no table of its own, see [`lb-list`](./lb-list.md).
102
+ For rows with no table of their own, write the row template inside any element
103
+ that carries `lb-query`.
@@ -3,13 +3,13 @@
3
3
  > Status: a barebones starter. Iterative use will drive improvements.
4
4
 
5
5
  The chrome's dialog for a URL that names no page. Write it once, inside
6
- `<lb-hub>`, and the hub opens it whenever a path resolves to no page host.
6
+ `<lb-hub>`, and the hub opens it whenever no page's stub matches the path.
7
7
 
8
8
  ```html
9
9
  <lb-hub>
10
10
  <nav>
11
- <a href="/" lb-nav-link>Home</a>
12
- <a href="/about" lb-nav-link>About</a>
11
+ <a href="/" lb-url-link>Home</a>
12
+ <a href="/about" lb-url-link>About</a>
13
13
  </nav>
14
14
  <main></main>
15
15
  <lb-unknown-page></lb-unknown-page>
@@ -19,24 +19,22 @@ The chrome's dialog for a URL that names no page. Write it once, inside
19
19
  ## Parameters
20
20
 
21
21
  | Parameter | Fills |
22
- |-------------------|---------------------------------------|
22
+ | ----------------- | ------------------------------------- |
23
23
  | `exp-button-text` | the text of the button that closes it |
24
24
 
25
25
  Leaving `exp-button-text` off labels the button `OK`.
26
26
 
27
27
  ## Binding
28
28
 
29
- The definition supplies its own binding: a `<dialog lb-unknown-page>` scoped
30
- to the hub's `lb-navigation` query, which the hub lands on every navigation.
29
+ The definition supplies its own binding: a `<dialog lb-url-unknown>` carrying
30
+ `lb-query="lb-url"`, the query the hub serves and lands on every page load.
31
31
 
32
- | Cell | Holds |
33
- |--------------|-----------------------------------------------------------|
34
- | `page-label` | the text of the nav anchor for the path, or empty if none |
35
- | `page-uri` | the path and query string as the browser has them |
32
+ | Column | Holds |
33
+ | --------- | ------------------------ |
34
+ | `lb-path` | the path the browser has |
36
35
 
37
- The widget shows both. It does not yet choose between "the page *Members*
38
- is not in this app" and "the URL */members* is not in this app"; that is the
39
- improvement iterative use is expected to drive.
36
+ The widget shows the path. The dialog opens only when no page matches, so
37
+ there is no page label to show.
40
38
 
41
39
  ## Inside the hub
42
40
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@loadbare/widgets",
3
- "description": "The basic widget set for @loadbare/app: input, select, options, picker, table, unknown-page",
4
- "version": "0.4.0",
3
+ "description": "The basic widget set for @loadbare/app: input, select, options, picker, table, unknown-page, confirm, form, insert-dialog, master",
4
+ "version": "0.6.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -49,10 +49,10 @@
49
49
  "node": ">=22"
50
50
  },
51
51
  "peerDependencies": {
52
- "@loadbare/app": ">=0.8.2 <1.0.0"
52
+ "@loadbare/app": ">=0.13.0 <1.0.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@loadbare/app": ">=0.8.2 <1.0.0",
55
+ "@loadbare/app": ">=0.13.0 <1.0.0",
56
56
  "@types/jsdom": "^21.1.7",
57
57
  "@types/node": "^22.0.0",
58
58
  "jsdom": "^25.0.0",