@loadbare/app 0.21.0 → 0.23.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 +18 -0
- package/dist/build/assemble.d.ts.map +1 -1
- package/dist/build/assemble.js +8 -3
- package/dist/build/assemble.js.map +1 -1
- package/dist/build/build.d.ts +78 -0
- package/dist/build/build.d.ts.map +1 -0
- package/dist/build/build.js +220 -0
- package/dist/build/build.js.map +1 -0
- package/dist/build/cli.d.ts +6 -1
- package/dist/build/cli.d.ts.map +1 -1
- package/dist/build/cli.js +25 -78
- package/dist/build/cli.js.map +1 -1
- package/dist/build/declared.d.ts.map +1 -1
- package/dist/build/declared.js +3 -0
- package/dist/build/declared.js.map +1 -1
- package/dist/build/skills-cli.d.ts +2 -1
- package/dist/build/skills-cli.d.ts.map +1 -1
- package/dist/build/skills-cli.js +8 -1
- package/dist/build/skills-cli.js.map +1 -1
- package/dist/build/skills.d.ts +2 -0
- package/dist/build/skills.d.ts.map +1 -1
- package/dist/build/skills.js +2 -0
- package/dist/build/skills.js.map +1 -1
- package/dist/core/lb-constants.d.ts +14 -0
- package/dist/core/lb-constants.d.ts.map +1 -1
- package/dist/core/lb-constants.js +25 -0
- package/dist/core/lb-constants.js.map +1 -1
- package/dist/dev/lb-dev.d.ts +128 -0
- package/dist/dev/lb-dev.d.ts.map +1 -0
- package/dist/dev/lb-dev.js +289 -0
- package/dist/dev/lb-dev.js.map +1 -0
- package/dist/hub/lb-apply.d.ts.map +1 -1
- package/dist/hub/lb-apply.js +12 -6
- 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 +119 -15
- package/dist/hub/lb-hub.browser.js.map +1 -1
- package/docs/comparison.md +4 -3
- package/docs/miswarts.md +3 -2
- package/docs/reference/builder.md +12 -4
- package/docs/reference/chrome.md +52 -1
- package/docs/reference/data-binding.md +28 -18
- package/docs/reference/dev-server.md +178 -0
- package/docs/reference/names.md +14 -1
- package/docs/reference/overview.md +1 -0
- package/docs/reference/server.md +8 -3
- package/docs/reference/widgets.md +10 -277
- package/docs/temp-proposals.md +251 -0
- package/docs/testing.md +2 -1
- package/docs/tutorials/000-getting-started.md +1 -1
- package/docs/tutorials/040-displaying-data.md +1 -1
- package/docs/tutorials/090-using-widget-libraries.md +1 -1
- package/package.json +4 -2
- package/skills/loadbare-app/SKILL.md +30 -11
- package/skills/loadbare-app/references/builder.md +12 -4
- package/skills/loadbare-app/references/chrome.md +52 -1
- package/skills/loadbare-app/references/data-binding.md +28 -18
- package/skills/loadbare-app/references/dev-server.md +178 -0
- package/skills/loadbare-app/references/miswarts.md +3 -2
- package/skills/loadbare-app/references/names.md +14 -1
- package/skills/loadbare-app/references/overview.md +1 -0
- package/skills/loadbare-app/references/server.md +8 -3
- package/skills/loadbare-app/references/widgets.md +10 -277
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# The Basic Widget Library
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
`lb-master`, `lb-checkbox`, `lb-number` and `lb-date`. Every one of them is an ordinary custom element, written
|
|
3
|
+
`@loadbare/widgets` is the basic widget set: controls, a table, dialogs, and
|
|
4
|
+
elements that format a value. Every one of them is an ordinary custom element, written
|
|
6
5
|
against the contracts in [Custom Elements](./custom-elements.md#html) for its
|
|
7
6
|
definition and [Custom Elements](./custom-elements.md#code) for its class.
|
|
8
7
|
|
|
@@ -30,282 +29,16 @@ see [Being a control](./custom-elements.md#being-a-control). Each passes a
|
|
|
30
29
|
refusal's message for its column to the native control inside it; see
|
|
31
30
|
[Refusals](./data-binding.md#refusals).
|
|
32
31
|
|
|
33
|
-
##
|
|
32
|
+
## Each widget
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
Each widget's parameters, the attributes it reads, and what a change sends
|
|
35
|
+
are documented once, in the package that ships it: one page per widget,
|
|
36
|
+
which the loadbare-widgets skill carries. Install that skill beside this one:
|
|
37
37
|
|
|
38
|
-
```html
|
|
39
|
-
<lb-input lb-column="name" lb-request="lb-row-update" exp-label="Name"></lb-input>
|
|
40
38
|
```
|
|
41
|
-
|
|
42
|
-
Inside a form, leave `lb-request` off. The form gathers the widget on submit
|
|
43
|
-
like any other control, so a widget that also sent its own request would
|
|
44
|
-
write the same edit twice.
|
|
45
|
-
|
|
46
|
-
| Parameter | Fills |
|
|
47
|
-
|----------------|----------------------------------|
|
|
48
|
-
| `exp-label` | The visible `<label>` text |
|
|
49
|
-
| `exp-type` | The input's `type`, `text` when absent |
|
|
50
|
-
| `exp-readonly` | The input's `readonly` attribute |
|
|
51
|
-
|
|
52
|
-
## `lb-select`
|
|
53
|
-
|
|
54
|
-
Wraps a `<select>` whose `<option>`s the page writes inside the tag:
|
|
55
|
-
|
|
56
|
-
```html
|
|
57
|
-
<lb-select lb-column="team" lb-request="lb-row-update" exp-label="Team">
|
|
58
|
-
<option value="">No team</option>
|
|
59
|
-
<option value="Engines">Engines</option>
|
|
60
|
-
</lb-select>
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
| Parameter | Fills |
|
|
64
|
-
|-------------|----------------------------|
|
|
65
|
-
| `exp-label` | The visible `<label>` text |
|
|
66
|
-
|
|
67
|
-
## `lb-options`
|
|
68
|
-
|
|
69
|
-
A `<select>` whose `<option>`s are the rows of the query it names. The page
|
|
70
|
-
writes the row template inside the widget:
|
|
71
|
-
|
|
72
|
-
```html
|
|
73
|
-
<lb-options lb-query="statuses" lb-column="status" lb-request="lb-row-update" exp-label="Status">
|
|
74
|
-
<template><option lb-column="label"></option></template>
|
|
75
|
-
</lb-options>
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
| Parameter | Fills |
|
|
79
|
-
|-------------|----------------------------|
|
|
80
|
-
| `exp-label` | The visible `<label>` text |
|
|
81
|
-
| `exp-size` | The `<select>`'s `size`, an open list rather than a drop-down |
|
|
82
|
-
|
|
83
|
-
- Each option's `value` is its row's key, the `lb-key-value` the hub stamps
|
|
84
|
-
on the live row, so the widget holds a key and shows a label.
|
|
85
|
-
- A group template holding an `<optgroup>` puts the options in groups, one
|
|
86
|
-
per run of the query's order's leading term. The widget labels each
|
|
87
|
-
`<optgroup>` from the `lb-group-value` the hub stamps on it:
|
|
88
|
-
|
|
89
|
-
```html
|
|
90
|
-
<template lb-group>
|
|
91
|
-
<optgroup><template><option lb-column="label"></option></template></optgroup>
|
|
92
|
-
</template>
|
|
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.
|
|
97
|
-
- Its `value` selects the option with that key, including an option that
|
|
98
|
-
arrives after the value did.
|
|
99
|
-
|
|
100
|
-
`lb-picker` is the same class with the row template supplied by its
|
|
101
|
-
definition.
|
|
102
|
-
|
|
103
|
-
## `lb-picker`
|
|
104
|
-
|
|
105
|
-
`lb-options`, with the row template built in, for a list where every row is
|
|
106
|
-
one option showing one column:
|
|
107
|
-
|
|
108
|
-
```html
|
|
109
|
-
<lb-picker
|
|
110
|
-
lb-query="statuses"
|
|
111
|
-
lb-column="status"
|
|
112
|
-
lb-request="lb-row-update"
|
|
113
|
-
exp-label="Status"
|
|
114
|
-
exp-column="label"
|
|
115
|
-
></lb-picker>
|
|
39
|
+
npx loadbare-widgets skills install
|
|
116
40
|
```
|
|
117
41
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
| `exp-column` | The column each option shows |
|
|
122
|
-
|
|
123
|
-
An option built from two columns, a row with a second element, or options
|
|
124
|
-
in groups, is `lb-options` with the page's own templates.
|
|
125
|
-
|
|
126
|
-
## `lb-table`
|
|
127
|
-
|
|
128
|
-
A `<table>` that supplies its own scaffolding. The page supplies the heading
|
|
129
|
-
row, the row template, and optionally a footer, each as a `<template>`:
|
|
130
|
-
|
|
131
|
-
```html
|
|
132
|
-
<lb-table lb-query="ledger" exp-caption="Ledger">
|
|
133
|
-
<template lb-exp-template="head">
|
|
134
|
-
<tr><th>Date</th><th>Amount</th></tr>
|
|
135
|
-
</template>
|
|
136
|
-
<template lb-group>
|
|
137
|
-
<tr><th colspan="2" lb-column="month"></th></tr>
|
|
138
|
-
<template>
|
|
139
|
-
<tr><td lb-column="date"></td><td lb-column="amount"></td></tr>
|
|
140
|
-
</template>
|
|
141
|
-
</template>
|
|
142
|
-
<template lb-exp-template="foot">
|
|
143
|
-
<tr><td>Total</td><td lb-sum="amount"></td></tr>
|
|
144
|
-
</template>
|
|
145
|
-
</lb-table>
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
| Parameter | Fills |
|
|
149
|
-
|---------------|----------------------|
|
|
150
|
-
| `exp-caption` | The `<caption>` text |
|
|
151
|
-
|
|
152
|
-
| Template | Fills |
|
|
153
|
-
|-----------------------------------|-----------------------------------------|
|
|
154
|
-
| `<template lb-exp-template="head">` | The `<thead>` |
|
|
155
|
-
| `<template lb-exp-template="foot">` | The `<tfoot>` |
|
|
156
|
-
| Any other `<template>` | The row or group template, in the `<tbody>` |
|
|
157
|
-
|
|
158
|
-
- The hub places the rows by the query's order and builds its groups, and
|
|
159
|
-
leaves them where they stand for an edit from inside the table; see
|
|
160
|
-
[Rows the user is working in](./data-binding.md#rows-the-user-is-working-in). The
|
|
161
|
-
rows land in the one `<tbody>`, so a group here is a heading row with its
|
|
162
|
-
rows after it.
|
|
163
|
-
- `lb-order` and `lb-filter` go on the `lb-table` itself, beside
|
|
164
|
-
`lb-query`; see [Order](./data-binding.md#order) and
|
|
165
|
-
[Filters](./data-binding.md#filters).
|
|
166
|
-
- The footer is not a row of `ledger`. An aggregate there covers every row
|
|
167
|
-
showing;
|
|
168
|
-
a figure that is not a sum of the rows, such as a budget, is a `<tr>`
|
|
169
|
-
naming a `row` query of its own.
|
|
170
|
-
- A `<template lb-exp-template="ghost">` is a blank row for entering a new
|
|
171
|
-
one, in a `<tbody>` of its own. The widget joins its controls to a form
|
|
172
|
-
outside the table, since a `<form>` cannot wrap a `<tr>`, and puts the
|
|
173
|
-
cursor back in it once an insert from it succeeds.
|
|
174
|
-
- After rows land, the widget scrolls the row the page's own request created
|
|
175
|
-
or moved into view.
|
|
176
|
-
- Text selected in a cell whose `lb-column` the table's `lb-filter` names
|
|
177
|
-
becomes that column's filter in `lb-choices`: `=` for the whole text,
|
|
178
|
-
`^=` from its start, `$=` up to its end, `*=` otherwise.
|
|
179
|
-
- The heading of the order's leading column carries a triangle for the
|
|
180
|
-
direction, read from [`lb-query-order`](./data-binding.md#order). A
|
|
181
|
-
heading's column is the `lb-column` in the cell at its position in the row
|
|
182
|
-
template. While rows stand out of order the triangle carries
|
|
183
|
-
`data-unsorted` and a click on its heading re-sorts. With `lb-order`, a
|
|
184
|
-
click on the sorted heading reverses the order and a click on another
|
|
185
|
-
sorts by its column. Not on a grouped table.
|
|
186
|
-
|
|
187
|
-
## `lb-confirm`
|
|
188
|
-
|
|
189
|
-
A button that asks before it sends. The page writes the question inside the
|
|
190
|
-
tag, and the request goes on the dialog's confirm button, so nothing reaches
|
|
191
|
-
the hub until the user says yes:
|
|
192
|
-
|
|
193
|
-
```html
|
|
194
|
-
<lb-confirm exp-label="Delete" exp-request="lb-row-delete">
|
|
195
|
-
Delete <b lb-column="name"></b>?
|
|
196
|
-
</lb-confirm>
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
| Parameter | Fills |
|
|
200
|
-
|---------------|--------------------------------------------------|
|
|
201
|
-
| `exp-label` | The text of the button that opens the dialog |
|
|
202
|
-
| `exp-request` | The confirm button's `lb-request` |
|
|
203
|
-
| `exp-confirm` | The confirm button's text, `Confirm` when absent |
|
|
204
|
-
|
|
205
|
-
The widget closes the dialog once the request succeeds, and leaves it open
|
|
206
|
-
on a refusal.
|
|
207
|
-
|
|
208
|
-
## `lb-form`
|
|
209
|
-
|
|
210
|
-
A `<form>` over one row's controls. A row with a key saves each control's
|
|
211
|
-
column on `change`; a row whose key is empty is new, and the hub sends no
|
|
212
|
-
update for it, so its controls wait for a submit. A definition only.
|
|
213
|
-
|
|
214
|
-
| Parameter | Fills |
|
|
215
|
-
|-----------|-----------------|
|
|
216
|
-
| `exp-id` | The form's `id` |
|
|
217
|
-
|
|
218
|
-
## `lb-insert-dialog`
|
|
219
|
-
|
|
220
|
-
A row entered in a modal dialog, written once outside every row and opened
|
|
221
|
-
with `commandfor` and `command="show-modal"`. Save is the form's
|
|
222
|
-
`lb-row-insert`; on success the widget chooses the new row in the nearest
|
|
223
|
-
`lb-options` around the button that opened it, and closes. The handler
|
|
224
|
-
answers with a patch holding the new row.
|
|
225
|
-
|
|
226
|
-
While open, the button that opened it carries `insert-dialog-opener` and the
|
|
227
|
-
widget carries `anchored`, for a stylesheet to place the dialog beside the
|
|
228
|
-
button with CSS anchor positioning.
|
|
229
|
-
|
|
230
|
-
| Parameter | Fills |
|
|
231
|
-
|-------------|---------------------------------------------------|
|
|
232
|
-
| `exp-id` | The dialog's `id` |
|
|
233
|
-
| `exp-title` | The dialog's heading |
|
|
234
|
-
| `exp-query` | The form's `lb-query`, which it inserts into |
|
|
235
|
-
| `exp-save` | The Save button's text, `Save` when absent |
|
|
236
|
-
|
|
237
|
-
## `lb-master`
|
|
238
|
-
|
|
239
|
-
A set, one of its rows, and the buttons that act on the set: New, Copy,
|
|
240
|
-
Delete, Save new and Cancel, each shown only for a row on record or a new
|
|
241
|
-
one. A definition only, built from `lb-form` and `lb-confirm`. New sends
|
|
242
|
-
`new` and Copy sends `copy`, requests the page declares; `new` returns
|
|
243
|
-
`url()` emptying the parm that names the row.
|
|
244
|
-
|
|
245
|
-
| Parameter | Fills |
|
|
246
|
-
|---------------|--------------------------------------------|
|
|
247
|
-
| `exp-row` | The `lb-query` of the row the form shows |
|
|
248
|
-
| `exp-form-id` | The form's `id`, `master-form` when absent |
|
|
249
|
-
|
|
250
|
-
## `lb-checkbox`
|
|
251
|
-
|
|
252
|
-
A checkbox and its label as one element, for an application to style. A
|
|
253
|
-
definition only: a native checkbox is already a control (see
|
|
254
|
-
[Checkboxes](./data-binding.md#checkboxes)), so the widget is the markup, a
|
|
255
|
-
`<label>` holding the `<input type="checkbox">` and a `<span>` with the
|
|
256
|
-
text. The column and request go on the checkbox inside, so they arrive as
|
|
257
|
-
expansion attributes.
|
|
258
|
-
|
|
259
|
-
Unlike `lb-input`, it has no script making the tag the control. A value
|
|
260
|
-
that lands before a widget's script has loaded arrives only as the string
|
|
261
|
-
stamp `lb-column-value`, and a script checkbox would read `"false"` as
|
|
262
|
-
checked. The hub sets a native checkbox's `checked` directly.
|
|
263
|
-
|
|
264
|
-
| Parameter | Fills |
|
|
265
|
-
|---------------|-----------------------------------------------|
|
|
266
|
-
| `exp-column` | The checkbox's `lb-column` |
|
|
267
|
-
| `exp-label` | The label's text |
|
|
268
|
-
| `exp-request` | The checkbox's `lb-request`, none when absent |
|
|
269
|
-
|
|
270
|
-
## `lb-number` and `lb-date`
|
|
271
|
-
|
|
272
|
-
A number shown by the browser's `Intl.NumberFormat`, and a date or time
|
|
273
|
-
shown by `Intl.DateTimeFormat`. Neither is a control: `lb-column` goes on
|
|
274
|
-
the tag, and the widget renders the `lb-column-value` the hub stamps; see
|
|
275
|
-
[Receiving a value](./custom-elements.md#receiving-a-value).
|
|
276
|
-
|
|
277
|
-
```html
|
|
278
|
-
<lb-number lb-column="balance" exp-style="currency" exp-currency="USD"></lb-number>
|
|
279
|
-
<lb-date lb-column="due" exp-date-style="medium"></lb-date>
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
Each parameter is one of Intl's options in kebab-case, as `exp-currency-sign`
|
|
283
|
-
for `currencySign`, plus `exp-locale`. A value that is no number or date
|
|
284
|
-
shows as it arrived, and a date alone, `YYYY-MM-DD`, shows as that day in
|
|
285
|
-
every time zone. The stamp keeps the raw value, so a stylesheet selects on
|
|
286
|
-
it:
|
|
287
|
-
|
|
288
|
-
```css
|
|
289
|
-
lb-number[lb-column-value^="-"] { color: var(--negative); }
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
## `lb-unknown-page`
|
|
293
|
-
|
|
294
|
-
The chrome's dialog for a URL that names no page, as one tag:
|
|
295
|
-
|
|
296
|
-
```html
|
|
297
|
-
<lb-hub>
|
|
298
|
-
<nav>...</nav>
|
|
299
|
-
<main></main>
|
|
300
|
-
<lb-unknown-page></lb-unknown-page>
|
|
301
|
-
</lb-hub>
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
It expands to a `<dialog lb-url-unknown lb-query="lb-url">` showing
|
|
305
|
-
`lb-path`, and the hub opens it when no page's stub matches the path. See
|
|
306
|
-
[An unknown page](./chrome.md#an-unknown-page) for the same dialog written
|
|
307
|
-
by hand.
|
|
308
|
-
|
|
309
|
-
| Parameter | Fills |
|
|
310
|
-
|-------------------|------------------------------------------|
|
|
311
|
-
| `exp-button-text` | The text of the button that closes it, `OK` by default |
|
|
42
|
+
For a reader without the skill, the package's
|
|
43
|
+
[README](https://gitlab.com/kendowns/loadbare/-/blob/main/packages/widgets/README.md)
|
|
44
|
+
lists the widgets and links each page.
|