@loadbare/widgets 0.10.1 → 0.11.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.
@@ -0,0 +1,173 @@
1
+ # `lb-table`
2
+
3
+ A wrapper for HTML Table, supplying the `<table>` itself.
4
+
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.
11
+
12
+ Provide `exp-caption`.
13
+
14
+ ```html
15
+ <lb-table lb-query="ledger" exp-caption="Ledger">
16
+ <template lb-exp-template="head">
17
+ <tr><th>Date</th><th>Amount</th></tr>
18
+ </template>
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>
24
+ </template>
25
+ <template lb-exp-template="foot">
26
+ <tr><td>Total</td><td lb-sum="amount"></td></tr>
27
+ </template>
28
+ </lb-table>
29
+ ```
30
+
31
+ Each part goes in a `<template>` because a `<thead>` or `<tr>` written
32
+ directly inside the tag is thrown away by the HTML parser.
33
+
34
+ ## Status
35
+
36
+ Barebones starter to prove out the publish/consume chain and identify necessary
37
+ improvements through iterative use.
38
+
39
+ ## Parameters
40
+
41
+ | Parameter | Fills |
42
+ | ------------- | -------------------- |
43
+ | `exp-caption` | the `<caption>` text |
44
+
45
+ ## Attributes
46
+
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-order` | the element itself | the choice holding the user's order |
52
+ | `lb-filter` | the element itself | the columns the user's choices filter |
53
+ | `lb-column` | elements inside the row template | the column each element shows |
54
+
55
+ The server declares the query's key and its order.
56
+
57
+ ## Order and groups
58
+
59
+ The hub places the rows by the query's order and builds its groups. An
60
+ edit from a control in a row, or from the ghost row, leaves the rows where
61
+ they stand until the user asks for the order; a button with
62
+ `commandfor` naming the table's `id` and `command="--lb-sort"` does that.
63
+ The rows land in the table's one `<tbody>`, and a `<tbody>` cannot hold another,
64
+ so a group here is a heading row with its rows after it. For a `<tbody>` per
65
+ group, write a plain `<table lb-query>` whose group template is the
66
+ `<tbody>`.
67
+
68
+ `lb-order` and `lb-filter` work on `lb-table` as on any element carrying
69
+ `lb-query`: the user's order replaces the query's, and a row the user's
70
+ filter does not pass is hidden.
71
+
72
+ ## The order on the heading
73
+
74
+ The heading of the column the rows are sorted by carries a triangle, up for
75
+ ascending and down for descending, and `aria-sort`, read from the
76
+ `lb-query-order` the hub stamps on the table. Only the order's leading term
77
+ is shown. A heading's column is the `lb-column` in the cell
78
+ at the same position in the row template, on the cell or inside it. A cell
79
+ naming no column, or several, gives its heading none.
80
+
81
+ While rows stand out of order, the triangle carries `data-unsorted`, and a
82
+ click on its heading places them again, as `--lb-sort` does, keeping the
83
+ direction.
84
+
85
+ With `lb-order` on the table, a click on the sorted heading reverses the
86
+ order, and a click on another heading sorts by its column, ascending. The
87
+ widget writes the order to the column of `lb-choices` that `lb-order`
88
+ names. Without `lb-order` there is nowhere to write one, and only the
89
+ re-sort answers a click. There is no click back to the server's order.
90
+
91
+ A heading that takes a click carries `data-sortable`.
92
+
93
+ None of this shows on a grouped table, nor when the order's leading column
94
+ has no heading. There, a button with `commandfor` and `--lb-sort` does the
95
+ re-sort.
96
+
97
+ The package ships `lb-table.css`: the triangle turns amber and circled
98
+ while rows stand out of order, and the first cell of a row carrying
99
+ `lb-row-unsorted` is marked on its leading edge. The application's own
100
+ stylesheet comes after it and overrides any of it.
101
+
102
+ ## Filtering by selection
103
+
104
+ Text selected in a cell filters the table by that cell's column, when the
105
+ cell's `lb-column` is one the table's `lb-filter` names. On mouse-up the
106
+ widget writes the filter to that column of `lb-choices`, replacing whatever
107
+ it held, and clears the selection. Where the selection lies in the cell's
108
+ text picks the operator:
109
+
110
+ | Selected | Filter |
111
+ | ---------------------- | ------ |
112
+ | the whole text | `=` |
113
+ | from its start | `^=` |
114
+ | up to its end | `$=` |
115
+ | anywhere else | `*=` |
116
+
117
+ A control naming the same column of `lb-choices` shows the filter and
118
+ clears it.
119
+
120
+ ```html
121
+ <div lb-query="lb-choices">
122
+ <lb-input lb-column="payee" lb-request="lb-row-update" exp-label="Payee"></lb-input>
123
+ </div>
124
+
125
+ <lb-table lb-query="ledger" lb-filter="payee" exp-caption="Ledger">
126
+ ...
127
+ </lb-table>
128
+ ```
129
+
130
+ A selection reaching across two cells, or into a cell whose column the
131
+ table does not filter, is left alone.
132
+
133
+ ## The ghost row
134
+
135
+ The `ghost` template is a blank row for entering a new one, in a `<tbody>` of
136
+ its own between the rows and the footer. It is not a live row: the hub never
137
+ reconciles it and never counts it, and lands on whatever in it names a query.
138
+
139
+ ```html
140
+ <template lb-exp-template="ghost">
141
+ <tr>
142
+ <td><lb-input lb-column="name" exp-label="Name"></lb-input></td>
143
+ <td><button lb-request="lb-row-insert">Save</button></td>
144
+ </tr>
145
+ </template>
146
+ ```
147
+
148
+ A `<form>` cannot wrap a `<tr>`, so the widget makes one outside the table
149
+ and joins the row's controls and buttons to it with the `form` attribute. A
150
+ button carrying `lb-row-insert` submits that form, the hub gathers what the
151
+ form owns, and resets it once the insert succeeds. The widget then puts the
152
+ cursor back in the row's first control. A refused insert leaves the cursor
153
+ where it was.
154
+
155
+ ## Scrolling
156
+
157
+ After rows land, the widget scrolls into view the row the page's own request
158
+ created, or moved by changing a column the order reads.
159
+
160
+ ## The footer
161
+
162
+ The footer is an ordinary part of the page, not a row from the table's query.
163
+ An aggregate there covers every row showing. A figure that is not a sum of the rows,
164
+ such as a budget, is a `<tr>` with its own `lb-query`, a query of kind
165
+ `row` declared on the server like any other.
166
+
167
+ ## Styling an empty table
168
+
169
+ `lb-table` carries `lb-query-row-count` with the number of rows showing, for a
170
+ stylesheet to read.
171
+
172
+ For rows with no table of their own, write the row template inside any element
173
+ that carries `lb-query`.
@@ -0,0 +1,32 @@
1
+ # `lb-tel`
2
+
3
+ > Status: a barebones starter. Iterative use will drive improvements.
4
+
5
+ A phone number shown as written, as a `tel:` link. Not a control: write
6
+ `lb-column` on the tag, and the hub lands the column on it and never gathers
7
+ it.
8
+
9
+ ```html
10
+ <lb-tel lb-column="phone"></lb-tel>
11
+ ```
12
+
13
+ It takes no parameters. To edit the number, use
14
+ `<lb-input exp-type="tel">`.
15
+
16
+ ## The value
17
+
18
+ The link's text is the value as it arrived. Its `href` keeps a leading `+`
19
+ and the digits, and drops everything else, so `(555) 123-4567` dials
20
+ `tel:5551234567`.
21
+
22
+ An extension written after `x`, `ext`, `ext.` or `extension` goes in the
23
+ `href` as `;ext=`, so `555-123-4567 x89` dials `tel:5551234567;ext=89`.
24
+
25
+ A value with no digits shows as it arrived, with no `href`. Null shows
26
+ nothing.
27
+
28
+ ## Styling
29
+
30
+ The definition is an `<a>`, with no `href` while there is nothing to dial,
31
+ so `lb-tel a:not([href])` selects a number that is no link. The hub stamps
32
+ the tag with `lb-column-value`, the value as it arrived.
@@ -0,0 +1,43 @@
1
+ # `lb-unknown-page`
2
+
3
+ > Status: a barebones starter. Iterative use will drive improvements.
4
+
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 no page's stub matches the path.
7
+
8
+ ```html
9
+ <lb-hub>
10
+ <nav>
11
+ <a href="/" lb-url-link>Home</a>
12
+ <a href="/about" lb-url-link>About</a>
13
+ </nav>
14
+ <main></main>
15
+ <lb-unknown-page></lb-unknown-page>
16
+ </lb-hub>
17
+ ```
18
+
19
+ ## Parameters
20
+
21
+ | Parameter | Fills |
22
+ | ----------------- | ------------------------------------- |
23
+ | `exp-button-text` | the text of the button that closes it |
24
+
25
+ Leaving `exp-button-text` off labels the button `OK`.
26
+
27
+ ## Binding
28
+
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
+
32
+ | Column | Holds |
33
+ | --------- | ------------------------ |
34
+ | `lb-path` | the path the browser has |
35
+
36
+ The widget shows the path. The dialog opens only when no page matches, so
37
+ there is no page label to show.
38
+
39
+ ## Inside the hub
40
+
41
+ The hub finds the dialog inside its own subtree and nowhere else, so the tag
42
+ goes inside `<lb-hub>`. The chrome reference of the loadbare-app skill shows
43
+ the same dialog written by hand in `chrome.html`.