@loadbare/widgets 0.5.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 (49) hide show
  1. package/README.md +5 -1
  2. package/dist/control.d.ts +4 -7
  3. package/dist/control.d.ts.map +1 -1
  4. package/dist/control.js +2 -3
  5. package/dist/control.js.map +1 -1
  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 +7 -7
  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 +29 -10
  30. package/dist/lb-options.browser.d.ts.map +1 -1
  31. package/dist/lb-options.browser.js +26 -55
  32. package/dist/lb-options.browser.js.map +1 -1
  33. package/dist/lb-picker.browser.js +7 -10
  34. package/dist/lb-picker.browser.js.map +1 -1
  35. package/dist/lb-picker.html +1 -1
  36. package/dist/lb-select.browser.js +4 -7
  37. package/dist/lb-select.browser.js.map +1 -1
  38. package/dist/lb-table.browser.js +61 -88
  39. package/dist/lb-table.browser.js.map +1 -1
  40. package/dist/lb-table.html +1 -0
  41. package/docs/lb-confirm.md +45 -0
  42. package/docs/lb-form.md +33 -0
  43. package/docs/lb-input.md +1 -0
  44. package/docs/lb-insert-dialog.md +50 -0
  45. package/docs/lb-master.md +53 -0
  46. package/docs/lb-options.md +11 -7
  47. package/docs/lb-picker.md +10 -11
  48. package/docs/lb-table.md +52 -20
  49. package/package.json +4 -4
@@ -0,0 +1,53 @@
1
+ # `lb-master`
2
+
3
+ > Status: a barebones starter. Iterative use will drive improvements.
4
+
5
+ A set on one side, one of its rows on the other, and the buttons that act on
6
+ the set. A definition only, with no script of its own: it is built from
7
+ [`lb-form`](./lb-form.md) and [`lb-confirm`](./lb-confirm.md).
8
+
9
+ Requires `exp-row`.
10
+
11
+ ```html
12
+ <lb-master exp-row="account">
13
+ <template lb-exp-template="picker">
14
+ <div lb-query="lb-url">
15
+ <lb-picker lb-query="accounts" lb-column="acct" lb-request="lb-row-update"
16
+ exp-label="Account" exp-column="name"></lb-picker>
17
+ </div>
18
+ </template>
19
+ <lb-input lb-column="name" exp-label="Name" lb-request="lb-row-update"></lb-input>
20
+ <template lb-exp-template="delete-message">
21
+ Delete <b lb-column="name"></b>?
22
+ </template>
23
+ </lb-master>
24
+ ```
25
+
26
+ ## Expansion Attributes
27
+
28
+ | Parameter | Fills |
29
+ | -------------- | ---------------------------------------------- |
30
+ | `exp-row` | the `lb-query` of the row the form shows |
31
+ | `exp-form-id` | the form's `id`, `master-form` when absent |
32
+
33
+ | Template | Fills |
34
+ | ------------------------------------------- | ----------------------------- |
35
+ | `<template lb-exp-template="picker">` | the side that chooses the row |
36
+ | `<template lb-exp-template="delete-message">` | the question Delete asks |
37
+
38
+ ## The buttons
39
+
40
+ | Button | Shows | Does |
41
+ | -------- | ----------------- | --------------------------------------------- |
42
+ | Copy | A row on record | Sends `copy`, a request the page declares |
43
+ | Delete | A row on record | Asks, then sends `lb-row-delete` |
44
+ | Save new | A new row | Submits the form as `lb-row-insert`, and pushes a history entry |
45
+ | Cancel | A new row | Resets the form |
46
+
47
+ Each carries `data-mode`, `on-record` or `new`, and the stylesheet shows each
48
+ only in its mode. A new row is one whose key is empty. New is not a button:
49
+ a button cannot write a query parm, so choosing the picker's blank starts a
50
+ new row.
51
+
52
+ Copy goes to the server rather than filling the form, because a copy is a new
53
+ row in the set, and only the server can bring its children along.
@@ -6,8 +6,8 @@ query.
6
6
  Apply the `lb-query` attribute to name the query, `lb-column` to name the
7
7
  column the choice shows and gathers to, and `lb-request` to name the request a
8
8
  change issues. Write a `<template>` inside the tag, and apply `lb-column` to
9
- the `<option>` itself — an `<option>` holds text, not elements. Apply
10
- `data-group` to the template to section the options.
9
+ the `<option>` itself — an `<option>` holds text, not elements. For options
10
+ in groups, write a group template holding an `<optgroup>`.
11
11
 
12
12
  Provide `exp-label`.
13
13
 
@@ -18,8 +18,10 @@ Provide `exp-label`.
18
18
  exp-label="Status"
19
19
  lb-request="setStatus"
20
20
  >
21
- <template data-group="category">
22
- <option lb-column="label"></option>
21
+ <template lb-group>
22
+ <optgroup>
23
+ <template><option lb-column="label"></option></template>
24
+ </optgroup>
23
25
  </template>
24
26
  </lb-options>
