@syware/jlib 0.11.0 → 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.
@@ -71,6 +71,7 @@ var JlCheckbox = class extends JlFormControl {
71
71
  /* @__PURE__ */ jsx("input", {
72
72
  type: "checkbox",
73
73
  class: "native",
74
+ id: "field",
74
75
  "aria-describedby": "description"
75
76
  }),
76
77
  /* @__PURE__ */ jsx(JlIcon, {
@@ -104,7 +104,10 @@ var JlInput = class extends JlFormControl {
104
104
  hidden: true
105
105
  }),
106
106
  /* @__PURE__ */ jsx("slot", { name: "start" }),
107
- /* @__PURE__ */ jsx("input", { class: "native" }),
107
+ /* @__PURE__ */ jsx("input", {
108
+ class: "native",
109
+ id: "field"
110
+ }),
108
111
  /* @__PURE__ */ jsx("button", {
109
112
  class: "action clear",
110
113
  type: "button",
@@ -1,3 +1,3 @@
1
1
  // src/atoms/jl-link.css?inline
2
- var jl_link_default = ":host{--color:var(--jl-accent);--hover:var(--jl-accent-strong);--underline:color-mix(in srgb, var(--jl-accent) 40%, transparent);display:inline}:host([variant=muted]){--color:var(--jl-muted);--hover:var(--jl-text);--underline:transparent}:host([variant=quiet]){--underline:transparent}a{color:var(--color);text-decoration:underline;-webkit-text-decoration-color:var(--underline);text-decoration-color:var(--underline);text-underline-offset:.2em;cursor:pointer;transition:color var(--jl-fast) var(--jl-ease), text-decoration-color var(--jl-fast) var(--jl-ease);border-radius:3px;font-weight:600;text-decoration-thickness:1px}a:hover{color:var(--hover);text-decoration-color:currentColor}a:not([href]){cursor:default}jl-icon{vertical-align:-.1em;margin-left:.2em}";
2
+ var jl_link_default = ":host{--color:var(--jl-accent);--hover:var(--jl-accent-strong);--underline:color-mix(in srgb, var(--jl-accent) 40%, transparent);display:inline}:host([variant=muted]){--color:var(--jl-muted);--hover:var(--jl-text);--underline:transparent}:host([variant=quiet]){--underline:transparent}a{color:var(--color);text-decoration:underline;-webkit-text-decoration-color:var(--underline);text-decoration-color:var(--underline);text-underline-offset:.2em;cursor:pointer;transition:color var(--jl-fast) var(--jl-ease), text-decoration-color var(--jl-fast) var(--jl-ease);border-radius:3px;font-weight:600;text-decoration-thickness:1px}a:hover{color:var(--hover);text-decoration-color:currentColor}a:not([href]){cursor:default}:host([interactive]) a:not([href]){cursor:pointer}jl-icon{vertical-align:-.1em;margin-left:.2em}";
3
3
  export { jl_link_default as default };
@@ -3,10 +3,14 @@ import type { LinkVariant } from '../types/jl-link.types';
3
3
  export declare const LINK_VARIANTS: readonly LinkVariant[];
4
4
  /**
5
5
  * A link in text or in a list: the browser's own `<a>`, styled. `external` opens it in a new tab, safely, with an
6
- * icon that says so. Its text is the `label` or the slotted content.
6
+ * icon that says so. Its text is the `label` or the slotted content. `interactive` without an `href`, it fires
7
+ * `press` instead: the app follows it itself (a router's `goto`).
7
8
  */
8
9
  export declare class JlLink extends JlElement {
9
10
  static readonly selector = "jl-link";
11
+ readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
12
+ press: undefined;
13
+ }>>;
10
14
  readonly href: Readonly<Readonly<{
11
15
  get(): string;
12
16
  set(setter: string | ((prevState: string) => string)): void;
@@ -29,9 +33,19 @@ export declare class JlLink extends JlElement {
29
33
  get(): LinkVariant;
30
34
  set(setter: ((prevState: LinkVariant) => LinkVariant) | LinkVariant): void;
31
35
  }>>;
36
+ /** Without an `href`, it fires `press` when followed, by a click or Enter, for the app to go there itself. */
37
+ readonly interactive: Readonly<Readonly<{
38
+ get(): boolean;
39
+ set(setter: boolean | ((prevState: boolean) => boolean)): void;
40
+ }>>;
32
41
  private readonly _refs;
33
42
  focus(options?: FocusOptions): void;
34
43
  templateHtml(): Node;
35
44
  templateCss(): string;
45
+ onConnect(): void;
46
+ /** An interactive link without an address fires `press`; one with an address leaves it to the browser. */
47
+ private pressable;
48
+ /** Followed by the app, the link is still a link to the keyboard and to screen readers. */
49
+ private renderInteraction;
36
50
  private renderTarget;
37
51
  }
@@ -18,13 +18,16 @@ var LINK_VARIANTS = [
18
18
  var NEW_TAB = "_blank";
19
19
  var SAFE_REL = "noopener noreferrer";
20
20
  var ICON_SIZE = 13;
21
+ var ENTER = "Enter";
21
22
  /**
22
23
  * A link in text or in a list: the browser's own `<a>`, styled. `external` opens it in a new tab, safely, with an
23
- * icon that says so. Its text is the `label` or the slotted content.
24
+ * icon that says so. Its text is the `label` or the slotted content. `interactive` without an `href`, it fires
25
+ * `press` instead: the app follows it itself (a router's `goto`).
24
26
  */
25
27
  var JlLink = class extends JlElement {
26
28
  static selector = "jl-link";
27
- href = this.useChange("", (value) => setOrRemove(this._refs.anchor, "href", value), { attribute: "href" });
29
+ events = this.useEvents();
30
+ href = this.useChange("", () => this.renderInteraction(), { attribute: "href" });
28
31
  label = this.useChange("", (value) => {
29
32
  this._refs.label.textContent = value;
30
33
  this._refs.label.hidden = value === "";
@@ -37,6 +40,11 @@ var JlLink = class extends JlElement {
37
40
  attribute: "variant",
38
41
  parse: oneOf(LINK_VARIANTS, "default")
39
42
  });
43
+ /** Without an `href`, it fires `press` when followed, by a click or Enter, for the app to go there itself. */
44
+ interactive = this.useChange(false, (value) => {
45
+ this.reflect("interactive", value);
46
+ this.renderInteraction();
47
+ }, { attribute: "interactive" });
40
48
  _refs = this.useRefs((ref) => ({
41
49
  anchor: ref("a"),
42
50
  icon: ref(JlIcon),
@@ -71,6 +79,30 @@ var JlLink = class extends JlElement {
71
79
  templateCss() {
72
80
  return css`${BASE_STYLES}${jl_link_default}`;
73
81
  }
82
+ onConnect() {
83
+ const anchor = this._refs.anchor;
84
+ this.on(anchor, "click", () => {
85
+ if (this.pressable()) this.events.emit("press");
86
+ });
87
+ this.on(anchor, "keydown", (event) => {
88
+ if (this.pressable() && event.key === ENTER) {
89
+ event.preventDefault();
90
+ this.events.emit("press");
91
+ }
92
+ });
93
+ }
94
+ /** An interactive link without an address fires `press`; one with an address leaves it to the browser. */
95
+ pressable() {
96
+ return this.interactive.get() && this.href.get() === "";
97
+ }
98
+ /** Followed by the app, the link is still a link to the keyboard and to screen readers. */
99
+ renderInteraction() {
100
+ const anchor = this._refs.anchor;
101
+ setOrRemove(anchor, "href", this.href.get());
102
+ const pressable = this.pressable();
103
+ setOrRemove(anchor, "role", pressable ? "link" : "");
104
+ setOrRemove(anchor, "tabindex", pressable ? "0" : "");
105
+ }
74
106
  renderTarget() {
75
107
  const anchor = this._refs.anchor;
76
108
  const external = this.external.get();
@@ -50,6 +50,7 @@ export declare class JlSelect<Value extends string = string> extends JlFormContr
50
50
  set(setter: boolean | ((prevState: boolean) => boolean)): void;
51
51
  }>>;
52
52
  private readonly _form;
53
+ private _kept;
53
54
  private readonly _refs;
54
55
  focus(options?: FocusOptions): void;
55
56
  templateHtml(): Node;
@@ -62,7 +63,18 @@ export declare class JlSelect<Value extends string = string> extends JlFormContr
62
63
  /** The options from `options`, or else copies of the `<option>` and `<optgroup>` the page wrote inside. */
63
64
  private optionNodes;
64
65
  private placeholderNodes;
66
+ /**
67
+ * Draws every option again: only when the options change. Chrome's customizable select reports, as an option
68
+ * inside an option, an option the page added and removed before its check ran.
69
+ */
65
70
  private renderOptions;
71
+ /** Another value among the options drawn: only the option kept for an unknown value comes or goes. */
72
+ private renderChosen;
73
+ /** Another placeholder: its own option is written, added or removed, the others left as they are. */
74
+ private renderPlaceholder;
75
+ private writePlaceholder;
76
+ /** The option kept for a value no option has goes once another value is chosen. */
77
+ private dropKept;
66
78
  /**
67
79
  * A value no option has (a choice since removed, options still loading) shows as an option of its own, first, so
68
80
  * the field shows what is saved and the form keeps it, rather than another choice.
@@ -43,12 +43,12 @@ var JlSelect = class extends JlFormControl {
43
43
  parse: jsonOf([])
44
44
  });
45
45
  /** The chosen value. One that no option has is kept, as an option of its own, rather than replaced. */
46
- value = this.useChange(NO_VALUE, () => this.renderOptions(), {
46
+ value = this.useChange(NO_VALUE, () => this.renderChosen(), {
47
47
  attribute: "value",
48
48
  parse: textOf(NO_VALUE)
49
49
  });
50
50
  /** Shown while nothing is chosen; it cannot be picked back from the list. */
51
- placeholder = this.useChange("", () => this.renderOptions(), { attribute: "placeholder" });
51
+ placeholder = this.useChange("", () => this.renderPlaceholder(), { attribute: "placeholder" });
52
52
  size = this.useChange("md", (value) => this.reflect("size", value), {
53
53
  attribute: "size",
54
54
  parse: oneOf(CONTROL_SIZES, "md")
@@ -70,6 +70,7 @@ var JlSelect = class extends JlFormControl {
70
70
  this._refs.native.toggleAttribute("aria-invalid", value);
71
71
  }, { attribute: "invalid" });
72
72
  _form = { disabled: false };
73
+ _kept;
73
74
  _refs = this.useRefs((ref) => ({ native: ref("select") }));
74
75
  focus(options) {
75
76
  this._refs.native.focus(options);
@@ -78,7 +79,10 @@ var JlSelect = class extends JlFormControl {
78
79
  return /* @__PURE__ */ jsxs("div", {
79
80
  class: "control",
80
81
  attrs: { part: "base" },
81
- children: [/* @__PURE__ */ jsx("select", { class: "native" }), /* @__PURE__ */ jsx(JlIcon, {
82
+ children: [/* @__PURE__ */ jsx("select", {
83
+ class: "native",
84
+ id: "field"
85
+ }), /* @__PURE__ */ jsx(JlIcon, {
82
86
  class: "chevron",
83
87
  name: "chevron-down",
84
88
  size: CHEVRON_SIZE
@@ -95,6 +99,7 @@ var JlSelect = class extends JlFormControl {
95
99
  this.value.set(value);
96
100
  this.events.emit("change", value);
97
101
  });
102
+ if (this.options.get().length > 0) return;
98
103
  this.renderOptions();
99
104
  }
100
105
  resetValue() {
@@ -125,11 +130,49 @@ var JlSelect = class extends JlFormControl {
125
130
  children: placeholder
126
131
  })];
127
132
  }
133
+ /**
134
+ * Draws every option again: only when the options change. Chrome's customizable select reports, as an option
135
+ * inside an option, an option the page added and removed before its check ran.
136
+ */
128
137
  renderOptions() {
129
138
  this._refs.native.replaceChildren(...this.placeholderNodes(), ...this.optionNodes());
139
+ this._kept = void 0;
140
+ this.keepUnknownValue();
141
+ this.renderValue();
142
+ }
143
+ /** Another value among the options drawn: only the option kept for an unknown value comes or goes. */
144
+ renderChosen() {
145
+ this.dropKept();
130
146
  this.keepUnknownValue();
131
147
  this.renderValue();
132
148
  }
149
+ /** Another placeholder: its own option is written, added or removed, the others left as they are. */
150
+ renderPlaceholder() {
151
+ this.writePlaceholder();
152
+ this.renderValue();
153
+ }
154
+ writePlaceholder() {
155
+ const native = this._refs.native;
156
+ const shown = native.querySelector(`:scope > option.${PLACEHOLDER_CLASS}`);
157
+ const placeholder = this.placeholder.get();
158
+ if (shown === null) {
159
+ native.prepend(...this.placeholderNodes());
160
+ return;
161
+ }
162
+ if (placeholder === "") {
163
+ shown.remove();
164
+ return;
165
+ }
166
+ if (shown.text === placeholder) return;
167
+ shown.text = placeholder;
168
+ }
169
+ /** The option kept for a value no option has goes once another value is chosen. */
170
+ dropKept() {
171
+ const kept = this._kept;
172
+ if (kept === void 0 || kept.value === this.value.get()) return;
173
+ kept.remove();
174
+ this._kept = void 0;
175
+ }
133
176
  /**
134
177
  * A value no option has (a choice since removed, options still loading) shows as an option of its own, first, so
135
178
  * the field shows what is saved and the form keeps it, rather than another choice.
@@ -140,10 +183,12 @@ var JlSelect = class extends JlFormControl {
140
183
  const known = [...native.options].some((option) => option.value === value);
141
184
  if (value === NO_VALUE || known) return;
142
185
  const afterPlaceholder = this.placeholder.get() === "" ? 0 : 1;
143
- native.add(/* @__PURE__ */ jsx("option", {
186
+ const kept = /* @__PURE__ */ jsx("option", {
144
187
  value,
145
188
  children: value
146
- }), afterPlaceholder);
189
+ });
190
+ native.add(kept, afterPlaceholder);
191
+ this._kept = kept;
147
192
  }
148
193
  /** Shows the chosen option; the form gets what is shown. */
149
194
  renderValue() {
@@ -56,7 +56,8 @@ var JlSlider = class extends JlFormControl {
56
56
  class: "track-area",
57
57
  children: [/* @__PURE__ */ jsx("input", {
58
58
  type: "range",
59
- class: "native"
59
+ class: "native",
60
+ id: "field"
60
61
  }), /* @__PURE__ */ jsx("div", {
61
62
  class: "marks",
62
63
  "aria-hidden": "true",
@@ -68,6 +68,7 @@ var JlSwitch = class extends JlFormControl {
68
68
  type: "checkbox",
69
69
  role: "switch",
70
70
  class: "native",
71
+ id: "field",
71
72
  "aria-checked": "false",
72
73
  "aria-describedby": "description"
73
74
  }), /* @__PURE__ */ jsx("span", { class: "thumb" })]
@@ -63,6 +63,7 @@ var JlTextarea = class extends JlFormControl {
63
63
  attrs: { part: "base" },
64
64
  children: /* @__PURE__ */ jsx("textarea", {
65
65
  class: "native",
66
+ id: "field",
66
67
  "aria-describedby": "counter"
67
68
  })
68
69
  }), /* @__PURE__ */ jsx("div", {
@@ -1,3 +1,3 @@
1
1
  // src/molecules/jl-breadcrumb.css?inline
2
- var jl_breadcrumb_default = ":host{display:block}ol{font-size:var(--jl-font-sm);flex-wrap:wrap;align-items:center;gap:4px 0;padding:0;line-height:20px;list-style:none;display:flex}li{align-items:center;min-width:0;display:inline-flex}.separator{color:var(--jl-faint);margin:0 6px}.crumb{border-radius:var(--jl-radius-xs);min-width:0;color:var(--jl-muted);align-items:center;gap:6px;padding:2px 4px;text-decoration:none;display:inline-flex}a.crumb:hover{color:var(--jl-text);text-underline-offset:3px;text-decoration:underline}.crumb[aria-current=page]{color:var(--jl-text);font-weight:600}.label{text-overflow:ellipsis;white-space:nowrap;max-width:24ch;overflow:hidden}.more{border-radius:var(--jl-radius-xs);width:26px;height:22px;color:var(--jl-muted);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.more:hover{background:var(--jl-surface-3);color:var(--jl-text)}li:first-child .crumb{margin-left:-4px}";
2
+ var jl_breadcrumb_default = ":host{display:block}ol{font-size:var(--jl-font-sm);flex-wrap:wrap;align-items:center;gap:4px 0;padding:0;line-height:20px;list-style:none;display:flex}li{align-items:center;min-width:0;display:inline-flex}.separator{color:var(--jl-faint);margin:0 6px}.crumb{border-radius:var(--jl-radius-xs);min-width:0;color:var(--jl-muted);align-items:center;gap:6px;padding:2px 4px;text-decoration:none;display:inline-flex}button.crumb{font:inherit;cursor:pointer;background:0 0;border:0}a.crumb:hover,button.crumb:hover{color:var(--jl-text);text-underline-offset:3px;text-decoration:underline}.crumb[aria-current=page]{color:var(--jl-text);font-weight:600}.label{text-overflow:ellipsis;white-space:nowrap;max-width:24ch;overflow:hidden}.more{border-radius:var(--jl-radius-xs);width:26px;height:22px;color:var(--jl-muted);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.more:hover{background:var(--jl-surface-3);color:var(--jl-text)}li:first-child .crumb{margin-left:-4px}";
3
3
  export { jl_breadcrumb_default as default };
@@ -2,13 +2,17 @@ import { JlElement } from '../base/jl-element';
2
2
  import type { BreadcrumbItem } from '../types/jl-breadcrumb.types';
3
3
  /**
4
4
  * Where the page sits in a hierarchy: a trail of links, the last one being the current page. With `max`, a long
5
- * trail folds its middle into a button that unfolds it.
5
+ * trail folds its middle into a button that unfolds it. An item with an `id` instead of an `href` is followed by the
6
+ * app: the breadcrumb fires `select` with its id. Typed by its ids, `JlBreadcrumb<'orders' | 'order'>`.
6
7
  */
7
- export declare class JlBreadcrumb extends JlElement {
8
+ export declare class JlBreadcrumb<Id extends string = string> extends JlElement {
8
9
  static readonly selector = "jl-breadcrumb";
10
+ readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
11
+ select: Id;
12
+ }>>;
9
13
  readonly items: Readonly<Readonly<{
10
- get(): BreadcrumbItem[];
11
- set(setter: BreadcrumbItem[] | ((prevState: BreadcrumbItem[]) => BreadcrumbItem[])): void;
14
+ get(): BreadcrumbItem<Id>[];
15
+ set(setter: BreadcrumbItem<Id>[] | ((prevState: BreadcrumbItem<Id>[]) => BreadcrumbItem<Id>[])): void;
12
16
  }>>;
13
17
  /** The most items shown before the middle folds; 0 never folds. */
14
18
  readonly max: Readonly<Readonly<{
@@ -30,6 +34,8 @@ export declare class JlBreadcrumb extends JlElement {
30
34
  /** A new trail starts folded. */
31
35
  private renderTrail;
32
36
  private render;
37
+ /** An item the app follows, found among the items by the id its button carries. */
38
+ private follow;
33
39
  private crumb;
34
40
  private moreButton;
35
41
  /** Unfolds the middle, and moves the focus to the first item it showed. */
@@ -32,10 +32,12 @@ function visibleCrumbs(items, max, expanded) {
32
32
  }
33
33
  /**
34
34
  * Where the page sits in a hierarchy: a trail of links, the last one being the current page. With `max`, a long
35
- * trail folds its middle into a button that unfolds it.
35
+ * trail folds its middle into a button that unfolds it. An item with an `id` instead of an `href` is followed by the
36
+ * app: the breadcrumb fires `select` with its id. Typed by its ids, `JlBreadcrumb<'orders' | 'order'>`.
36
37
  */
37
38
  var JlBreadcrumb = class extends JlElement {
38
39
  static selector = "jl-breadcrumb";
40
+ events = this.useEvents();
39
41
  items = this.useChange([], () => this.renderTrail(), {
40
42
  attribute: "items",
41
43
  parse: jsonOf([])
@@ -60,7 +62,12 @@ var JlBreadcrumb = class extends JlElement {
60
62
  }
61
63
  onConnect() {
62
64
  this.on(this._refs.list, "click", (event) => {
63
- if (event.target.closest(".more") !== null) this.expand();
65
+ const target = event.target;
66
+ if (target.closest(".more") !== null) {
67
+ this.expand();
68
+ return;
69
+ }
70
+ this.follow(target.closest("button.crumb")?.dataset.id);
64
71
  });
65
72
  }
66
73
  drawTexts() {
@@ -85,6 +92,11 @@ var JlBreadcrumb = class extends JlElement {
85
92
  size: SEPARATOR_SIZE
86
93
  }) : "", "hidden" in crumb ? this.moreButton(crumb.hidden) : this.crumb(crumb.item, crumb.index === lastIndex)] })));
87
94
  }
95
+ /** An item the app follows, found among the items by the id its button carries. */
96
+ follow(id) {
97
+ const item = this.items.get().find((candidate) => candidate.id !== void 0 && candidate.id === id);
98
+ if (item?.id !== void 0) this.events.emit("select", item.id);
99
+ }
88
100
  crumb(item, current) {
89
101
  const ariaCurrent = current ? "page" : void 0;
90
102
  const content = [item.icon === void 0 ? "" : /* @__PURE__ */ jsx(JlIcon, {
@@ -94,6 +106,14 @@ var JlBreadcrumb = class extends JlElement {
94
106
  class: "label",
95
107
  children: item.label
96
108
  })];
109
+ if (item.href === void 0 && item.id !== void 0) return /* @__PURE__ */ jsx("button", {
110
+ type: "button",
111
+ class: "crumb",
112
+ "data-id": item.id,
113
+ title: item.label,
114
+ "aria-current": ariaCurrent,
115
+ children: content
116
+ });
97
117
  if (item.href === void 0) return /* @__PURE__ */ jsx("span", {
98
118
  class: "crumb",
99
119
  title: item.label,
@@ -99,6 +99,7 @@ var JlCombobox = class extends JlFormControl {
99
99
  children: [
100
100
  /* @__PURE__ */ jsx("input", {
101
101
  class: "native",
102
+ id: "field",
102
103
  role: "combobox",
103
104
  "aria-autocomplete": "list",
104
105
  "aria-expanded": "false",
@@ -105,6 +105,7 @@ var JlDatePicker = class extends JlFormControl {
105
105
  children: [
106
106
  /* @__PURE__ */ jsx("input", {
107
107
  class: "native",
108
+ id: "field",
108
109
  role: "combobox",
109
110
  autocomplete: "off",
110
111
  spellcheck: false,
@@ -1,3 +1,3 @@
1
1
  // src/molecules/jl-facts.css?inline
2
- var jl_facts_default = ":host{display:block;container-type:inline-size}:host([empty]){display:none}.facts{font-size:var(--jl-font-md);grid-template-columns:max-content minmax(0,1fr);gap:6px 24px;margin:0;display:grid}.fact{display:contents}dt{color:var(--jl-muted)}dd{min-width:0;color:var(--jl-text);overflow-wrap:anywhere;margin:0}code{font-family:var(--jl-font-mono);font-size:var(--jl-font-sm);word-break:break-all}a{color:var(--jl-accent);text-decoration:none}a:hover{color:var(--jl-accent-strong);text-decoration:underline}:host([orientation=vertical]) .facts{grid-template-columns:repeat(auto-fill,minmax(min(100%,180px),1fr));gap:16px 24px}:host([orientation=vertical]) .fact{align-content:start;gap:2px;display:grid}@container (width<420px){.facts{grid-template-columns:minmax(0,1fr);gap:12px}.fact{gap:2px;display:grid}}";
2
+ var jl_facts_default = ":host{display:block;container-type:inline-size}:host([empty]){display:none}.facts{font-size:var(--jl-font-md);grid-template-columns:max-content minmax(0,1fr);gap:6px 24px;margin:0;display:grid}.fact{display:contents}dt{color:var(--jl-muted)}dd{min-width:0;color:var(--jl-text);overflow-wrap:anywhere;margin:0}code{font-family:var(--jl-font-mono);font-size:var(--jl-font-sm);word-break:break-all}a,button.link{color:var(--jl-accent);text-decoration:none}button.link{font:inherit;text-align:start;cursor:pointer;background:0 0;border:0;padding:0}a:hover,button.link:hover{color:var(--jl-accent-strong);text-decoration:underline}:host([orientation=vertical]) .facts{grid-template-columns:repeat(auto-fill,minmax(min(100%,180px),1fr));gap:16px 24px}:host([orientation=vertical]) .fact{align-content:start;gap:2px;display:grid}@container (width<420px){.facts{grid-template-columns:minmax(0,1fr);gap:12px}.fact{gap:2px;display:grid}}";
3
3
  export { jl_facts_default as default };
@@ -5,10 +5,13 @@ export declare const FACTS_ORIENTATIONS: readonly FactsOrientation[];
5
5
  * The facts about one thing, label and value: an object's size and digest, an order's customer and date. Facts
6
6
  * without a value are left out, and an element with none takes no room. Values can be code (monospace, broken
7
7
  * anywhere), links, or drawn by code (`renderers`, by a fact's `key`). Narrower than 420 pixels, labels go over
8
- * their values.
8
+ * their values. A fact with an `id` instead of an `href` is a link the app follows: the facts fire `select` with it.
9
9
  */
10
10
  export declare class JlFacts extends JlElement {
11
11
  static readonly selector = "jl-facts";
12
+ readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
13
+ select: string;
14
+ }>>;
12
15
  readonly items: Readonly<Readonly<{
13
16
  get(): Fact[];
14
17
  set(setter: Fact[] | ((prevState: Fact[]) => Fact[])): void;
@@ -30,6 +33,7 @@ export declare class JlFacts extends JlElement {
30
33
  private readonly _refs;
31
34
  templateHtml(): Node;
32
35
  templateCss(): string;
36
+ onConnect(): void;
33
37
  private render;
34
38
  private valueNode;
35
39
  }
@@ -12,10 +12,11 @@ var hasValue = (fact) => fact.value !== null && fact.value !== void 0 && fact.va
12
12
  * The facts about one thing, label and value: an object's size and digest, an order's customer and date. Facts
13
13
  * without a value are left out, and an element with none takes no room. Values can be code (monospace, broken
14
14
  * anywhere), links, or drawn by code (`renderers`, by a fact's `key`). Narrower than 420 pixels, labels go over
15
- * their values.
15
+ * their values. A fact with an `id` instead of an `href` is a link the app follows: the facts fire `select` with it.
16
16
  */
17
17
  var JlFacts = class extends JlElement {
18
18
  static selector = "jl-facts";
19
+ events = this.useEvents();
19
20
  items = this.useChange([], () => this.render(), {
20
21
  attribute: "items",
21
22
  parse: jsonOf([])
@@ -38,6 +39,13 @@ var JlFacts = class extends JlElement {
38
39
  templateCss() {
39
40
  return css`${BASE_STYLES}${jl_facts_default}`;
40
41
  }
42
+ onConnect() {
43
+ this.on(this._refs.list, "click", (event) => {
44
+ const id = event.target.closest("button.link")?.dataset.id;
45
+ const fact = this.items.get().find((candidate) => candidate.id !== void 0 && candidate.id === id);
46
+ if (fact?.id !== void 0) this.events.emit("select", fact.id);
47
+ });
48
+ }
41
49
  render() {
42
50
  const shown = this.items.get().filter(hasValue);
43
51
  this._refs.list.replaceChildren(...shown.map((fact) => /* @__PURE__ */ jsxs("div", {
@@ -54,10 +62,16 @@ var JlFacts = class extends JlElement {
54
62
  if (renderer !== void 0) return renderer(fact);
55
63
  const text = String(fact.value);
56
64
  const content = fact.code ? /* @__PURE__ */ jsx("code", { children: text }) : document.createTextNode(text);
57
- return fact.href === void 0 ? content : /* @__PURE__ */ jsx("a", {
65
+ if (fact.href !== void 0) return /* @__PURE__ */ jsx("a", {
58
66
  href: fact.href,
59
67
  children: content
60
68
  });
69
+ return fact.id === void 0 ? content : /* @__PURE__ */ jsx("button", {
70
+ type: "button",
71
+ class: "link",
72
+ "data-id": fact.id,
73
+ children: content
74
+ });
61
75
  }
62
76
  };
63
77
  JlFacts.register();
@@ -157,6 +157,7 @@ var JlFileDrop = class extends JlFormControl {
157
157
  }),
158
158
  /* @__PURE__ */ jsx("input", {
159
159
  class: "picker",
160
+ id: "picker",
160
161
  type: "file",
161
162
  tabIndex: -1,
162
163
  hidden: true
@@ -96,6 +96,7 @@ var JlNumberInput = class extends JlFormControl {
96
96
  }),
97
97
  /* @__PURE__ */ jsx("input", {
98
98
  class: "native",
99
+ id: "field",
99
100
  type: "text",
100
101
  inputMode: "decimal",
101
102
  role: "spinbutton",
@@ -102,6 +102,7 @@ var JlSearch = class extends JlFormControl {
102
102
  }),
103
103
  /* @__PURE__ */ jsx("input", {
104
104
  class: "native",
105
+ id: "field",
105
106
  type: "search",
106
107
  autocomplete: "off"
107
108
  }),
@@ -96,6 +96,7 @@ var JlTagInput = class extends JlFormControl {
96
96
  role: "list"
97
97
  }), /* @__PURE__ */ jsx("input", {
98
98
  class: "native",
99
+ id: "field",
99
100
  autocomplete: "off"
100
101
  })]
101
102
  }),
@@ -104,6 +104,7 @@ var JlCommandPalette = class extends JlElement {
104
104
  }),
105
105
  /* @__PURE__ */ jsx("input", {
106
106
  type: "text",
107
+ id: "query",
107
108
  role: "combobox",
108
109
  "aria-expanded": "true",
109
110
  "aria-controls": "results",
@@ -1,3 +1,3 @@
1
1
  // src/organisms/jl-side-nav.css?inline
2
- var jl_side_nav_default = ":host{width:var(--width,248px);height:100%;min-height:0;transition:width var(--jl-slow) var(--jl-ease);display:block}:host([rail]){width:var(--rail-width,60px)}nav{height:100%;color:var(--jl-text-2);font-size:var(--jl-font-md);flex-direction:column;gap:8px;padding:12px 8px;display:flex;overflow:hidden auto}.bottom{flex-direction:column;gap:8px;margin-top:auto;display:flex}.fold{align-self:flex-start}:host([rail]) .fold{align-self:center}.sections{gap:14px;display:grid}.section{gap:2px;display:grid}.section-label{color:var(--jl-muted);letter-spacing:.08em;text-transform:uppercase;white-space:nowrap;padding:4px 10px 6px;font-size:11px;font-weight:650}.items,.children{gap:2px;margin:0;padding:0;list-style:none;display:grid}.children{margin-top:2px}.entry{position:relative}.item{border-radius:var(--jl-radius-sm);width:100%;min-height:34px;color:inherit;font:inherit;text-align:start;white-space:nowrap;cursor:pointer;transition:background var(--jl-fast) var(--jl-ease), color var(--jl-fast) var(--jl-ease);background:0 0;border:none;align-items:center;gap:10px;padding:0 10px;font-weight:550;text-decoration:none;display:flex}.item[data-depth=\"1\"]{padding-left:36px}.item[data-depth=\"2\"]{padding-left:50px}.item[data-depth=\"3\"]{padding-left:64px}.item:hover{background:var(--jl-surface-3);color:var(--jl-text)}.item[aria-current=page]{background:var(--jl-accent-soft);color:var(--jl-accent)}.item.holds-active{color:var(--jl-text)}.item-icon{color:var(--jl-faint)}.item:hover .item-icon,.item.holds-active .item-icon{color:var(--jl-text-2)}.item[aria-current=page] .item-icon{color:var(--jl-accent)}.item-initial{border-radius:var(--jl-radius-xs);background:var(--jl-surface-3);width:20px;height:20px;color:var(--jl-text-2);flex:none;justify-content:center;align-items:center;font-size:11px;font-weight:700;display:none}.item:not([data-depth=\"0\"]) .item-initial{display:none}.item-label{text-overflow:ellipsis;flex:1;min-width:0;overflow:hidden}.item-badge{border-radius:var(--jl-radius-pill);background:var(--jl-surface-3);min-width:20px;color:var(--jl-text-2);text-align:center;flex:none;padding:2px 6px;font-size:11px;font-weight:650;line-height:14px}.item[aria-current=page] .item-badge{background:var(--jl-accent);color:var(--jl-on-accent)}.expander jl-icon{transition:transform var(--jl-fast) var(--jl-ease)}.chevron{color:var(--jl-faint);transition:transform var(--jl-fast) var(--jl-ease)}.entry.open>.item .chevron,.entry.open>.expander jl-icon{transform:rotate(90deg)}.expander{border-radius:var(--jl-radius-xs);width:24px;height:24px;color:var(--jl-faint);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:absolute;top:5px;right:6px}.expander:hover{background:var(--jl-surface-3);color:var(--jl-text)}.entry:has(>.expander)>.item{padding-right:36px}:host([rail]) .section-label{background:var(--jl-line);color:#0000;height:1px;margin:4px 10px;padding:0;overflow:hidden}:host([rail]) .section:first-child .section-label{display:none}:host([rail]) .item{justify-content:center;padding:0}:host([rail]) .item-label{clip-path:inset(50%);width:1px;height:1px;position:absolute;overflow:hidden}:host([rail]) .item-initial{display:inline-flex}:host([rail]) .item-badge{background:var(--jl-accent);color:#0000;width:8px;min-width:0;height:8px;padding:0;position:absolute;top:5px;right:9px;overflow:hidden}:host([rail]) .children{display:none}";
2
+ var jl_side_nav_default = ":host{width:var(--width,248px);height:100%;min-height:0;transition:width var(--jl-slow) var(--jl-ease);display:block}:host([rail]){width:var(--rail-width,60px)}nav{height:100%;color:var(--jl-text-2);font-size:var(--jl-font-md);flex-direction:column;gap:8px;padding:12px 8px;display:flex;overflow:hidden auto}.bottom{flex-direction:column;gap:8px;margin-top:auto;display:flex}.fold::part(base){justify-content:flex-start;gap:10px;padding:0 9px}:host([rail]) .fold::part(base){justify-content:center;padding:0}.sections{gap:14px;display:grid}.section{gap:2px;display:grid}.sections,.section,.items,.children{grid-template-columns:minmax(0,1fr)}.section-label{color:var(--jl-muted);letter-spacing:.08em;text-overflow:ellipsis;text-transform:uppercase;white-space:nowrap;padding:4px 10px 6px;font-size:11px;font-weight:650;overflow:hidden}.items,.children{gap:2px;margin:0;padding:0;list-style:none;display:grid}.children{margin-top:2px}.entry{position:relative}.item{border-radius:var(--jl-radius-sm);width:100%;min-height:34px;color:inherit;font:inherit;text-align:start;white-space:nowrap;cursor:pointer;transition:background var(--jl-fast) var(--jl-ease), color var(--jl-fast) var(--jl-ease);background:0 0;border:none;align-items:center;gap:10px;padding:0 10px;font-weight:550;text-decoration:none;display:flex}.item[data-depth=\"1\"]{padding-left:36px}.item[data-depth=\"2\"]{padding-left:50px}.item[data-depth=\"3\"]{padding-left:64px}.item:hover{background:var(--jl-surface-3);color:var(--jl-text)}.item[aria-current=page]{background:var(--jl-accent-soft);color:var(--jl-accent)}.item.holds-active{color:var(--jl-text)}.item-icon{color:var(--jl-faint)}.item:hover .item-icon,.item.holds-active .item-icon{color:var(--jl-text-2)}.item[aria-current=page] .item-icon{color:var(--jl-accent)}.item-initial{border-radius:var(--jl-radius-xs);background:var(--jl-surface-3);width:20px;height:20px;color:var(--jl-text-2);flex:none;justify-content:center;align-items:center;font-size:11px;font-weight:700;display:none}.item:not([data-depth=\"0\"]) .item-initial{display:none}.item-label{text-overflow:ellipsis;flex:1;min-width:0;overflow:hidden}.item-badge{border-radius:var(--jl-radius-pill);background:var(--jl-surface-3);min-width:20px;color:var(--jl-text-2);text-align:center;flex:none;padding:2px 6px;font-size:11px;font-weight:650;line-height:14px}.item[aria-current=page] .item-badge{background:var(--jl-accent);color:var(--jl-on-accent)}.expander jl-icon{transition:transform var(--jl-fast) var(--jl-ease)}.chevron{color:var(--jl-faint);transition:transform var(--jl-fast) var(--jl-ease)}.entry.open>.item .chevron,.entry.open>.expander jl-icon{transform:rotate(90deg)}.expander{border-radius:var(--jl-radius-xs);width:24px;height:24px;color:var(--jl-faint);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:absolute;top:5px;right:6px}.expander:hover{background:var(--jl-surface-3);color:var(--jl-text)}.entry:has(>.expander)>.item{padding-right:36px}:host([rail]) .section-label{background:var(--jl-line);color:#0000;height:1px;margin:4px 10px;padding:0;overflow:hidden}:host([rail]) .section:first-child .section-label{display:none}:host([rail]) .item{justify-content:center;padding:0}:host([rail]) .item-label{clip-path:inset(50%);width:1px;height:1px;position:absolute;overflow:hidden}:host([rail]) .item-initial{display:inline-flex}:host([rail]) .item-badge{background:var(--jl-accent);color:#0000;width:8px;min-width:0;height:8px;padding:0;position:absolute;top:5px;right:9px;overflow:hidden}:host([rail]) .children{display:none}";
3
3
  export { jl_side_nav_default as default };
@@ -90,7 +90,7 @@ var JlSideNav = class extends JlElement {
90
90
  children: [/* @__PURE__ */ jsx("slot", { name: "footer" }), /* @__PURE__ */ jsx(JlButton, {
91
91
  class: "fold",
92
92
  variant: "ghost",
93
- size: "sm",
93
+ block: true,
94
94
  hidden: true
95
95
  })]
96
96
  })
@@ -69,6 +69,7 @@ function checkbox(label, index) {
69
69
  children: [/* @__PURE__ */ jsx("input", {
70
70
  type: "checkbox",
71
71
  class: "checkbox",
72
+ id: index === null ? "select-all" : `select-${index}`,
72
73
  "aria-label": label,
73
74
  "data-index": index ?? void 0
74
75
  }), /* @__PURE__ */ jsx("span", {
@@ -24,11 +24,16 @@ export declare class JlPage extends JlElement {
24
24
  get(): PageWidth;
25
25
  set(setter: ((prevState: PageWidth) => PageWidth) | PageWidth): void;
26
26
  }>>;
27
- /** Where the back link leads; no back link without it. */
27
+ /** Where the back link leads; no back link without it, unless `backable`. */
28
28
  readonly back: Readonly<Readonly<{
29
29
  get(): string;
30
30
  set(setter: string | ((prevState: string) => string)): void;
31
31
  }>>;
32
+ /** Shows the back link without an address: pressed, it fires `back`, which the app follows (a router's `goto`). */
33
+ readonly backable: Readonly<Readonly<{
34
+ get(): boolean;
35
+ set(setter: boolean | ((prevState: boolean) => boolean)): void;
36
+ }>>;
32
37
  /** The name of the page the back link leads to: "Orders". */
33
38
  readonly backLabel: Readonly<Readonly<{
34
39
  get(): string;
@@ -44,7 +49,7 @@ export declare class JlPage extends JlElement {
44
49
  templateCss(): string;
45
50
  onConnect(): void;
46
51
  protected drawTexts(): void;
47
- /** The back link stays out of the header's breadcrumb slot without an address, so the header takes no room for it. */
52
+ /** The back link stays out of the header's breadcrumb slot without an address (and not backable), so the header takes no room for it. */
48
53
  private renderBack;
49
54
  private renderTitle;
50
55
  }
@@ -40,8 +40,10 @@ var JlPage = class extends JlElement {
40
40
  attribute: "width",
41
41
  parse: oneOf(PAGE_WIDTHS, "standard")
42
42
  });
43
- /** Where the back link leads; no back link without it. */
43
+ /** Where the back link leads; no back link without it, unless `backable`. */
44
44
  back = this.useChange("", () => this.renderBack(), { attribute: "back" });
45
+ /** Shows the back link without an address: pressed, it fires `back`, which the app follows (a router's `goto`). */
46
+ backable = this.useChange(false, () => this.renderBack(), { attribute: "backable" });
45
47
  /** The name of the page the back link leads to: "Orders". */
46
48
  backLabel = this.useChange("", () => this.renderBack(), { attribute: "back-label" });
47
49
  /** The app's name, after the heading in the browser tab. Without it, the page leaves the tab's title alone. */
@@ -86,13 +88,13 @@ var JlPage = class extends JlElement {
86
88
  drawTexts() {
87
89
  this.renderBack();
88
90
  }
89
- /** The back link stays out of the header's breadcrumb slot without an address, so the header takes no room for it. */
91
+ /** The back link stays out of the header's breadcrumb slot without an address (and not backable), so the header takes no room for it. */
90
92
  renderBack() {
91
93
  const back = this._refs.back;
92
94
  const href = this.back.get();
93
95
  back.href.set(href);
94
96
  back.label.set(this.backLabel.get() || jlText("back"));
95
- setOrRemove(back, "slot", href === "" ? "" : BREADCRUMB_SLOT);
97
+ setOrRemove(back, "slot", href === "" && !this.backable.get() ? "" : BREADCRUMB_SLOT);
96
98
  }
97
99
  renderTitle() {
98
100
  const app = this.appName.get();
@@ -1,6 +1,10 @@
1
- /** One level of a breadcrumb: a link when it has an `href`, plain text otherwise. */
2
- export type BreadcrumbItem = {
1
+ /**
2
+ * One level of a breadcrumb: a link when it has an `href`; with an `id` instead, a link the app follows itself (the
3
+ * breadcrumb fires `select` with it); plain text otherwise.
4
+ */
5
+ export type BreadcrumbItem<Id extends string = string> = {
3
6
  label: string;
4
7
  href?: string;
8
+ id?: Id;
5
9
  icon?: string;
6
10
  };
@@ -6,6 +6,8 @@ export type Fact = {
6
6
  code?: boolean;
7
7
  /** An address: the value is a link to it. */
8
8
  href?: string;
9
+ /** Without an `href`, the value is a link the app follows itself: the facts fire `select` with this id. */
10
+ id?: string;
9
11
  /** The value's tooltip. */
10
12
  hint?: string;
11
13
  /** Names the fact for a renderer of `renderers`, which then draws its value. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syware/jlib",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "A tree-shakeable component library on Jadis and native Web Components, organised in atomic design",
5
5
  "keywords": [
6
6
  "web-components",