@loadbare/widgets 0.6.0 → 0.8.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 +1 -0
- package/dist/control.d.ts +17 -11
- package/dist/control.d.ts.map +1 -1
- package/dist/control.js +21 -17
- package/dist/control.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/lb-checkbox.html +13 -0
- package/dist/lb-confirm.browser.js +7 -7
- package/dist/lb-confirm.browser.js.map +1 -1
- package/dist/lb-insert-dialog.browser.js +14 -17
- package/dist/lb-insert-dialog.browser.js.map +1 -1
- package/dist/lb-master.html +7 -2
- package/dist/lb-options.browser.d.ts +2 -2
- package/dist/lb-options.browser.d.ts.map +1 -1
- package/dist/lb-options.browser.js.map +1 -1
- package/dist/lb-table.browser.js +16 -24
- package/dist/lb-table.browser.js.map +1 -1
- package/docs/lb-checkbox.md +63 -0
- package/docs/lb-confirm.md +1 -2
- package/docs/lb-form.md +5 -3
- package/docs/lb-input.md +0 -4
- package/docs/lb-insert-dialog.md +1 -2
- package/docs/lb-master.md +15 -3
- package/package.json +4 -4
- package/dist/lb-form.browser.d.ts +0 -2
- package/dist/lb-form.browser.d.ts.map +0 -1
- package/dist/lb-form.browser.js +0 -28
- package/dist/lb-form.browser.js.map +0 -1
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ Inventory:
|
|
|
16
16
|
| [`lb-form`](docs/lb-form.md) | a form over one row, which saves per control once the row is on record |
|
|
17
17
|
| [`lb-insert-dialog`](docs/lb-insert-dialog.md) | a row entered in a modal dialog, chosen in the picker that opened it |
|
|
18
18
|
| [`lb-master`](docs/lb-master.md) | a set, one of its rows, and the buttons that act on the set |
|
|
19
|
+
| [`lb-checkbox`](docs/lb-checkbox.md) | a checkbox and its label, as markup to style |
|
|
19
20
|
|
|
20
21
|
## Installing
|
|
21
22
|
|
package/dist/control.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HubLifecycle } from "@loadbare/app/types";
|
|
1
2
|
/**
|
|
2
3
|
* A form-associated custom element wrapping one native control, which makes
|
|
3
4
|
* the widget itself the control: the hub sets its `value` when a column
|
|
@@ -12,7 +13,7 @@
|
|
|
12
13
|
* a consumer's builder passes it over, and each widget that extends it
|
|
13
14
|
* brings it along.
|
|
14
15
|
*/
|
|
15
|
-
export declare abstract class WrappedControl extends HTMLElement {
|
|
16
|
+
export declare abstract class WrappedControl extends HTMLElement implements HubLifecycle {
|
|
16
17
|
static formAssociated: boolean;
|
|
17
18
|
/** The tag of the native control this widget wraps. */
|
|
18
19
|
protected abstract inner: string;
|
|
@@ -22,20 +23,14 @@ export declare abstract class WrappedControl extends HTMLElement {
|
|
|
22
23
|
* leaves it out.
|
|
23
24
|
*/
|
|
24
25
|
private internals;
|
|
25
|
-
/** Whether the widget has connected once. */
|
|
26
|
-
private connected;
|
|
27
26
|
constructor();
|
|
28
27
|
/**
|
|
29
|
-
* A value that landed before this widget's definition did is only a
|
|
30
|
-
* stamp, since the hub sets `value` on a control and the element was not
|
|
31
|
-
* one yet. It is taken up the first time the widget connects, and never
|
|
32
|
-
* again: after that the hub sets `value` itself, and a later move must not
|
|
33
|
-
* undo an edit.
|
|
34
|
-
*
|
|
35
28
|
* The native control follows the widget's `form` attribute, so a form
|
|
36
|
-
* this widget joins by id resets the control inside it too.
|
|
29
|
+
* this widget joins by id resets the control inside it too. An element
|
|
30
|
+
* around this one that joins it to a form does so in its own
|
|
31
|
+
* `lbAttached`, which the hub calls first.
|
|
37
32
|
*/
|
|
38
|
-
|
|
33
|
+
lbAttached(): void;
|
|
39
34
|
/** The native control this widget wraps, once it is there. */
|
|
40
35
|
protected get control(): HTMLInputElement | HTMLSelectElement | null;
|
|
41
36
|
get value(): string;
|
|
@@ -46,6 +41,17 @@ export declare abstract class WrappedControl extends HTMLElement {
|
|
|
46
41
|
* form its value once the control has been reset.
|
|
47
42
|
*/
|
|
48
43
|
formResetCallback(): void;
|
|
44
|
+
/**
|
|
45
|
+
* A message the hub sets when a handler refuses this control's column. It
|
|
46
|
+
* goes on the native control inside, which is what the form checks before
|
|
47
|
+
* it submits, what the browser shows the message beside, and what takes
|
|
48
|
+
* focus when it is reported.
|
|
49
|
+
*/
|
|
50
|
+
setCustomValidity(message: string): void;
|
|
51
|
+
/** Show the native control's message, and focus it. */
|
|
52
|
+
reportValidity(): boolean;
|
|
53
|
+
/** The native control's message, empty when it has none. */
|
|
54
|
+
get validationMessage(): string;
|
|
49
55
|
/** The inner control changed, before the widget fires its own `change`. */
|
|
50
56
|
protected changed(): void;
|
|
51
57
|
/** Tell the form owner the value, where the implementation allows it. */
|
package/dist/control.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../widgets/control.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../widgets/control.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,8BAAsB,cACpB,SAAQ,WACR,YAAW,YAAY;IAEvB,MAAM,CAAC,cAAc,UAAQ;IAE7B,uDAAuD;IACvD,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEjC;;;;OAIG;IACH,OAAO,CAAC,SAAS,CAAqB;;IAYtC;;;;;OAKG;IACH,UAAU,IAAI,IAAI;IAKlB,8DAA8D;IAC9D,SAAS,KAAK,OAAO,IAAI,gBAAgB,GAAG,iBAAiB,GAAG,IAAI,CAEnE;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAUtB;IAED;;;;OAIG;IACH,iBAAiB,IAAI,IAAI;IAIzB;;;;;OAKG;IACH,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIxC,uDAAuD;IACvD,cAAc,IAAI,OAAO;IAIzB,4DAA4D;IAC5D,IAAI,iBAAiB,IAAI,MAAM,CAE9B;IAED,2EAA2E;IAC3E,SAAS,CAAC,OAAO,IAAI,IAAI;IAIzB,yEAAyE;IACzE,SAAS,CAAC,SAAS,IAAI,IAAI;CAG5B"}
|
package/dist/control.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference lib="dom" />
|
|
2
|
-
import { ATTR_COLUMN_VALUE } from "@loadbare/app/constants";
|
|
3
2
|
/**
|
|
4
3
|
* A form-associated custom element wrapping one native control, which makes
|
|
5
4
|
* the widget itself the control: the hub sets its `value` when a column
|
|
@@ -22,8 +21,6 @@ export class WrappedControl extends HTMLElement {
|
|
|
22
21
|
* leaves it out.
|
|
23
22
|
*/
|
|
24
23
|
internals = internalsOf(this);
|
|
25
|
-
/** Whether the widget has connected once. */
|
|
26
|
-
connected = false;
|
|
27
24
|
constructor() {
|
|
28
25
|
super();
|
|
29
26
|
this.addEventListener("change", (e) => {
|
|
@@ -35,25 +32,15 @@ export class WrappedControl extends HTMLElement {
|
|
|
35
32
|
});
|
|
36
33
|
}
|
|
37
34
|
/**
|
|
38
|
-
* A value that landed before this widget's definition did is only a
|
|
39
|
-
* stamp, since the hub sets `value` on a control and the element was not
|
|
40
|
-
* one yet. It is taken up the first time the widget connects, and never
|
|
41
|
-
* again: after that the hub sets `value` itself, and a later move must not
|
|
42
|
-
* undo an edit.
|
|
43
|
-
*
|
|
44
35
|
* The native control follows the widget's `form` attribute, so a form
|
|
45
|
-
* this widget joins by id resets the control inside it too.
|
|
36
|
+
* this widget joins by id resets the control inside it too. An element
|
|
37
|
+
* around this one that joins it to a form does so in its own
|
|
38
|
+
* `lbAttached`, which the hub calls first.
|
|
46
39
|
*/
|
|
47
|
-
|
|
40
|
+
lbAttached() {
|
|
48
41
|
const form = this.getAttribute("form");
|
|
49
42
|
if (form !== null)
|
|
50
43
|
this.control?.setAttribute("form", form);
|
|
51
|
-
if (this.connected)
|
|
52
|
-
return;
|
|
53
|
-
this.connected = true;
|
|
54
|
-
const stamped = this.getAttribute(ATTR_COLUMN_VALUE);
|
|
55
|
-
if (stamped !== null)
|
|
56
|
-
this.value = stamped;
|
|
57
44
|
}
|
|
58
45
|
/** The native control this widget wraps, once it is there. */
|
|
59
46
|
get control() {
|
|
@@ -79,6 +66,23 @@ export class WrappedControl extends HTMLElement {
|
|
|
79
66
|
formResetCallback() {
|
|
80
67
|
queueMicrotask(() => this.formValue());
|
|
81
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* A message the hub sets when a handler refuses this control's column. It
|
|
71
|
+
* goes on the native control inside, which is what the form checks before
|
|
72
|
+
* it submits, what the browser shows the message beside, and what takes
|
|
73
|
+
* focus when it is reported.
|
|
74
|
+
*/
|
|
75
|
+
setCustomValidity(message) {
|
|
76
|
+
this.control?.setCustomValidity(message);
|
|
77
|
+
}
|
|
78
|
+
/** Show the native control's message, and focus it. */
|
|
79
|
+
reportValidity() {
|
|
80
|
+
return this.control?.reportValidity() ?? true;
|
|
81
|
+
}
|
|
82
|
+
/** The native control's message, empty when it has none. */
|
|
83
|
+
get validationMessage() {
|
|
84
|
+
return this.control?.validationMessage ?? "";
|
|
85
|
+
}
|
|
82
86
|
/** The inner control changed, before the widget fires its own `change`. */
|
|
83
87
|
changed() {
|
|
84
88
|
this.formValue();
|
package/dist/control.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.js","sourceRoot":"","sources":["../widgets/control.ts"],"names":[],"mappings":"AAAA,2BAA2B;
|
|
1
|
+
{"version":3,"file":"control.js","sourceRoot":"","sources":["../widgets/control.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAI3B;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAgB,cACpB,SAAQ,WAAW;IAGnB,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC;IAK7B;;;;OAIG;IACK,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAEtC;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;YACpC,IAAI,CAAC,CAAC,MAAM,KAAK,IAAI,IAAI,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO;gBAAE,OAAO;YAC3D,CAAC,CAAC,eAAe,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,UAAU;QACR,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,IAAI,KAAK,IAAI;YAAE,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC9D,CAAC;IAED,8DAA8D;IAC9D,IAAc,OAAO;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,KAAK,CAAC,KAAa;QACrB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CACX,GAAG,IAAI,CAAC,SAAS,SAAS,IAAI,CAAC,KAAK,wBAAwB,CAC7D,CAAC;YACF,OAAO;QACT,CAAC;QACD,OAAO,CAAC,KAAK,GAAG,KAAK,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACH,iBAAiB;QACf,cAAc,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;IACzC,CAAC;IAED;;;;;OAKG;IACH,iBAAiB,CAAC,OAAe;QAC/B,IAAI,CAAC,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,uDAAuD;IACvD,cAAc;QACZ,OAAO,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,IAAI,CAAC;IAChD,CAAC;IAED,4DAA4D;IAC5D,IAAI,iBAAiB;QACnB,OAAO,IAAI,CAAC,OAAO,EAAE,iBAAiB,IAAI,EAAE,CAAC;IAC/C,CAAC;IAED,2EAA2E;IACjE,OAAO;QACf,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAED,yEAAyE;IAC/D,SAAS;QACjB,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;;AAGH,SAAS,WAAW,CAAC,EAAe;IAClC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC;QACvC,OAAO,OAAO,SAAS,CAAC,YAAY,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IACzE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["/// <reference lib=\"dom\" />\n\nimport type { HubLifecycle } from \"@loadbare/app/types\";\n\n/**\n * A form-associated custom element wrapping one native control, which makes\n * the widget itself the control: the hub sets its `value` when a column\n * lands, reads it back when a request gathers, and commits it on `change`\n * when it carries `lb-request`. Nothing about a request is the widget's.\n *\n * The native control inside is an implementation detail. Its `change` is\n * stopped and fired again on the widget, so a listener sees one control and\n * one event per edit.\n *\n * Not a widget itself, so the file carries no `.browser` and no `lb-` name:\n * a consumer's builder passes it over, and each widget that extends it\n * brings it along.\n */\nexport abstract class WrappedControl\n extends HTMLElement\n implements HubLifecycle\n{\n static formAssociated = true;\n\n /** The tag of the native control this widget wraps. */\n protected abstract inner: string;\n\n /**\n * Null where the DOM implementation offers no form value, which includes\n * jsdom: the widget still works as a control, and a native form submission\n * leaves it out.\n */\n private internals = internalsOf(this);\n\n constructor() {\n super();\n this.addEventListener(\"change\", (e) => {\n if (e.target === this || e.target !== this.control) return;\n e.stopPropagation();\n this.changed();\n this.dispatchEvent(new Event(\"change\", { bubbles: true }));\n });\n }\n\n /**\n * The native control follows the widget's `form` attribute, so a form\n * this widget joins by id resets the control inside it too. An element\n * around this one that joins it to a form does so in its own\n * `lbAttached`, which the hub calls first.\n */\n lbAttached(): void {\n const form = this.getAttribute(\"form\");\n if (form !== null) this.control?.setAttribute(\"form\", form);\n }\n\n /** The native control this widget wraps, once it is there. */\n protected get control(): HTMLInputElement | HTMLSelectElement | null {\n return this.querySelector(this.inner);\n }\n\n get value(): string {\n return this.control?.value ?? \"\";\n }\n\n set value(value: string) {\n const control = this.control;\n if (!control) {\n console.error(\n `${this.localName}: no <${this.inner}> to receive the value`,\n );\n return;\n }\n control.value = value ?? \"\";\n this.formValue();\n }\n\n /**\n * The native control is the form's too, and the form resets it by HTML's\n * own algorithm. This widget comes first in tree order, so it tells the\n * form its value once the control has been reset.\n */\n formResetCallback(): void {\n queueMicrotask(() => this.formValue());\n }\n\n /**\n * A message the hub sets when a handler refuses this control's column. It\n * goes on the native control inside, which is what the form checks before\n * it submits, what the browser shows the message beside, and what takes\n * focus when it is reported.\n */\n setCustomValidity(message: string): void {\n this.control?.setCustomValidity(message);\n }\n\n /** Show the native control's message, and focus it. */\n reportValidity(): boolean {\n return this.control?.reportValidity() ?? true;\n }\n\n /** The native control's message, empty when it has none. */\n get validationMessage(): string {\n return this.control?.validationMessage ?? \"\";\n }\n\n /** The inner control changed, before the widget fires its own `change`. */\n protected changed(): void {\n this.formValue();\n }\n\n /** Tell the form owner the value, where the implementation allows it. */\n protected formValue(): void {\n this.internals?.setFormValue(this.value);\n }\n}\n\nfunction internalsOf(el: HTMLElement): ElementInternals | null {\n try {\n const internals = el.attachInternals();\n return typeof internals.setFormValue === \"function\" ? internals : null;\n } catch {\n return null;\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../widgets/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AACjC,OAAO,uBAAuB,CAAC;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AACjC,OAAO
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../widgets/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AACjC,OAAO,uBAAuB,CAAC;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AACjC,OAAO,+BAA+B,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../widgets/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AACjC,OAAO,uBAAuB,CAAC;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AACjC,OAAO
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../widgets/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AACjC,OAAO,uBAAuB,CAAC;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AACjC,OAAO,+BAA+B,CAAC","sourcesContent":["import \"./lb-input.browser.js\";\nimport \"./lb-select.browser.js\";\nimport \"./lb-options.browser.js\";\nimport \"./lb-table.browser.js\";\nimport \"./lb-picker.browser.js\";\nimport \"./lb-confirm.browser.js\";\nimport \"./lb-insert-dialog.browser.js\";\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
A checkbox with its label, as markup alone. The hub treats a native
|
|
3
|
+
checkbox as a control, so there is nothing for script to do: the widget
|
|
4
|
+
gives the box and its text one element an application styles.
|
|
5
|
+
|
|
6
|
+
The column and request go on the checkbox inside, since that is the
|
|
7
|
+
control, so they arrive as exp-column and exp-request rather than as
|
|
8
|
+
lb-column and lb-request on the tag.
|
|
9
|
+
-->
|
|
10
|
+
<label>
|
|
11
|
+
<input type="checkbox" lb-column="{{column}}" lb-request="{{request}}" />
|
|
12
|
+
<span>{{label}}</span>
|
|
13
|
+
</label>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference lib="dom" />
|
|
2
|
-
import { LB_DONE_EVENT_NAME } from "@loadbare/app/constants";
|
|
3
2
|
/**
|
|
4
3
|
* Opens and closes its own dialog, and nothing else.
|
|
5
4
|
*
|
|
@@ -8,8 +7,8 @@ import { LB_DONE_EVENT_NAME } from "@loadbare/app/constants";
|
|
|
8
7
|
* own `commandfor` would open it with no script, but only by id.
|
|
9
8
|
*
|
|
10
9
|
* The confirm button carries `lb-request`, and the hub commits it. This code
|
|
11
|
-
* never touches the request; it closes the dialog when
|
|
12
|
-
*
|
|
10
|
+
* never touches the request; it closes the dialog when the hub says the
|
|
11
|
+
* request succeeded. A refused request leaves the dialog open, with the
|
|
13
12
|
* hub's `lb-request-error` on the confirm button, so the user sees the
|
|
14
13
|
* refusal where they asked and can cancel or try again.
|
|
15
14
|
*/
|
|
@@ -23,14 +22,15 @@ class LbConfirm extends HTMLElement {
|
|
|
23
22
|
else if (target.closest("[data-close]"))
|
|
24
23
|
this.dialog.close();
|
|
25
24
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
}
|
|
26
|
+
lbRequestDone({ error }) {
|
|
27
|
+
if (!error)
|
|
28
|
+
this.dialog.close();
|
|
30
29
|
}
|
|
31
30
|
get dialog() {
|
|
32
31
|
return this.querySelector("dialog");
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
customElements.define("lb-confirm", LbConfirm);
|
|
35
|
+
export {};
|
|
36
36
|
//# sourceMappingURL=lb-confirm.browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lb-confirm.browser.js","sourceRoot":"","sources":["../widgets/lb-confirm.browser.ts"],"names":[],"mappings":"AAAA,2BAA2B;
|
|
1
|
+
{"version":3,"file":"lb-confirm.browser.js","sourceRoot":"","sources":["../widgets/lb-confirm.browser.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAI3B;;;;;;;;;;;;GAYG;AACH,MAAM,SAAU,SAAQ,WAAW;IACjC;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACnC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAiB,CAAC;YACnC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC;gBAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;iBACtD,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC;gBAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC/D,CAAC,CAAC,CAAC;IACL,CAAC;IAED,aAAa,CAAC,EAAE,KAAK,EAAkB;QACrC,IAAI,CAAC,KAAK;YAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;IAED,IAAY,MAAM;QAChB,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAE,CAAC;IACvC,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC","sourcesContent":["/// <reference lib=\"dom\" />\n\nimport type { HubLifecycle, HubRequestDone } from \"@loadbare/app/types\";\n\n/**\n * Opens and closes its own dialog, and nothing else.\n *\n * The dialog is found by position rather than by id, because ids repeat when\n * the tag sits in a row template and the hub clones it once per row. HTML's\n * own `commandfor` would open it with no script, but only by id.\n *\n * The confirm button carries `lb-request`, and the hub commits it. This code\n * never touches the request; it closes the dialog when the hub says the\n * request succeeded. A refused request leaves the dialog open, with the\n * hub's `lb-request-error` on the confirm button, so the user sees the\n * refusal where they asked and can cancel or try again.\n */\nclass LbConfirm extends HTMLElement implements HubLifecycle {\n constructor() {\n super();\n this.addEventListener(\"click\", (e) => {\n const target = e.target as Element;\n if (target.closest(\"[data-open]\")) this.dialog.showModal();\n else if (target.closest(\"[data-close]\")) this.dialog.close();\n });\n }\n\n lbRequestDone({ error }: HubRequestDone): void {\n if (!error) this.dialog.close();\n }\n\n private get dialog(): HTMLDialogElement {\n return this.querySelector(\"dialog\")!;\n }\n}\n\ncustomElements.define(\"lb-confirm\", LbConfirm);\n"]}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
/// <reference lib="dom" />
|
|
2
|
-
import { LB_DONE_EVENT_NAME } from "@loadbare/app/constants";
|
|
3
2
|
/**
|
|
4
3
|
* Two rules. Closing the dialog resets the form, and the row the form creates
|
|
5
4
|
* is chosen in the picker the dialog was opened from.
|
|
6
5
|
*
|
|
7
|
-
* Save closes the dialog when
|
|
8
|
-
*
|
|
9
|
-
* correct. Cancel and Escape close it, and throw away what was typed.
|
|
6
|
+
* Save closes the dialog when the hub says the insert succeeded, so there
|
|
7
|
+
* is a row to show for it, and a refusal leaves the entry open to correct. Cancel and Escape close it, and throw away what was typed.
|
|
10
8
|
*
|
|
11
9
|
* The picker is the nearest `lb-options` around the button that opened the
|
|
12
10
|
* dialog, which a `command` event names as its `source`. The new row's key is
|
|
13
|
-
* in the patch the insert answers with, and by the time
|
|
14
|
-
*
|
|
11
|
+
* in the patch the insert answers with, and by the time the hub calls
|
|
12
|
+
* `lbRequestDone` that row is among the picker's options. Choosing it fires
|
|
15
13
|
* `change`, so a picker that saves its own column saves it, and one in a ghost
|
|
16
14
|
* row or a new record holds it until Save.
|
|
17
15
|
*
|
|
@@ -26,17 +24,15 @@ class LbInsertDialog extends HTMLElement {
|
|
|
26
24
|
this.addEventListener("command", (e) => {
|
|
27
25
|
this.opener = e.source ?? null;
|
|
28
26
|
}, true);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.querySelector("dialog")?.close();
|
|
39
|
-
});
|
|
27
|
+
}
|
|
28
|
+
lbRequestDone({ request, items, error }) {
|
|
29
|
+
if (error)
|
|
30
|
+
return;
|
|
31
|
+
const item = items.find((i) => i.query === request.query);
|
|
32
|
+
const created = item?.patch?.rows?.[0];
|
|
33
|
+
if (created)
|
|
34
|
+
this.choose(String(created[item.key]));
|
|
35
|
+
this.querySelector("dialog")?.close();
|
|
40
36
|
}
|
|
41
37
|
choose(key) {
|
|
42
38
|
const picker = pickerNear(this.opener);
|
|
@@ -56,4 +52,5 @@ function pickerNear(el) {
|
|
|
56
52
|
return null;
|
|
57
53
|
}
|
|
58
54
|
customElements.define("lb-insert-dialog", LbInsertDialog);
|
|
55
|
+
export {};
|
|
59
56
|
//# sourceMappingURL=lb-insert-dialog.browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lb-insert-dialog.browser.js","sourceRoot":"","sources":["../widgets/lb-insert-dialog.browser.ts"],"names":[],"mappings":"AAAA,2BAA2B;
|
|
1
|
+
{"version":3,"file":"lb-insert-dialog.browser.js","sourceRoot":"","sources":["../widgets/lb-insert-dialog.browser.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAI3B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,cAAe,SAAQ,WAAW;IACtC,8CAA8C;IACtC,MAAM,GAAmB,IAAI,CAAC;IAEtC;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,gBAAgB,CACnB,OAAO,EACP,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EACzC,IAAI,CACL,CAAC;QACF,IAAI,CAAC,gBAAgB,CACnB,SAAS,EACT,CAAC,CAAC,EAAE,EAAE;YACJ,IAAI,CAAC,MAAM,GAAI,CAAyC,CAAC,MAAM,IAAI,IAAI,CAAC;QAC1E,CAAC,EACD,IAAI,CACL,CAAC;IACJ,CAAC;IAED,aAAa,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAkB;QACrD,IAAI,KAAK;YAAE,OAAO;QAClB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;QAC1D,MAAM,OAAO,GAAG,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACvC,IAAI,OAAO;YAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACrD,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC;IACxC,CAAC;IAEO,MAAM,CAAC,GAAW;QACxB,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM;YAAE,OAAO;QACpB,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC;QACnB,MAAM,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC/D,CAAC;CACF;AAED,qEAAqE;AACrE,SAAS,UAAU,CACjB,EAAkB;IAElB,KAAK,IAAI,IAAI,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACnE,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;QAC/C,IAAI,KAAK;YAAE,OAAO,KAAwC,CAAC;IAC7D,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,cAAc,CAAC,MAAM,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["/// <reference lib=\"dom\" />\n\nimport type { HubLifecycle, HubRequestDone } from \"@loadbare/app/types\";\n\n/**\n * Two rules. Closing the dialog resets the form, and the row the form creates\n * is chosen in the picker the dialog was opened from.\n *\n * Save closes the dialog when the hub says the insert succeeded, so there\n * is a row to show for it, and a refusal leaves the entry open to correct. Cancel and Escape close it, and throw away what was typed.\n *\n * The picker is the nearest `lb-options` around the button that opened the\n * dialog, which a `command` event names as its `source`. The new row's key is\n * in the patch the insert answers with, and by the time the hub calls\n * `lbRequestDone` that row is among the picker's options. Choosing it fires\n * `change`, so a picker that saves its own column saves it, and one in a ghost\n * row or a new record holds it until Save.\n *\n * `close` and `command` do not bubble, so they are heard in capture.\n */\nclass LbInsertDialog extends HTMLElement implements HubLifecycle {\n /** The button that last opened the dialog. */\n private opener: Element | null = null;\n\n constructor() {\n super();\n this.addEventListener(\n \"close\",\n () => this.querySelector(\"form\")?.reset(),\n true,\n );\n this.addEventListener(\n \"command\",\n (e) => {\n this.opener = (e as Event & { source?: Element | null }).source ?? null;\n },\n true,\n );\n }\n\n lbRequestDone({ request, items, error }: HubRequestDone): void {\n if (error) return;\n const item = items.find((i) => i.query === request.query);\n const created = item?.patch?.rows?.[0];\n if (created) this.choose(String(created[item!.key]));\n this.querySelector(\"dialog\")?.close();\n }\n\n private choose(key: string): void {\n const picker = pickerNear(this.opener);\n if (!picker) return;\n picker.value = key;\n picker.dispatchEvent(new Event(\"change\", { bubbles: true }));\n }\n}\n\n/** The nearest `lb-options` around an element, searching outward. */\nfunction pickerNear(\n el: Element | null,\n): (HTMLElement & { value: string }) | null {\n for (let node = el?.parentElement; node; node = node.parentElement) {\n const found = node.querySelector(\"lb-options\");\n if (found) return found as HTMLElement & { value: string };\n }\n return null;\n}\n\ncustomElements.define(\"lb-insert-dialog\", LbInsertDialog);\n"]}
|
package/dist/lb-master.html
CHANGED
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
belongs to.
|
|
10
10
|
|
|
11
11
|
The standard bar is [New] [Copy] [Delete] [Save new] [Cancel].
|
|
12
|
-
- New is
|
|
13
|
-
|
|
12
|
+
- New is a request the page declares, `new`. Which row shows is a query
|
|
13
|
+
parm, and a button writes none, so the page's handler returns url()
|
|
14
|
+
emptying the parm, and the row query answers a row not yet entered.
|
|
15
|
+
It pushes a history entry, so Back returns to the row on record.
|
|
14
16
|
- Copy is a request the page declares, `copy`. It goes to the server by
|
|
15
17
|
design rather than filling the form for Save new: a copy is a new row in
|
|
16
18
|
the set, and only the server can bring its children along. What comes
|
|
@@ -25,6 +27,9 @@
|
|
|
25
27
|
<div class="lb-master-row" lb-query="{{row}}">
|
|
26
28
|
<lb-form exp-id="{{form-id|master-form}}" lb-exp-slot></lb-form>
|
|
27
29
|
<div class="lb-master-buttons">
|
|
30
|
+
<button type="button" lb-request="new" lb-url-push data-mode="on-record">
|
|
31
|
+
New
|
|
32
|
+
</button>
|
|
28
33
|
<button type="button" lb-request="copy" data-mode="on-record">Copy</button>
|
|
29
34
|
<lb-confirm
|
|
30
35
|
exp-label="Delete"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HubLifecycle } from "@loadbare/app/types";
|
|
2
2
|
import { WrappedControl } from "./control.js";
|
|
3
3
|
/**
|
|
4
4
|
* A `<select>` whose choices are the rows of the query it names.
|
|
@@ -26,7 +26,7 @@ import { WrappedControl } from "./control.js";
|
|
|
26
26
|
* Exported because `lb-picker` is this widget with its row template supplied
|
|
27
27
|
* by the definition instead of by the page.
|
|
28
28
|
*/
|
|
29
|
-
export declare class LbOptions extends WrappedControl implements
|
|
29
|
+
export declare class LbOptions extends WrappedControl implements HubLifecycle {
|
|
30
30
|
protected inner: string;
|
|
31
31
|
/**
|
|
32
32
|
* The value last set or chosen, which the options may not include yet.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lb-options.browser.d.ts","sourceRoot":"","sources":["../widgets/lb-options.browser.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"lb-options.browser.d.ts","sourceRoot":"","sources":["../widgets/lb-options.browser.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,qBAAa,SAAU,SAAQ,cAAe,YAAW,YAAY;IACnE,SAAS,CAAC,KAAK,SAAY;IAE3B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAuB;IAErC,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAGtB;IAED,iBAAiB,IAAI,IAAI;IAKzB,SAAS,CAAC,OAAO,IAAI,IAAI;IAKzB,0EAA0E;IAC1E,YAAY,IAAI,IAAI;CAcrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lb-options.browser.js","sourceRoot":"","sources":["../widgets/lb-options.browser.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,QAAQ,GACT,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,MAAM,OAAO,SAAU,SAAQ,cAAc;IACjC,KAAK,GAAG,QAAQ,CAAC;IAE3B;;;OAGG;IACK,MAAM,GAAkB,IAAI,CAAC;IAErC,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC;IACpC,CAAC;IAED,IAAI,KAAK,CAAC,KAAa;QACrB,IAAI,CAAC,MAAM,GAAG,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3E,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,iBAAiB;QACf,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,KAAK,CAAC,iBAAiB,EAAE,CAAC;IAC5B,CAAC;IAES,OAAO;QACf,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,KAAK,IAAI,IAAI,CAAC;QAC1C,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;IAED,0EAA0E;IAC1E,YAAY;QACV,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,gBAAgB,CAAC,SAAS,QAAQ,EAAE,CAAC,EAAE,CAAC;YAChE,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,YAAY,CAAC,cAAc,CAAE,CAAC,CAAC;QACrE,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,gBAAgB,CACvC,WAAW,UAAU,EAAE,CACxB,EAAE,CAAC;YACF,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;QAC3D,CAAC;QACD,iEAAiE;QACjE,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,MAAM,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI;YAAE,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QAC/D,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC","sourcesContent":["/// <reference lib=\"dom\" />\n\nimport {\n ATTR_GROUP_VALUE,\n ATTR_KEY_VALUE,\n LIVE_GROUP,\n LIVE_ROW,\n} from \"@loadbare/app/constants\";\nimport type {
|
|
1
|
+
{"version":3,"file":"lb-options.browser.js","sourceRoot":"","sources":["../widgets/lb-options.browser.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,QAAQ,GACT,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,MAAM,OAAO,SAAU,SAAQ,cAAc;IACjC,KAAK,GAAG,QAAQ,CAAC;IAE3B;;;OAGG;IACK,MAAM,GAAkB,IAAI,CAAC;IAErC,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC;IACpC,CAAC;IAED,IAAI,KAAK,CAAC,KAAa;QACrB,IAAI,CAAC,MAAM,GAAG,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3E,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,iBAAiB;QACf,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,KAAK,CAAC,iBAAiB,EAAE,CAAC;IAC5B,CAAC;IAES,OAAO;QACf,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,KAAK,IAAI,IAAI,CAAC;QAC1C,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;IAED,0EAA0E;IAC1E,YAAY;QACV,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,gBAAgB,CAAC,SAAS,QAAQ,EAAE,CAAC,EAAE,CAAC;YAChE,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,YAAY,CAAC,cAAc,CAAE,CAAC,CAAC;QACrE,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,gBAAgB,CACvC,WAAW,UAAU,EAAE,CACxB,EAAE,CAAC;YACF,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;QAC3D,CAAC;QACD,iEAAiE;QACjE,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,MAAM,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI;YAAE,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QAC/D,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC","sourcesContent":["/// <reference lib=\"dom\" />\n\nimport {\n ATTR_GROUP_VALUE,\n ATTR_KEY_VALUE,\n LIVE_GROUP,\n LIVE_ROW,\n} from \"@loadbare/app/constants\";\nimport type { HubLifecycle } from \"@loadbare/app/types\";\nimport { WrappedControl } from \"./control.js\";\n\n/**\n * A `<select>` whose choices are the rows of the query it names.\n *\n * The hub places the options by the query's order, and a group template\n * holding an `<optgroup>` puts them in groups. What landing does not give an\n * `<optgroup>` is its label, so the widget sets it from the `lb-group-value`\n * the hub stamps on it.\n *\n * The identity of a row is the value of its option, so the `lb-key-value` the\n * hub stamps on each option is copied to its `value`. The key column is the\n * one the server declared for the query; the page never names it.\n *\n * It is two things at once, and the hub keeps them apart: its own `lb-query`\n * names the rows it offers, and its `lb-column` is a column of the row around\n * it, which is what it holds and what it sends. As a control it is\n * form-associated, with a `value` and a `change` of its own, so the hub lands\n * that column on `value` and commits `lb-request` on `change`.\n *\n * The value is held here as well as on the select. A `<select>` does not hold\n * a value it has no option for: it selects nothing and forgets it. The value\n * and the choices are two answers that land in either order, so the held\n * value is put on the select again whenever rows land.\n *\n * Exported because `lb-picker` is this widget with its row template supplied\n * by the definition instead of by the page.\n */\n\nexport class LbOptions extends WrappedControl implements HubLifecycle {\n protected inner = \"select\";\n\n /**\n * The value last set or chosen, which the options may not include yet.\n * Null when nothing chose one, so the select's own default stands.\n */\n private chosen: string | null = null;\n\n get value(): string {\n return this.chosen ?? super.value;\n }\n\n set value(value: string) {\n this.chosen = value === null || value === undefined ? null : String(value);\n super.value = value;\n }\n\n formResetCallback(): void {\n this.chosen = null;\n super.formResetCallback();\n }\n\n protected changed(): void {\n this.chosen = this.control?.value ?? null;\n super.changed();\n }\n\n /** Everything derived from the rows, once the whole answer has landed. */\n lbRowsLanded(): void {\n for (const option of this.querySelectorAll(`option${LIVE_ROW}`)) {\n option.setAttribute(\"value\", option.getAttribute(ATTR_KEY_VALUE)!);\n }\n for (const group of this.querySelectorAll<HTMLOptGroupElement>(\n `optgroup${LIVE_GROUP}`,\n )) {\n group.label = group.getAttribute(ATTR_GROUP_VALUE) ?? \"\";\n }\n // After the values above, since the select matches against them.\n const select = this.querySelector(\"select\");\n if (select && this.chosen !== null) select.value = this.chosen;\n this.formValue();\n }\n}\n\ncustomElements.define(\"lb-options\", LbOptions);\n"]}
|
package/dist/lb-table.browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="dom" />
|
|
2
|
-
import { ATTR_COLUMN, ATTR_ROW_REQUESTED,
|
|
2
|
+
import { ATTR_COLUMN, ATTR_ROW_REQUESTED, REQUEST_ROW_INSERT, REQUESTED_CREATED, REQUESTED_MOVED, } from "@loadbare/app/constants";
|
|
3
3
|
/**
|
|
4
4
|
* A table that owns its own scaffolding.
|
|
5
5
|
*
|
|
@@ -36,27 +36,9 @@ const GHOST = "data-ghost";
|
|
|
36
36
|
/** Ghost row forms need ids for the `form` attribute; any unique one will do. */
|
|
37
37
|
let ghostForms = 0;
|
|
38
38
|
class LbTable extends HTMLElement {
|
|
39
|
-
|
|
40
|
-
* A ghost row is for entering the next row, so once one is saved the
|
|
41
|
-
* cursor goes back to the start of it. `lb-request-done` comes after the
|
|
42
|
-
* response items have landed, so nothing the hub places afterwards takes
|
|
43
|
-
* the focus away again. A refused insert leaves the cursor where the user
|
|
44
|
-
* left it.
|
|
45
|
-
*/
|
|
46
|
-
constructor() {
|
|
47
|
-
super();
|
|
48
|
-
this.addEventListener(LB_DONE_EVENT_NAME, (e) => {
|
|
49
|
-
const { request, error } = e.detail;
|
|
50
|
-
if (error || request.name !== REQUEST_ROW_INSERT)
|
|
51
|
-
return;
|
|
52
|
-
const row = e.target.closest(`[${GHOST}]`);
|
|
53
|
-
if (row)
|
|
54
|
-
firstControl(row)?.focus();
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
connectedCallback() {
|
|
39
|
+
lbAttached() {
|
|
58
40
|
const ghost = this.querySelector(`tbody[${GHOST}]`);
|
|
59
|
-
if (!ghost?.firstElementChild
|
|
41
|
+
if (!ghost?.firstElementChild)
|
|
60
42
|
return;
|
|
61
43
|
const form = document.createElement("form");
|
|
62
44
|
form.id = `ghost-row-${++ghostForms}`;
|
|
@@ -71,9 +53,19 @@ class LbTable extends HTMLElement {
|
|
|
71
53
|
this.querySelector(`[${ATTR_ROW_REQUESTED}="${REQUESTED_CREATED}"], ` +
|
|
72
54
|
`[${ATTR_ROW_REQUESTED}="${REQUESTED_MOVED}"]`)?.scrollIntoView({ block: "nearest" });
|
|
73
55
|
}
|
|
74
|
-
/**
|
|
75
|
-
|
|
76
|
-
|
|
56
|
+
/**
|
|
57
|
+
* A ghost row is for entering the next row, so once one is saved the
|
|
58
|
+
* cursor goes back to the start of it. The hub calls this after the
|
|
59
|
+
* response items have landed, so nothing it places afterwards takes the
|
|
60
|
+
* focus away again. A refused insert leaves the cursor where the user left
|
|
61
|
+
* it.
|
|
62
|
+
*/
|
|
63
|
+
lbRequestDone({ request, error }, origin) {
|
|
64
|
+
if (error || request.name !== REQUEST_ROW_INSERT)
|
|
65
|
+
return;
|
|
66
|
+
const row = origin.closest(`[${GHOST}]`);
|
|
67
|
+
if (row)
|
|
68
|
+
firstControl(row)?.focus();
|
|
77
69
|
}
|
|
78
70
|
}
|
|
79
71
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lb-table.browser.js","sourceRoot":"","sources":["../widgets/lb-table.browser.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"lb-table.browser.js","sourceRoot":"","sources":["../widgets/lb-table.browser.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,GAChB,MAAM,yBAAyB,CAAC;AAGjC;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,KAAK,GAAG,YAAY,CAAC;AAE3B,iFAAiF;AACjF,IAAI,UAAU,GAAG,CAAC,CAAC;AAEnB,MAAM,OAAQ,SAAQ,WAAW;IAC/B,UAAU;QACR,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,SAAS,KAAK,GAAG,CAAC,CAAC;QACpD,IAAI,CAAC,KAAK,EAAE,iBAAiB;YAAE,OAAO;QAEtC,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC,EAAE,GAAG,aAAa,EAAE,UAAU,EAAE,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAClB,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,gBAAgB,CAAC,IAAI,WAAW,WAAW,CAAC,EAAE,CAAC;YACpE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,uEAAuE;IACvE,YAAY;QACV,IAAI,CAAC,aAAa,CAChB,IAAI,kBAAkB,KAAK,iBAAiB,MAAM;YAChD,IAAI,kBAAkB,KAAK,eAAe,IAAI,CACjD,EAAE,cAAc,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,OAAO,EAAE,KAAK,EAAkB,EAAE,MAAe;QAC/D,IAAI,KAAK,IAAI,OAAO,CAAC,IAAI,KAAK,kBAAkB;YAAE,OAAO;QACzD,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC;QACzC,IAAI,GAAG;YAAE,YAAY,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;IACtC,CAAC;CACF;AAED;;;GAGG;AACH,SAAS,YAAY,CAAC,GAAY;IAChC,OAAO;QACL,GAAG,GAAG,CAAC,gBAAgB,CACrB,8CAA8C,CAC/C;KACF,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,eAAe,EAAE,EAAE,KAAK,KAAK,CAAC,CAAC;AAC/E,CAAC;AAED,cAAc,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC","sourcesContent":["/// <reference lib=\"dom\" />\n\nimport {\n ATTR_COLUMN,\n ATTR_ROW_REQUESTED,\n REQUEST_ROW_INSERT,\n REQUESTED_CREATED,\n REQUESTED_MOVED,\n} from \"@loadbare/app/constants\";\nimport type { HubLifecycle, HubRequestDone } from \"@loadbare/app/types\";\n\n/**\n * A table that owns its own scaffolding.\n *\n * A plain `<table lb-query>` with a row template inside it needs no widget at\n * all. This one supplies the table, and the developer writes what only the\n * page knows: the heading row and the row template. That division is forced\n * rather than chosen — a `<thead>` written inside a custom element is not\n * inside a table, so the parser drops the tag and keeps the text. A\n * `<template>` survives anywhere, so the heading row arrives wrapped and\n * expansion unwraps it into the `lb-exp-template` destination beside the slot.\n *\n * Placement and groups are the hub's, by the query's order and the page's\n * group templates. What this widget adds at run time is the ghost row, and\n * scrolling to the row the page's own request created or moved.\n *\n * The `foot` destination needs no code here. A `<tfoot>` is a place on the\n * page, not a row the hub delivers, so what lands in it is an aggregate or a\n * `row` query of its own, named on its `<tr>`.\n */\n\n/**\n * The ghost row's `<tbody>`, a blank row for entering a new one, between the\n * rows and the footer. The page writes it as the `ghost` template, so it\n * ships in the document like the heading and the footer, and the hub lands\n * on whatever in it names a query. It is not a live row: the hub never\n * reconciles it and never counts it.\n *\n * A `<form>` cannot wrap a `<tr>`, so the widget makes one outside the table\n * and joins the row's controls and buttons to it with the HTML `form`\n * attribute. Sending is the page's: a button in the row carrying\n * `lb-row-insert` submits that form, and the hub gathers what the form owns.\n * The hub resets the form once the insert succeeds.\n */\nconst GHOST = \"data-ghost\";\n\n/** Ghost row forms need ids for the `form` attribute; any unique one will do. */\nlet ghostForms = 0;\n\nclass LbTable extends HTMLElement implements HubLifecycle {\n lbAttached(): void {\n const ghost = this.querySelector(`tbody[${GHOST}]`);\n if (!ghost?.firstElementChild) return;\n\n const form = document.createElement(\"form\");\n form.id = `ghost-row-${++ghostForms}`;\n form.hidden = true;\n this.append(form);\n for (const el of ghost.querySelectorAll(`[${ATTR_COLUMN}], button`)) {\n el.setAttribute(\"form\", form.id);\n }\n }\n\n /** The row this page's request created or moved, brought into view. */\n lbRowsLanded(): void {\n this.querySelector(\n `[${ATTR_ROW_REQUESTED}=\"${REQUESTED_CREATED}\"], ` +\n `[${ATTR_ROW_REQUESTED}=\"${REQUESTED_MOVED}\"]`,\n )?.scrollIntoView({ block: \"nearest\" });\n }\n\n /**\n * A ghost row is for entering the next row, so once one is saved the\n * cursor goes back to the start of it. The hub calls this after the\n * response items have landed, so nothing it places afterwards takes the\n * focus away again. A refused insert leaves the cursor where the user left\n * it.\n */\n lbRequestDone({ request, error }: HubRequestDone, origin: Element): void {\n if (error || request.name !== REQUEST_ROW_INSERT) return;\n const row = origin.closest(`[${GHOST}]`);\n if (row) firstControl(row)?.focus();\n }\n}\n\n/**\n * The first control in a row the user can type into or choose from. A\n * control a widget wraps is found inside it, since the wrapper takes no focus.\n */\nfunction firstControl(row: Element): HTMLElement | undefined {\n return [\n ...row.querySelectorAll<HTMLElement>(\n 'input:not([type=\"hidden\"]), select, textarea',\n ),\n ].find((el) => !el.matches(\":disabled\") && el.checkVisibility?.() !== false);\n}\n\ncustomElements.define(\"lb-table\", LbTable);\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# `lb-checkbox`
|
|
2
|
+
|
|
3
|
+
> Status: a barebones starter. Iterative use will drive improvements.
|
|
4
|
+
|
|
5
|
+
A checkbox and its label as one element, for an application to style. A
|
|
6
|
+
definition only, with no script: the hub treats a native checkbox as a
|
|
7
|
+
control, so the widget adds nothing but the markup.
|
|
8
|
+
|
|
9
|
+
Requires `exp-column` and `exp-label`.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<div lb-query="people">
|
|
13
|
+
<template>
|
|
14
|
+
<div>
|
|
15
|
+
<lb-checkbox exp-column="active" exp-label="Active" exp-request="lb-row-update"></lb-checkbox>
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
18
|
+
</div>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Expansion Attributes
|
|
22
|
+
|
|
23
|
+
| Parameter | Fills |
|
|
24
|
+
| ------------- | ----------------------------------------------- |
|
|
25
|
+
| `exp-column` | the checkbox's `lb-column` |
|
|
26
|
+
| `exp-label` | the label's text |
|
|
27
|
+
| `exp-request` | the checkbox's `lb-request`, none when absent |
|
|
28
|
+
|
|
29
|
+
The column and request go on the checkbox inside, since it is the control,
|
|
30
|
+
so they are expansion attributes here rather than `lb-column` and
|
|
31
|
+
`lb-request` on the tag.
|
|
32
|
+
|
|
33
|
+
## Why it is not like `lb-input`
|
|
34
|
+
|
|
35
|
+
`lb-input` has a script that makes the tag itself the control, so the page
|
|
36
|
+
writes `lb-column` on the tag. `lb-checkbox` cannot do the same. A value
|
|
37
|
+
that lands before a widget's script has loaded reaches it only as the
|
|
38
|
+
`lb-column-value` stamp, a string, and a checkbox's state is a boolean. A
|
|
39
|
+
script `lb-checkbox` would read the stamp `"false"` as checked, since no
|
|
40
|
+
string is read. The native checkbox has no such gap: the hub sets `checked`
|
|
41
|
+
on it directly.
|
|
42
|
+
|
|
43
|
+
`lb-input` could equally be markup alone; its script is a convention, kept
|
|
44
|
+
for now.
|
|
45
|
+
|
|
46
|
+
## The control
|
|
47
|
+
|
|
48
|
+
The checkbox is checked when its column is anything but `false` or null, and
|
|
49
|
+
sends `"true"` or `"false"`. See
|
|
50
|
+
[checkboxes](../../app/docs/reference/data-binding.md#checkboxes).
|
|
51
|
+
|
|
52
|
+
## Styling
|
|
53
|
+
|
|
54
|
+
The definition is a `<label>` holding the `<input type="checkbox">` and a
|
|
55
|
+
`<span>` with the text:
|
|
56
|
+
|
|
57
|
+
```css
|
|
58
|
+
lb-checkbox label {
|
|
59
|
+
display: inline-flex;
|
|
60
|
+
gap: 0.5em;
|
|
61
|
+
align-items: center;
|
|
62
|
+
}
|
|
63
|
+
```
|
package/docs/lb-confirm.md
CHANGED
|
@@ -37,8 +37,7 @@ sits in, so the request carries that row's query and key, and the message
|
|
|
37
37
|
can show the row's columns with `lb-column`.
|
|
38
38
|
|
|
39
39
|
Cancel comes first and takes focus, so Enter on a dialog opened by accident
|
|
40
|
-
sends nothing. The widget closes the dialog when
|
|
41
|
-
request succeeded. A refused request leaves it open, with the hub's
|
|
40
|
+
sends nothing. The widget closes the dialog when the request succeeds. A refused request leaves it open, with the hub's
|
|
42
41
|
`lb-request-error` on the confirm button.
|
|
43
42
|
|
|
44
43
|
The dialog is found by its place in the tag, not by id, so the tag works in a
|
package/docs/lb-form.md
CHANGED
|
@@ -25,9 +25,11 @@ Requires `exp-id`.
|
|
|
25
25
|
|
|
26
26
|
A row with a key is on record, and each control saves its own column on
|
|
27
27
|
`change` with `lb-request="lb-row-update"`. A row whose key is empty is a new
|
|
28
|
-
one not yet entered:
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
one not yet entered: the hub sends no update for it, so the controls only
|
|
29
|
+
hold what a submit will gather. See
|
|
30
|
+
[a row not yet entered](../../app/docs/reference/data-binding.md#a-row-not-yet-entered).
|
|
31
|
+
|
|
32
|
+
A definition only, with no script of its own.
|
|
31
33
|
|
|
32
34
|
A button that acts on the row as a whole, such as one adding it to the set,
|
|
33
35
|
belongs to whatever holds the set, and reaches the form by `form="<id>"`.
|
package/docs/lb-input.md
CHANGED
|
@@ -45,10 +45,6 @@ sets the value of the `<input>` inside it, and it fires `change` on itself when
|
|
|
45
45
|
that `<input>` fires `change`. A form reset returns the `<input>` to its
|
|
46
46
|
default.
|
|
47
47
|
|
|
48
|
-
A value that lands on a live row before the row's elements upgrade reaches the
|
|
49
|
-
widget as `lb-column-value`, and the widget takes it up when it first
|
|
50
|
-
connects.
|
|
51
|
-
|
|
52
48
|
## Inside a form
|
|
53
49
|
|
|
54
50
|
An `lb-input` inside an `lb-row-insert` or `lb-row-update` form carries no
|
package/docs/lb-insert-dialog.md
CHANGED
|
@@ -39,8 +39,7 @@ the control it serves.
|
|
|
39
39
|
|
|
40
40
|
## What it does
|
|
41
41
|
|
|
42
|
-
Save is the form's `lb-row-insert`. When `lb-
|
|
43
|
-
succeeded, the widget chooses the new row in the nearest `lb-options` around
|
|
42
|
+
Save is the form's `lb-row-insert`. When it succeeds, the widget chooses the new row in the nearest `lb-options` around
|
|
44
43
|
the button that opened the dialog, fires `change` on it, and closes the
|
|
45
44
|
dialog. The new key comes from the patch the insert answers with, so the
|
|
46
45
|
handler answers with the row it created. A picker that saves its own column
|
package/docs/lb-master.md
CHANGED
|
@@ -39,15 +39,27 @@ Requires `exp-row`.
|
|
|
39
39
|
|
|
40
40
|
| Button | Shows | Does |
|
|
41
41
|
| -------- | ----------------- | --------------------------------------------- |
|
|
42
|
+
| New | A row on record | Sends `new`, a request the page declares, and pushes a history entry |
|
|
42
43
|
| Copy | A row on record | Sends `copy`, a request the page declares |
|
|
43
44
|
| Delete | A row on record | Asks, then sends `lb-row-delete` |
|
|
44
45
|
| Save new | A new row | Submits the form as `lb-row-insert`, and pushes a history entry |
|
|
45
46
|
| Cancel | A new row | Resets the form |
|
|
46
47
|
|
|
47
48
|
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
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
only in its mode. A new row is one whose key is empty, a
|
|
50
|
+
[row not yet entered](../../app/docs/reference/data-binding.md#a-row-not-yet-entered).
|
|
51
|
+
|
|
52
|
+
Which row shows is a query parm, and only the page knows its name, so New is
|
|
53
|
+
a request the page declares. Its handler empties the parm, and the row
|
|
54
|
+
query answers a row with an empty key:
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
handlers: {
|
|
58
|
+
new: { run: async () => url({ acct: "" }), refresh: [] },
|
|
59
|
+
},
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Choosing the picker's blank does the same.
|
|
51
63
|
|
|
52
64
|
Copy goes to the server rather than filling the form, because a copy is a new
|
|
53
65
|
row in the set, and only the server can bring its children along.
|
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, confirm, form, insert-dialog, master",
|
|
4
|
-
"version": "0.
|
|
3
|
+
"description": "The basic widget set for @loadbare/app: input, select, options, picker, table, unknown-page, confirm, form, insert-dialog, master, checkbox",
|
|
4
|
+
"version": "0.8.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.15.0 <1.0.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@loadbare/app": ">=0.
|
|
55
|
+
"@loadbare/app": ">=0.15.0 <1.0.0",
|
|
56
56
|
"@types/jsdom": "^21.1.7",
|
|
57
57
|
"@types/node": "^22.0.0",
|
|
58
58
|
"jsdom": "^25.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lb-form.browser.d.ts","sourceRoot":"","sources":["../widgets/lb-form.browser.ts"],"names":[],"mappings":""}
|
package/dist/lb-form.browser.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/// <reference lib="dom" />
|
|
2
|
-
import { LB_EVENT_NAME, REQUEST_ROW_UPDATE } from "@loadbare/app/constants";
|
|
3
|
-
/**
|
|
4
|
-
* A form over one row, in one of two modes that the row decides.
|
|
5
|
-
*
|
|
6
|
-
* A row with a key is on record, and each control saves its own column on
|
|
7
|
-
* `change`: the page writes `lb-request="lb-row-update"` on every control.
|
|
8
|
-
* A row with an empty key is a new one not yet entered, and a change saves
|
|
9
|
-
* nothing, because there is nothing to update; the controls only hold what
|
|
10
|
-
* will be gathered when something submits the form.
|
|
11
|
-
*
|
|
12
|
-
* So the form stops an update whose key came back empty. The hub completes a
|
|
13
|
-
* request on the way down, before any ancestor sees it, so the key is already
|
|
14
|
-
* in `detail` when the event bubbles through here.
|
|
15
|
-
*/
|
|
16
|
-
class LbForm extends HTMLElement {
|
|
17
|
-
constructor() {
|
|
18
|
-
super();
|
|
19
|
-
this.addEventListener(LB_EVENT_NAME, (e) => {
|
|
20
|
-
const request = e.detail;
|
|
21
|
-
if (request.name === REQUEST_ROW_UPDATE && request.key === "") {
|
|
22
|
-
e.stopPropagation();
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
customElements.define("lb-form", LbForm);
|
|
28
|
-
//# sourceMappingURL=lb-form.browser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lb-form.browser.js","sourceRoot":"","sources":["../widgets/lb-form.browser.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG5E;;;;;;;;;;;;GAYG;AACH,MAAM,MAAO,SAAQ,WAAW;IAC9B;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE;YACzC,MAAM,OAAO,GAAI,CAA6B,CAAC,MAAM,CAAC;YACtD,IAAI,OAAO,CAAC,IAAI,KAAK,kBAAkB,IAAI,OAAO,CAAC,GAAG,KAAK,EAAE,EAAE,CAAC;gBAC9D,CAAC,CAAC,eAAe,EAAE,CAAC;YACtB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC","sourcesContent":["/// <reference lib=\"dom\" />\n\nimport { LB_EVENT_NAME, REQUEST_ROW_UPDATE } from \"@loadbare/app/constants\";\nimport type { HubRequest } from \"@loadbare/app/types\";\n\n/**\n * A form over one row, in one of two modes that the row decides.\n *\n * A row with a key is on record, and each control saves its own column on\n * `change`: the page writes `lb-request=\"lb-row-update\"` on every control.\n * A row with an empty key is a new one not yet entered, and a change saves\n * nothing, because there is nothing to update; the controls only hold what\n * will be gathered when something submits the form.\n *\n * So the form stops an update whose key came back empty. The hub completes a\n * request on the way down, before any ancestor sees it, so the key is already\n * in `detail` when the event bubbles through here.\n */\nclass LbForm extends HTMLElement {\n constructor() {\n super();\n this.addEventListener(LB_EVENT_NAME, (e) => {\n const request = (e as CustomEvent<HubRequest>).detail;\n if (request.name === REQUEST_ROW_UPDATE && request.key === \"\") {\n e.stopPropagation();\n }\n });\n }\n}\n\ncustomElements.define(\"lb-form\", LbForm);\n"]}
|