25
27
  ```
@@ -42,7 +44,7 @@ improvements through iterative use.
42
44
  | `lb-query` | the element itself | the query whose rows become options |
43
45
  | `lb-column` | the element itself | the column the choice shows and gathers to |
44
46
  | `lb-request` | the element itself | the request a change issues |
45
- | `data-group` | the row template | the column that sections the options |
47
+ | `lb-group` | a template holding an `<optgroup>` | a group of options |
46
48
  | `lb-column` | the `<option>` | the column the option shows |
47
49
 
48
50
  The server declares the query's key. The widget copies each option's
@@ -50,8 +52,10 @@ The server declares the query's key. The widget copies each option's
50
52
 
51
53
  ## Grouping
52
54
 
53
- `data-group` names a column whose distinct values become `<optgroup>`s, each
54
- labelled with the value.
55
+ The hub makes one `<optgroup>` per run of the query's order's leading term.
56
+ An `<optgroup>` takes its label from an attribute, which landing does not
57
+ set, so the widget labels each from the `lb-group-value` the hub stamps on
58
+ it: the value the group breaks on.
55
59
 
56
60
  ## The control
57
61
 
package/docs/lb-picker.md CHANGED
@@ -1,13 +1,15 @@
1
1
  # `lb-picker`
2
2
 
3
3
  [`lb-options`](./lb-options.md) with the row template built in, for when every
4
- row is one option and only the column names vary. It takes no children.
4
+ row is one option and only the column it shows varies. It takes no
5
+ children. Options in groups take a group template, which is `lb-options`
6
+ with the page's own templates.
5
7
 
6
8
  Apply the `lb-query` attribute to name the query, `lb-column` to name the
7
9
  column the choice shows and gathers to, and `lb-request` to name the request a
8
10
  change issues.
9
11
 
10
- Provide `exp-label`, `exp-column`, and optionally `exp-group`.
12
+ Provide `exp-label` and `exp-column`.
11
13
 
12
14
  ```html
13
15
  <lb-picker
@@ -15,7 +17,6 @@ Provide `exp-label`, `exp-column`, and optionally `exp-group`.
15
17
  lb-column="status_id"
16
18
  exp-label="Status"
17
19
  exp-column="label"
18
- exp-group="category"
19
20
  lb-request="setStatus"
20
21
  ></lb-picker>
21
22
  ```
@@ -27,15 +28,13 @@ improvements through iterative use.
27
28
 
28
29
  ## Parameters
29
30
 
30
- | Parameter | Fills |
31
- | ------------ | ------------------------------------------------ |
32
- | `exp-label` | the visible `<label>` text |
33
- | `exp-column` | the column the option shows |
34
- | `exp-group` | the column that sections the options, if grouped |
31
+ | Parameter | Fills |
32
+ | ------------ | --------------------------- |
33
+ | `exp-label` | the visible `<label>` text |
34
+ | `exp-column` | the column the option shows |
35
35
 
36
- `exp-column` is required. Leaving `exp-group` off leaves the options
37
- ungrouped. The server declares the query's key, which becomes each option's
38
- `value`.
36
+ `exp-column` is required. The server declares the query's key, which
37
+ becomes each option's `value`.
39
38
 
40
39
  ## Attributes
41
40
 
package/docs/lb-table.md CHANGED
@@ -4,9 +4,10 @@ A wrapper for HTML Table, supplying the `<table>` itself.
4
4
 
5
5
  Apply the `lb-query` attribute to name the query. Write three `<template>`s
6
6
  inside the tag: one marked `lb-exp-template="head"` for the heading row, one
7
- unmarked for the row, and optionally one marked `lb-exp-template="foot"` for
8
- the footer. Apply `data-sort` and `data-group` to the row template to order
9
- and section the rows.
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
 
@@ -15,11 +16,14 @@ Provide `exp-caption`.
15
16
  <template lb-exp-template="head">
16
17
  <tr><th>Date</th><th>Amount</th></tr>
17
18
  </template>
18
- <template data-sort="date" data-group="month">
19
- <tr><td lb-column="date"></td><td lb-column="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
25
  <template lb-exp-template="foot">
22
- <tr lb-query="ledger-total"><td>Total</td><td lb-column="total"></td></tr>
26
+ <tr><td>Total</td><td lb-sum="amount"></td></tr>
23
27
  </template>
24
28
  </lb-table>
25
29
  ```
@@ -40,27 +44,55 @@ improvements through iterative use.
40
44
 
41
45
  ## Attributes
42
46
 
43
- | Attribute | On | Names |
44
- | ------------ | -------------------------------- | ---------------------------------- |
45
- | `lb-query` | the element itself | the query whose rows fill the body |
46
- | `data-sort` | the row template | the column rows are ordered by |
47
- | `data-group` | the row template | the column rows are sectioned by |
48
- | `lb-column` | 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 |
49
52
 
50
- The server declares the query's key.
53
+ The server declares the query's key and its order.
51
54
 
52
- ## Sorting and grouping
55
+ ## Order and groups
53
56
 
54
- `data-sort` names the column rows are ordered by, comparing the text each row
55
- shows. `data-group` names the column they are sectioned by: each distinct
56
- value gets a heading row of its own, spanning the width of the row template,
57
- and rows sort within their section.
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.
58
89
 
59
90
  ## The footer
60
91
 
61
92
  The footer is an ordinary part of the page, not a row from the table's query.
62
- Give it its own `lb-query` — a grand total is a second query of kind `row`,
63
- declared on the 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.
64
96
 
65
97
  ## Styling an empty table
66
98
 
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.5.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.10.0 <1.0.0"
52
+ "@loadbare/app": ">=0.13.0 <1.0.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@loadbare/app": ">=0.10.0 <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",