@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.
- package/README.md +9 -5
- package/dist/control.d.ts +54 -0
- package/dist/control.d.ts.map +1 -0
- package/dist/control.js +100 -0
- package/dist/control.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/lb-confirm.browser.d.ts +2 -0
- package/dist/lb-confirm.browser.d.ts.map +1 -0
- package/dist/lb-confirm.browser.js +36 -0
- package/dist/lb-confirm.browser.js.map +1 -0
- package/dist/lb-confirm.html +27 -0
- package/dist/lb-form.browser.d.ts +2 -0
- package/dist/lb-form.browser.d.ts.map +1 -0
- package/dist/lb-form.browser.js +28 -0
- package/dist/lb-form.browser.js.map +1 -0
- package/dist/lb-form.html +7 -0
- package/dist/lb-input.browser.js +9 -37
- package/dist/lb-input.browser.js.map +1 -1
- package/dist/lb-input.html +1 -1
- package/dist/lb-insert-dialog.browser.d.ts +2 -0
- package/dist/lb-insert-dialog.browser.d.ts.map +1 -0
- package/dist/lb-insert-dialog.browser.js +59 -0
- package/dist/lb-insert-dialog.browser.js.map +1 -0
- package/dist/lb-insert-dialog.html +25 -0
- package/dist/lb-master.html +51 -0
- package/dist/lb-options.browser.d.ts +38 -11
- package/dist/lb-options.browser.d.ts.map +1 -1
- package/dist/lb-options.browser.js +50 -80
- package/dist/lb-options.browser.js.map +1 -1
- package/dist/lb-options.html +1 -1
- package/dist/lb-picker.browser.js +9 -11
- package/dist/lb-picker.browser.js.map +1 -1
- package/dist/lb-picker.html +2 -2
- package/dist/lb-select.browser.js +7 -39
- package/dist/lb-select.browser.js.map +1 -1
- package/dist/lb-select.html +1 -1
- package/dist/lb-table.browser.js +63 -90
- package/dist/lb-table.browser.js.map +1 -1
- package/dist/lb-table.html +4 -3
- package/dist/lb-unknown-page.html +2 -4
- package/docs/lb-confirm.md +45 -0
- package/docs/lb-form.md +33 -0
- package/docs/lb-input.md +42 -40
- package/docs/lb-insert-dialog.md +50 -0
- package/docs/lb-master.md +53 -0
- package/docs/lb-options.md +54 -34
- package/docs/lb-picker.md +24 -24
- package/docs/lb-select.md +37 -19
- package/docs/lb-table.md +63 -29
- package/docs/lb-unknown-page.md +11 -13
- package/package.json +4 -4
package/docs/lb-select.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# `lb-select`
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A control wrapping an HTML `<select>`, with the `<option>`s written by hand.
|
|
4
4
|
|
|
5
|
-
Apply the `lb-
|
|
6
|
-
|
|
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-
|
|
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
|
-
##
|
|
28
|
+
## Attributes
|
|
29
29
|
|
|
30
|
-
| Attribute
|
|
31
|
-
|
|
32
|
-
| `lb-
|
|
33
|
-
| `lb-
|
|
34
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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-
|
|
43
|
-
|
|
44
|
-
|
|
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`.
|
|
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-
|
|
6
|
-
inside the tag: one marked `lb-template="head"` for the heading row, one
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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-
|
|
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-
|
|
19
|
-
<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
|
|
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
|
-
##
|
|
45
|
+
## Attributes
|
|
42
46
|
|
|
43
|
-
| Attribute
|
|
44
|
-
|
|
45
|
-
| `lb-
|
|
46
|
-
| `lb-
|
|
47
|
-
| `
|
|
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
|
-
|
|
53
|
+
The server declares the query's key and its order.
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
rows
|
|
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
|
-
|
|
62
|
-
|
|
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
|
|
102
|
+
For rows with no table of their own, write the row template inside any element
|
|
103
|
+
that carries `lb-query`.
|
package/docs/lb-unknown-page.md
CHANGED
|
@@ -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
|
|
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-
|
|
12
|
-
<a href="/about" lb-
|
|
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
|
|
30
|
-
|
|
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
|
-
|
|
|
33
|
-
|
|
34
|
-
| `
|
|
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
|
|
38
|
-
|
|
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.
|
|
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.
|
|
52
|
+
"@loadbare/app": ">=0.13.0 <1.0.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@loadbare/app": ">=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",
|