@syware/jlib 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +2 -1
  2. package/dist/all.js +3 -3
  3. package/dist/atoms/jl-chip.d.ts +1 -0
  4. package/dist/atoms/jl-chip.js +4 -2
  5. package/dist/atoms/jl-input.d.ts +2 -0
  6. package/dist/atoms/jl-input.js +9 -3
  7. package/dist/atoms/jl-rating.d.ts +2 -0
  8. package/dist/atoms/jl-rating.js +13 -5
  9. package/dist/atoms/jl-select.d.ts +8 -7
  10. package/dist/atoms/jl-select.js +11 -6
  11. package/dist/atoms/jl-spinner.d.ts +2 -0
  12. package/dist/atoms/jl-spinner.js +6 -2
  13. package/dist/base/jl-element.d.ts +6 -0
  14. package/dist/base/jl-element.js +5 -0
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +3 -3
  17. package/dist/lib/attributes.d.ts +9 -0
  18. package/dist/lib/attributes.js +10 -1
  19. package/dist/lib/nav-tree.d.ts +2 -2
  20. package/dist/lib/palette.d.ts +2 -2
  21. package/dist/lib/table.d.ts +19 -6
  22. package/dist/lib/table.js +42 -7
  23. package/dist/lib/texts-de.d.ts +108 -0
  24. package/dist/lib/texts-de.js +111 -0
  25. package/dist/lib/texts-fr.d.ts +108 -0
  26. package/dist/lib/texts-fr.js +111 -0
  27. package/dist/lib/texts.d.ts +177 -89
  28. package/dist/lib/texts.js +176 -9
  29. package/dist/molecules/jl-alert.d.ts +1 -0
  30. package/dist/molecules/jl-alert.js +4 -2
  31. package/dist/molecules/jl-breadcrumb.d.ts +2 -0
  32. package/dist/molecules/jl-breadcrumb.js +12 -6
  33. package/dist/molecules/jl-calendar.d.ts +1 -0
  34. package/dist/molecules/jl-calendar.js +7 -4
  35. package/dist/molecules/jl-chip-group.d.ts +8 -6
  36. package/dist/molecules/jl-chip-group.js +10 -5
  37. package/dist/molecules/jl-code-block.js +1 -1
  38. package/dist/molecules/jl-combobox.d.ts +3 -1
  39. package/dist/molecules/jl-combobox.js +12 -7
  40. package/dist/molecules/jl-copy-button.d.ts +1 -0
  41. package/dist/molecules/jl-copy-button.js +7 -5
  42. package/dist/molecules/jl-date-picker.d.ts +1 -0
  43. package/dist/molecules/jl-date-picker.js +10 -7
  44. package/dist/molecules/jl-file-drop.d.ts +1 -0
  45. package/dist/molecules/jl-file-drop.js +15 -6
  46. package/dist/molecules/jl-input-list.d.ts +3 -2
  47. package/dist/molecules/jl-input-list.js +10 -7
  48. package/dist/molecules/jl-load-more.d.ts +4 -2
  49. package/dist/molecules/jl-load-more.js +15 -8
  50. package/dist/molecules/jl-load-state.d.ts +4 -0
  51. package/dist/molecules/jl-load-state.js +13 -9
  52. package/dist/molecules/jl-menu.d.ts +8 -4
  53. package/dist/molecules/jl-menu.js +8 -1
  54. package/dist/molecules/jl-number-input.d.ts +1 -0
  55. package/dist/molecules/jl-number-input.js +6 -3
  56. package/dist/molecules/jl-pagination.d.ts +2 -0
  57. package/dist/molecules/jl-pagination.js +17 -9
  58. package/dist/molecules/jl-radio-group.d.ts +9 -7
  59. package/dist/molecules/jl-radio-group.js +14 -7
  60. package/dist/molecules/jl-search-button.d.ts +2 -1
  61. package/dist/molecules/jl-search-button.js +6 -4
  62. package/dist/molecules/jl-search.d.ts +2 -0
  63. package/dist/molecules/jl-search.js +9 -3
  64. package/dist/molecules/jl-segmented.d.ts +8 -7
  65. package/dist/molecules/jl-segmented.js +10 -5
  66. package/dist/molecules/jl-steps.d.ts +2 -0
  67. package/dist/molecules/jl-steps.js +9 -4
  68. package/dist/molecules/jl-tag-input.d.ts +1 -0
  69. package/dist/molecules/jl-tag-input.js +8 -4
  70. package/dist/molecules/jl-toast.d.ts +1 -0
  71. package/dist/molecules/jl-toast.js +4 -2
  72. package/dist/organisms/jl-command-palette.d.ts +9 -5
  73. package/dist/organisms/jl-command-palette.js +15 -11
  74. package/dist/organisms/jl-confirm.d.ts +3 -0
  75. package/dist/organisms/jl-confirm.js +12 -11
  76. package/dist/organisms/jl-dialog.d.ts +1 -0
  77. package/dist/organisms/jl-dialog.js +4 -2
  78. package/dist/organisms/jl-drawer.d.ts +1 -0
  79. package/dist/organisms/jl-drawer.js +4 -2
  80. package/dist/organisms/jl-flow.d.ts +2 -0
  81. package/dist/organisms/jl-flow.js +25 -16
  82. package/dist/organisms/jl-navbar.d.ts +3 -0
  83. package/dist/organisms/jl-navbar.js +16 -7
  84. package/dist/organisms/jl-side-nav.d.ts +12 -9
  85. package/dist/organisms/jl-side-nav.js +26 -15
  86. package/dist/organisms/jl-tab-bar.d.ts +9 -7
  87. package/dist/organisms/jl-tab-bar.js +15 -6
  88. package/dist/organisms/jl-table.css_raw.js +1 -1
  89. package/dist/organisms/jl-table.d.ts +56 -17
  90. package/dist/organisms/jl-table.js +227 -43
  91. package/dist/organisms/jl-toaster.d.ts +2 -1
  92. package/dist/organisms/jl-toaster.js +12 -9
  93. package/dist/organisms/jl-tree.d.ts +6 -4
  94. package/dist/organisms/jl-tree.js +21 -15
  95. package/dist/templates/jl-app-shell.d.ts +1 -0
  96. package/dist/templates/jl-app-shell.js +4 -2
  97. package/dist/templates/jl-auth-layout.d.ts +4 -3
  98. package/dist/templates/jl-auth-layout.js +13 -11
  99. package/dist/templates/jl-page.d.ts +1 -0
  100. package/dist/templates/jl-page.js +4 -1
  101. package/dist/templates/jl-split-view.d.ts +1 -0
  102. package/dist/templates/jl-split-view.js +5 -4
  103. package/dist/types/jl-chip-group.types.d.ts +3 -3
  104. package/dist/types/jl-command-palette.types.d.ts +10 -6
  105. package/dist/types/jl-menu.types.d.ts +4 -4
  106. package/dist/types/jl-radio-group.types.d.ts +6 -3
  107. package/dist/types/jl-segmented.types.d.ts +6 -3
  108. package/dist/types/jl-select.types.d.ts +6 -3
  109. package/dist/types/jl-side-nav.types.d.ts +9 -6
  110. package/dist/types/jl-tab-bar.types.d.ts +6 -3
  111. package/dist/types/jl-table.types.d.ts +34 -8
  112. package/dist/types/texts.types.d.ts +29 -4
  113. package/package.json +3 -3
@@ -4,24 +4,27 @@ import type { PaletteCommand } from '../types/jl-command-palette.types';
4
4
  * A search box over every command of an app, opened by ⌘K (Ctrl+K off Apple) or `show()`. Typing filters the
5
5
  * commands by their letters in order, best matches first, under their groups; arrows move, Enter runs the command
6
6
  * (`select` with its id) and Escape closes. It sits near the top of the window, on the browser's modal `<dialog>`.
7
+ * Typed by its ids, `JlCommandPalette<'theme' | 'logout'>` takes commands of those ids and gives `select` one of
8
+ * them.
7
9
  */
8
- export declare class JlCommandPalette extends JlElement {
10
+ export declare class JlCommandPalette<Id extends string = string> extends JlElement {
9
11
  static readonly selector = "jl-command-palette";
10
12
  /** `search`: what was typed, once typing pauses (and empty when it opens), for a page that answers it. */
11
13
  readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
12
- select: string;
14
+ select: Id;
13
15
  open: undefined;
14
16
  close: undefined;
15
17
  search: string;
16
18
  }>>;
17
19
  readonly commands: Readonly<Readonly<{
18
- get(): PaletteCommand[];
19
- set(setter: PaletteCommand[] | ((prevState: PaletteCommand[]) => PaletteCommand[])): void;
20
+ get(): PaletteCommand<Id>[];
21
+ set(setter: PaletteCommand<Id>[] | ((prevState: PaletteCommand<Id>[]) => PaletteCommand<Id>[])): void;
20
22
  }>>;
21
23
  readonly open: Readonly<Readonly<{
22
24
  get(): boolean;
23
25
  set(setter: boolean | ((prevState: boolean) => boolean)): void;
24
26
  }>>;
27
+ /** What the field says before anything is typed; jlib's own text when empty. */
25
28
  readonly placeholder: Readonly<Readonly<{
26
29
  get(): string;
27
30
  set(setter: string | ((prevState: string) => string)): void;
@@ -31,7 +34,7 @@ export declare class JlCommandPalette extends JlElement {
31
34
  get(): string;
32
35
  set(setter: string | ((prevState: string) => string)): void;
33
36
  }>>;
34
- /** What it says when nothing matches. */
37
+ /** What it says when nothing matches; jlib's own text when empty. */
35
38
  readonly emptyText: Readonly<Readonly<{
36
39
  get(): string;
37
40
  set(setter: string | ((prevState: string) => string)): void;
@@ -57,6 +60,7 @@ export declare class JlCommandPalette extends JlElement {
57
60
  close(): void;
58
61
  templateHtml(): Node;
59
62
  templateCss(): string;
63
+ protected drawTexts(): void;
60
64
  onConnect(): void;
61
65
  private toggleOnHotkey;
62
66
  private navigate;
@@ -1,8 +1,8 @@
1
+ import { jlText } from "../lib/texts.js";
1
2
  import { BASE_STYLES } from "../styles/shared.js";
2
3
  import { JlElement } from "../base/jl-element.js";
3
4
  import { jsonOf } from "../lib/attributes.js";
4
5
  import { registerIcons } from "../lib/icons.js";
5
- import { jlText } from "../lib/texts.js";
6
6
  import { JlIcon } from "../atoms/jl-icon.js";
7
7
  import { setOrRemove } from "../lib/dom.js";
8
8
  import { JlSpinner } from "../atoms/jl-spinner.js";
@@ -34,6 +34,8 @@ function highlighted(label, positions) {
34
34
  * A search box over every command of an app, opened by ⌘K (Ctrl+K off Apple) or `show()`. Typing filters the
35
35
  * commands by their letters in order, best matches first, under their groups; arrows move, Enter runs the command
36
36
  * (`select` with its id) and Escape closes. It sits near the top of the window, on the browser's modal `<dialog>`.
37
+ * Typed by its ids, `JlCommandPalette<'theme' | 'logout'>` takes commands of those ids and gives `select` one of
38
+ * them.
37
39
  */
38
40
  var JlCommandPalette = class extends JlElement {
39
41
  static selector = "jl-command-palette";
@@ -44,15 +46,12 @@ var JlCommandPalette = class extends JlElement {
44
46
  parse: jsonOf([])
45
47
  });
46
48
  open = this.useChange(false, (value) => this.renderOpen(value), { attribute: "open" });
47
- placeholder = this.useChange(jlText("commandPlaceholder"), (value) => {
48
- this._refs.input.placeholder = value;
49
- }, { attribute: "placeholder" });
49
+ /** What the field says before anything is typed; jlib's own text when empty. */
50
+ placeholder = this.useChange("", () => this.drawTexts(), { attribute: "placeholder" });
50
51
  /** The keys that open and close it from anywhere on the page; `none` for no keys. `mod` is ⌘ or Ctrl. */
51
52
  hotkey = this.useChange(DEFAULT_HOTKEY, () => this.renderHotkey(), { attribute: "hotkey" });
52
- /** What it says when nothing matches. */
53
- emptyText = this.useChange(jlText("noCommands"), (value) => {
54
- this._refs.empty.textContent = value;
55
- }, { attribute: "empty-text" });
53
+ /** What it says when nothing matches; jlib's own text when empty. */
54
+ emptyText = this.useChange("", () => this.drawTexts(), { attribute: "empty-text" });
56
55
  /** How long typing pauses, in milliseconds, before `search` fires. */
57
56
  debounce = this.useChange(DEFAULT_DEBOUNCE_MS, () => void 0, { attribute: "debounce" });
58
57
  /** Shows a spinner in place of the search icon, while the page looks for what was typed. */
@@ -61,7 +60,7 @@ var JlCommandPalette = class extends JlElement {
61
60
  this._refs.spinner.hidden = !value;
62
61
  }, { attribute: "loading" });
63
62
  /** The dialog's name for screen readers. */
64
- label = this.useChange(jlText("commandPalette"), (value) => this._refs.dialog.setAttribute("aria-label", value), { attribute: "label" });
63
+ label = this.useChange("", () => this.drawTexts(), { attribute: "label" });
65
64
  _state = {
66
65
  active: 0,
67
66
  matches: [],
@@ -118,8 +117,7 @@ var JlCommandPalette = class extends JlElement {
118
117
  /* @__PURE__ */ jsx("div", {
119
118
  class: "results",
120
119
  id: "results",
121
- role: "listbox",
122
- "aria-label": jlText("commands")
120
+ role: "listbox"
123
121
  }),
124
122
  /* @__PURE__ */ jsx("p", {
125
123
  class: "empty",
@@ -153,6 +151,12 @@ var JlCommandPalette = class extends JlElement {
153
151
  templateCss() {
154
152
  return css`${BASE_STYLES}${jl_command_palette_default}`;
155
153
  }
154
+ drawTexts() {
155
+ this._refs.input.placeholder = this.placeholder.get() || jlText("commandPlaceholder");
156
+ this._refs.empty.textContent = this.emptyText.get() || jlText("noCommands");
157
+ this._refs.dialog.setAttribute("aria-label", this.label.get() || jlText("commandPalette"));
158
+ this._refs.results.setAttribute("aria-label", jlText("commands"));
159
+ }
156
160
  onConnect() {
157
161
  const dialog = this._refs.dialog;
158
162
  const input = this._refs.input;
@@ -20,10 +20,12 @@ export declare class JlConfirm extends JlElement {
20
20
  get(): string;
21
21
  set(setter: string | ((prevState: string) => string)): void;
22
22
  }>>;
23
+ /** The confirm button's text; jlib's own when empty. */
23
24
  readonly confirmLabel: Readonly<Readonly<{
24
25
  get(): string;
25
26
  set(setter: string | ((prevState: string) => string)): void;
26
27
  }>>;
28
+ /** The cancel button's text; jlib's own when empty. */
27
29
  readonly cancelLabel: Readonly<Readonly<{
28
30
  get(): string;
29
31
  set(setter: string | ((prevState: string) => string)): void;
@@ -38,6 +40,7 @@ export declare class JlConfirm extends JlElement {
38
40
  ask(): Promise<boolean>;
39
41
  templateHtml(): Node;
40
42
  templateCss(): string;
43
+ protected drawTexts(): void;
41
44
  onConnect(): void;
42
45
  /** Every way the dialog closes ends in its close event: that is where the answer is given. */
43
46
  private openFor;
@@ -1,8 +1,8 @@
1
+ import { jlText } from "../lib/texts.js";
1
2
  import { BASE_STYLES } from "../styles/shared.js";
2
3
  import { JlElement } from "../base/jl-element.js";
3
4
  import { oneOf } from "../lib/attributes.js";
4
5
  import { define } from "../lib/define.js";
5
- import { jlText } from "../lib/texts.js";
6
6
  import { JlButton } from "../atoms/jl-button.js";
7
7
  import jl_confirm_default from "./jl-confirm.css_raw.js";
8
8
  import { JlDialog } from "./jl-dialog.js";
@@ -15,8 +15,6 @@ var CONFIRM_VARIANTS = {
15
15
  accent: "primary",
16
16
  danger: "danger"
17
17
  };
18
- var DEFAULT_CONFIRM = "Confirm";
19
- var DEFAULT_CANCEL = "Cancel";
20
18
  var CLOSE = "close";
21
19
  /**
22
20
  * A yes-or-no question in a small modal dialog. `ask()` opens it and resolves `true` on confirm, `false` on cancel,
@@ -31,8 +29,10 @@ var JlConfirm = class extends JlElement {
31
29
  this._refs.text.textContent = value;
32
30
  this._refs.text.hidden = value === "";
33
31
  }, { attribute: "text" });
34
- confirmLabel = this.useChange(DEFAULT_CONFIRM, (value) => this._refs.confirm.label.set(value), { attribute: "confirm-label" });
35
- cancelLabel = this.useChange(DEFAULT_CANCEL, (value) => this._refs.cancel.label.set(value), { attribute: "cancel-label" });
32
+ /** The confirm button's text; jlib's own when empty. */
33
+ confirmLabel = this.useChange("", () => this.drawTexts(), { attribute: "confirm-label" });
34
+ /** The cancel button's text; jlib's own when empty. */
35
+ cancelLabel = this.useChange("", () => this.drawTexts(), { attribute: "cancel-label" });
36
36
  tone = this.useChange("accent", (value) => {
37
37
  this.reflect("tone", value);
38
38
  this._refs.confirm.variant.set(CONFIRM_VARIANTS[value]);
@@ -67,14 +67,12 @@ var JlConfirm = class extends JlElement {
67
67
  /* @__PURE__ */ jsx("slot", {}),
68
68
  /* @__PURE__ */ jsx(JlButton, {
69
69
  slot: "actions",
70
- class: "cancel",
71
- label: DEFAULT_CANCEL
70
+ class: "cancel"
72
71
  }),
73
72
  /* @__PURE__ */ jsx(JlButton, {
74
73
  slot: "actions",
75
74
  class: "confirm",
76
- variant: "primary",
77
- label: DEFAULT_CONFIRM
75
+ variant: "primary"
78
76
  })
79
77
  ]
80
78
  });
@@ -82,6 +80,10 @@ var JlConfirm = class extends JlElement {
82
80
  templateCss() {
83
81
  return css`${BASE_STYLES}${jl_confirm_default}`;
84
82
  }
83
+ drawTexts() {
84
+ this._refs.confirm.label.set(this.confirmLabel.get() || jlText("confirm"));
85
+ this._refs.cancel.label.set(this.cancelLabel.get() || jlText("cancel"));
86
+ }
85
87
  onConnect() {
86
88
  this._refs.cancel.events.register("press", () => this._refs.dialog.close());
87
89
  this._refs.confirm.events.register("press", () => {
@@ -130,7 +132,6 @@ function confirmDialog(options) {
130
132
  document.body.append(element);
131
133
  return element.ask().finally(() => element.remove());
132
134
  }
133
- var LEAVE_HEADING = "Leave without saving?";
134
135
  /**
135
136
  * Guards a form or an editor against leaving with changes not saved. Closing or reloading the tab asks the
136
137
  * browser's own question; the function it returns asks in the page, for the app's router to call before it moves
@@ -147,7 +148,7 @@ function guardLeave(options) {
147
148
  asking.pending ??= confirmDialog({
148
149
  cancelLabel: options.stayLabel ?? jlText("stay"),
149
150
  confirmLabel: options.leaveLabel ?? jlText("leave"),
150
- heading: options.heading ?? LEAVE_HEADING,
151
+ heading: options.heading ?? jlText("leaveHeading"),
151
152
  text: options.text ?? jlText("leaveText"),
152
153
  tone: "danger"
153
154
  }).finally(() => {
@@ -37,6 +37,7 @@ export declare class JlDialog extends JlElement {
37
37
  close(): void;
38
38
  templateHtml(): Node;
39
39
  templateCss(): string;
40
+ protected drawTexts(): void;
40
41
  onConnect(): void;
41
42
  private renderFooter;
42
43
  private renderOpen;
@@ -1,8 +1,8 @@
1
+ import { jlText } from "../lib/texts.js";
1
2
  import { BASE_STYLES } from "../styles/shared.js";
2
3
  import { JlElement } from "../base/jl-element.js";
3
4
  import { oneOf } from "../lib/attributes.js";
4
5
  import { registerIcons } from "../lib/icons.js";
5
- import { jlText } from "../lib/texts.js";
6
6
  import { JlButton } from "../atoms/jl-button.js";
7
7
  import jl_dialog_default from "./jl-dialog.css_raw.js";
8
8
  import { css } from "@jadis/core";
@@ -68,7 +68,6 @@ var JlDialog = class extends JlElement {
68
68
  class: "close",
69
69
  variant: "ghost",
70
70
  icon: "x",
71
- hint: jlText("close"),
72
71
  size: "sm"
73
72
  })] }),
74
73
  /* @__PURE__ */ jsx("div", {
@@ -85,6 +84,9 @@ var JlDialog = class extends JlElement {
85
84
  templateCss() {
86
85
  return css`${BASE_STYLES}${jl_dialog_default}`;
87
86
  }
87
+ drawTexts() {
88
+ this._refs.close.hint.set(jlText("close"));
89
+ }
88
90
  onConnect() {
89
91
  const dialog = this._refs.dialog;
90
92
  this._refs.close.events.register("press", () => this.close());
@@ -44,6 +44,7 @@ export declare class JlDrawer extends JlElement {
44
44
  close(): void;
45
45
  templateHtml(): Node;
46
46
  templateCss(): string;
47
+ protected drawTexts(): void;
47
48
  onConnect(): void;
48
49
  private renderFooter;
49
50
  private renderOpen;
@@ -1,8 +1,8 @@
1
+ import { jlText } from "../lib/texts.js";
1
2
  import { BASE_STYLES } from "../styles/shared.js";
2
3
  import { JlElement } from "../base/jl-element.js";
3
4
  import { oneOf } from "../lib/attributes.js";
4
5
  import { registerIcons } from "../lib/icons.js";
5
- import { jlText } from "../lib/texts.js";
6
6
  import { JlButton } from "../atoms/jl-button.js";
7
7
  import jl_drawer_default from "./jl-drawer.css_raw.js";
8
8
  import { css } from "@jadis/core";
@@ -86,7 +86,6 @@ var JlDrawer = class extends JlElement {
86
86
  class: "close",
87
87
  variant: "ghost",
88
88
  icon: "x",
89
- hint: jlText("close"),
90
89
  size: "sm"
91
90
  })]
92
91
  })] }),
@@ -104,6 +103,9 @@ var JlDrawer = class extends JlElement {
104
103
  templateCss() {
105
104
  return css`${BASE_STYLES}${jl_drawer_default}`;
106
105
  }
106
+ drawTexts() {
107
+ this._refs.close.hint.set(jlText("close"));
108
+ }
107
109
  onConnect() {
108
110
  const dialog = this._refs.dialog;
109
111
  this._refs.close.events.register("press", () => this.close());
@@ -57,6 +57,8 @@ export declare class JlFlow extends JlElement {
57
57
  layout(): void;
58
58
  templateHtml(): Node;
59
59
  templateCss(): string;
60
+ protected drawTexts(): void;
61
+ private renderLabel;
60
62
  onConnect(): void;
61
63
  private show;
62
64
  /** An edit: drawn, kept, and sent to the page. */
@@ -1,8 +1,8 @@
1
+ import { jlText } from "../lib/texts.js";
1
2
  import { BASE_STYLES } from "../styles/shared.js";
2
3
  import { JlElement } from "../base/jl-element.js";
3
4
  import { jsonOf } from "../lib/attributes.js";
4
5
  import { registerIcons } from "../lib/icons.js";
5
- import { jlText } from "../lib/texts.js";
6
6
  import { JlIcon } from "../atoms/jl-icon.js";
7
7
  import { setOrRemove, svgElement } from "../lib/dom.js";
8
8
  import { FLOW_NODE, FLOW_ZOOM, centeredAt, connect, edgeEnds, edgeMidpoint, edgePath, fitView, isEdgeTaken, isPortFree, layoutFlow, moveNode, nodeAt, nodeHeight, outputAnchor, portX, portsOf, positionAfter, removeEdge, removeNode, revealIn, snap, toWorld, zoomAt } from "../lib/flow.js";
@@ -116,7 +116,7 @@ var JlFlow = class extends JlElement {
116
116
  */
117
117
  dropType = this.useChange("", () => void 0, { attribute: "drop-type" });
118
118
  /** The canvas's name for screen readers. */
119
- label = this.useChange("", (value) => this._refs.viewport.setAttribute("aria-label", value || jlText("flow")), { attribute: "label" });
119
+ label = this.useChange("", () => this.renderLabel(), { attribute: "label" });
120
120
  _state = {
121
121
  edge: "",
122
122
  fitted: false,
@@ -139,6 +139,7 @@ var JlFlow = class extends JlElement {
139
139
  };
140
140
  _refs = this.useRefs((ref) => ({
141
141
  empty: ref(".empty"),
142
+ emptySlot: ref("slot[name=\"empty\"]"),
142
143
  fit: ref(".fit"),
143
144
  nodes: ref(".nodes"),
144
145
  removeEdge: ref(".remove-edge"),
@@ -203,7 +204,6 @@ var JlFlow = class extends JlElement {
203
204
  class: "remove-edge",
204
205
  "data-control": "",
205
206
  hidden: true,
206
- "aria-label": jlText("removeEdge"),
207
207
  children: /* @__PURE__ */ jsx(JlIcon, {
208
208
  name: "x",
209
209
  size: ADD_ICON_SIZE
@@ -215,10 +215,7 @@ var JlFlow = class extends JlElement {
215
215
  class: "empty",
216
216
  "data-control": "",
217
217
  hidden: true,
218
- children: /* @__PURE__ */ jsx("slot", {
219
- name: "empty",
220
- children: "Nothing here yet."
221
- })
218
+ children: /* @__PURE__ */ jsx("slot", { name: "empty" })
222
219
  }),
223
220
  /* @__PURE__ */ jsxs("div", {
224
221
  class: "controls",
@@ -227,8 +224,6 @@ var JlFlow = class extends JlElement {
227
224
  /* @__PURE__ */ jsx("button", {
228
225
  type: "button",
229
226
  class: "control zoom-out",
230
- title: jlText("zoomOut"),
231
- "aria-label": jlText("zoomOut"),
232
227
  children: /* @__PURE__ */ jsx(JlIcon, {
233
228
  name: "minus",
234
229
  size: CONTROL_ICON_SIZE
@@ -238,8 +233,6 @@ var JlFlow = class extends JlElement {
238
233
  /* @__PURE__ */ jsx("button", {
239
234
  type: "button",
240
235
  class: "control zoom-in",
241
- title: jlText("zoomIn"),
242
- "aria-label": jlText("zoomIn"),
243
236
  children: /* @__PURE__ */ jsx(JlIcon, {
244
237
  name: "plus",
245
238
  size: CONTROL_ICON_SIZE
@@ -248,8 +241,6 @@ var JlFlow = class extends JlElement {
248
241
  /* @__PURE__ */ jsx("button", {
249
242
  type: "button",
250
243
  class: "control fit",
251
- title: jlText("fitView"),
252
- "aria-label": jlText("fitView"),
253
244
  children: /* @__PURE__ */ jsx(JlIcon, {
254
245
  name: "maximize",
255
246
  size: CONTROL_ICON_SIZE
@@ -258,8 +249,6 @@ var JlFlow = class extends JlElement {
258
249
  /* @__PURE__ */ jsx("button", {
259
250
  type: "button",
260
251
  class: "control tidy",
261
- title: jlText("tidyLayout"),
262
- "aria-label": jlText("tidyLayout"),
263
252
  children: /* @__PURE__ */ jsx(JlIcon, {
264
253
  name: "wand-sparkles",
265
254
  size: CONTROL_ICON_SIZE
@@ -273,6 +262,26 @@ var JlFlow = class extends JlElement {
273
262
  templateCss() {
274
263
  return css`${BASE_STYLES}${jl_flow_default}`;
275
264
  }
265
+ drawTexts() {
266
+ this.renderLabel();
267
+ this._refs.emptySlot.textContent = jlText("flowEmpty");
268
+ this._refs.removeEdge.setAttribute("aria-label", jlText("removeEdge"));
269
+ const controls = [
270
+ [this._refs.zoomOut, jlText("zoomOut")],
271
+ [this._refs.zoomIn, jlText("zoomIn")],
272
+ [this._refs.fit, jlText("fitView")],
273
+ [this._refs.tidy, jlText("tidyLayout")]
274
+ ];
275
+ for (const [button, text] of controls) {
276
+ button.title = text;
277
+ button.setAttribute("aria-label", text);
278
+ }
279
+ for (const node of this._nodes.values()) node.setAttribute("aria-roledescription", jlText("node"));
280
+ for (const port of this._refs.nodes.querySelectorAll(".port")) port.title = jlText("dragToConnect");
281
+ }
282
+ renderLabel() {
283
+ this._refs.viewport.setAttribute("aria-label", this.label.get() || jlText("flow"));
284
+ }
276
285
  onConnect() {
277
286
  const viewport = this._refs.viewport;
278
287
  this.on(viewport, "pointerdown", (event) => this.pointerDown(event));
@@ -584,7 +593,7 @@ var JlFlow = class extends JlElement {
584
593
  "data-node": id,
585
594
  tabIndex: 0,
586
595
  role: "group",
587
- "aria-roledescription": "node",
596
+ "aria-roledescription": jlText("node"),
588
597
  attrs: { part: "node" }
589
598
  });
590
599
  this._nodes.set(id, element);
@@ -27,6 +27,9 @@ export declare class JlNavbar extends JlElement {
27
27
  onConnect(): void;
28
28
  private renderLinks;
29
29
  private link;
30
+ protected drawTexts(): void;
31
+ private renderLabel;
32
+ private renderToggleLabel;
30
33
  /** Opens or closes the list of links under the bar, on a narrow bar. */
31
34
  private setDrawer;
32
35
  }
@@ -1,8 +1,8 @@
1
+ import { jlText } from "../lib/texts.js";
1
2
  import { BASE_STYLES } from "../styles/shared.js";
2
3
  import { JlElement } from "../base/jl-element.js";
3
4
  import { jsonOf } from "../lib/attributes.js";
4
5
  import { registerIcons } from "../lib/icons.js";
5
- import { jlText } from "../lib/texts.js";
6
6
  import { JlIcon } from "../atoms/jl-icon.js";
7
7
  import jl_navbar_default from "./jl-navbar.css_raw.js";
8
8
  import { css } from "@jadis/core";
@@ -30,10 +30,7 @@ var JlNavbar = class extends JlElement {
30
30
  /** Stays at the top of the window while the page scrolls. */
31
31
  sticky = this.useChange(false, (value) => this.reflect("sticky", value), { attribute: "sticky" });
32
32
  /** The navigation's name for screen readers. */
33
- label = this.useChange(jlText("mainNavigation"), (value) => {
34
- this._refs.links.setAttribute("aria-label", value || jlText("mainNavigation"));
35
- this._refs.drawer.setAttribute("aria-label", value || jlText("mainNavigation"));
36
- }, { attribute: "label" });
33
+ label = this.useChange("", () => this.renderLabel(), { attribute: "label" });
37
34
  _refs = this.useRefs((ref) => ({
38
35
  drawer: ref(".drawer"),
39
36
  drawerList: ref(".drawer ul"),
@@ -65,7 +62,6 @@ var JlNavbar = class extends JlElement {
65
62
  class: "toggle",
66
63
  "aria-expanded": "false",
67
64
  "aria-controls": "drawer",
68
- "aria-label": jlText("menu"),
69
65
  children: /* @__PURE__ */ jsx(JlIcon, {
70
66
  name: MENU_ICON,
71
67
  size: ICON_SIZE
@@ -108,11 +104,24 @@ var JlNavbar = class extends JlElement {
108
104
  children: link.label
109
105
  }) });
110
106
  }
107
+ drawTexts() {
108
+ this.renderLabel();
109
+ this.renderToggleLabel();
110
+ }
111
+ renderLabel() {
112
+ const label = this.label.get() || jlText("mainNavigation");
113
+ this._refs.links.setAttribute("aria-label", label);
114
+ this._refs.drawer.setAttribute("aria-label", label);
115
+ }
116
+ renderToggleLabel() {
117
+ const open = !this._refs.drawer.hidden;
118
+ this._refs.toggle.setAttribute("aria-label", open ? jlText("closeMenu") : jlText("menu"));
119
+ }
111
120
  /** Opens or closes the list of links under the bar, on a narrow bar. */
112
121
  setDrawer(open) {
113
122
  this._refs.drawer.hidden = !open;
114
123
  this._refs.toggle.setAttribute("aria-expanded", String(open));
115
- this._refs.toggle.setAttribute("aria-label", open ? jlText("closeMenu") : jlText("menu"));
124
+ this.renderToggleLabel();
116
125
  this._refs.toggleIcon.name.set(open ? CLOSE_ICON : MENU_ICON);
117
126
  this.reflect("expanded", open);
118
127
  }
@@ -4,23 +4,24 @@ import type { SideNavSection } from '../types/jl-side-nav.types';
4
4
  * The navigation of an app, down its side: sections of items with icons, badges and nested items that open with
5
5
  * a chevron. `value` is the active item (its parents open to show it); `collapsed` makes it a rail of icons, with
6
6
  * the labels as tooltips, and `collapsible` lets people fold and unfold it with a button at its bottom. Items with
7
- * an `href` are links; the others fire `select`.
7
+ * an `href` are links; the others fire `select`. Typed by its ids, `JlSideNav<'jobs' | 'people'>` takes items of
8
+ * those ids and gives `select` one of them.
8
9
  */
9
- export declare class JlSideNav extends JlElement {
10
+ export declare class JlSideNav<Id extends string = string> extends JlElement {
10
11
  static readonly selector = "jl-side-nav";
11
12
  /** `collapse`: people folded the side nav into its rail (true) or unfolded it (false), for the app to remember. */
12
13
  readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
13
- select: string;
14
+ select: Id;
14
15
  collapse: boolean;
15
16
  }>>;
16
17
  readonly sections: Readonly<Readonly<{
17
- get(): SideNavSection[];
18
- set(setter: SideNavSection[] | ((prevState: SideNavSection[]) => SideNavSection[])): void;
18
+ get(): SideNavSection<Id>[];
19
+ set(setter: SideNavSection<Id>[] | ((prevState: SideNavSection<Id>[]) => SideNavSection<Id>[])): void;
19
20
  }>>;
20
21
  /** The id of the active item. */
21
22
  readonly value: Readonly<Readonly<{
22
- get(): string;
23
- set(setter: string | ((prevState: string) => string)): void;
23
+ get(): "" | Id;
24
+ set(setter: "" | Id | ((prevState: "" | Id) => "" | Id)): void;
24
25
  }>>;
25
26
  /** Shows only the icons, in a narrow rail; the labels become tooltips. */
26
27
  readonly collapsed: Readonly<Readonly<{
@@ -32,12 +33,12 @@ export declare class JlSideNav extends JlElement {
32
33
  get(): boolean;
33
34
  set(setter: boolean | ((prevState: boolean) => boolean)): void;
34
35
  }>>;
35
- /** The fold button's text while the side nav is open. */
36
+ /** The fold button's text while the side nav is open; jlib's own when empty. */
36
37
  readonly collapseLabel: Readonly<Readonly<{
37
38
  get(): string;
38
39
  set(setter: string | ((prevState: string) => string)): void;
39
40
  }>>;
40
- /** Its hint while the side nav is a rail. */
41
+ /** Its hint while the side nav is a rail; jlib's own when empty. */
41
42
  readonly expandLabel: Readonly<Readonly<{
42
43
  get(): string;
43
44
  set(setter: string | ((prevState: string) => string)): void;
@@ -70,6 +71,8 @@ export declare class JlSideNav extends JlElement {
70
71
  private fold;
71
72
  /** The rail, or the whole side nav: drawn again, said on the host (`rail`) for the styles and the page. */
72
73
  private renderRail;
74
+ protected drawTexts(): void;
75
+ private renderLabel;
73
76
  private renderFold;
74
77
  private choose;
75
78
  /** Up and Down move between the rows people can see, Right opens a parent, Left closes it or goes up to it. */
@@ -1,8 +1,8 @@
1
+ import { jlText } from "../lib/texts.js";
1
2
  import { BASE_STYLES } from "../styles/shared.js";
2
3
  import { JlElement } from "../base/jl-element.js";
3
- import { jsonOf } from "../lib/attributes.js";
4
+ import { jsonOf, textOf } from "../lib/attributes.js";
4
5
  import { registerIcons } from "../lib/icons.js";
5
- import { jlText } from "../lib/texts.js";
6
6
  import { JlIcon } from "../atoms/jl-icon.js";
7
7
  import { setOrRemove, uniqueId } from "../lib/dom.js";
8
8
  import { JlButton } from "../atoms/jl-button.js";
@@ -24,6 +24,7 @@ var EXPAND_ICON = "panel-left-open";
24
24
  var ROW_SELECTOR = ".item";
25
25
  var NEW_TAB = "_blank";
26
26
  var SAFE_REL = "noopener noreferrer";
27
+ var NO_ITEM = "";
27
28
  /** A JSON attribute that should hold a list of sections; anything else gives none. */
28
29
  var parseSections = (value) => {
29
30
  const parsed = jsonOf([])(value);
@@ -36,7 +37,8 @@ var isReachable = (row) => row.closest("[hidden]") === null && row.offsetParent
36
37
  * The navigation of an app, down its side: sections of items with icons, badges and nested items that open with
37
38
  * a chevron. `value` is the active item (its parents open to show it); `collapsed` makes it a rail of icons, with
38
39
  * the labels as tooltips, and `collapsible` lets people fold and unfold it with a button at its bottom. Items with
39
- * an `href` are links; the others fire `select`.
40
+ * an `href` are links; the others fire `select`. Typed by its ids, `JlSideNav<'jobs' | 'people'>` takes items of
41
+ * those ids and gives `select` one of them.
40
42
  */
41
43
  var JlSideNav = class extends JlElement {
42
44
  static selector = "jl-side-nav";
@@ -47,7 +49,10 @@ var JlSideNav = class extends JlElement {
47
49
  parse: parseSections
48
50
  });
49
51
  /** The id of the active item. */
50
- value = this.useChange("", (value) => this.renderActive(value), { attribute: "value" });
52
+ value = this.useChange(NO_ITEM, (value) => this.renderActive(value), {
53
+ attribute: "value",
54
+ parse: textOf(NO_ITEM)
55
+ });
51
56
  /** Shows only the icons, in a narrow rail; the labels become tooltips. */
52
57
  collapsed = this.useChange(false, (value) => {
53
58
  this.reflect("collapsed", value);
@@ -55,19 +60,17 @@ var JlSideNav = class extends JlElement {
55
60
  }, { attribute: "collapsed" });
56
61
  /** Adds a button at the bottom that folds the side nav into its rail and unfolds it. */
57
62
  collapsible = this.useChange(false, () => this.renderFold(), { attribute: "collapsible" });
58
- /** The fold button's text while the side nav is open. */
59
- collapseLabel = this.useChange(jlText("collapseMenu"), () => this.renderFold(), { attribute: "collapse-label" });
60
- /** Its hint while the side nav is a rail. */
61
- expandLabel = this.useChange(jlText("expandMenu"), () => this.renderFold(), { attribute: "expand-label" });
63
+ /** The fold button's text while the side nav is open; jlib's own when empty. */
64
+ collapseLabel = this.useChange("", () => this.renderFold(), { attribute: "collapse-label" });
65
+ /** Its hint while the side nav is a rail; jlib's own when empty. */
66
+ expandLabel = this.useChange("", () => this.renderFold(), { attribute: "expand-label" });
62
67
  /**
63
68
  * Set by `jl-app-shell` while the side nav is its drawer, on a narrow screen: the drawer shows it whole, and its
64
69
  * fold button hides, `collapsed` waiting for a wide screen again.
65
70
  */
66
71
  inDrawer = this.useChange(false, () => this.renderRail(), { attribute: "in-drawer" });
67
72
  /** The name of the navigation for screen readers. */
68
- label = this.useChange(jlText("mainNavigation"), (value) => {
69
- this._refs.nav.setAttribute("aria-label", value === "" ? jlText("mainNavigation") : value);
70
- }, { attribute: "label" });
73
+ label = this.useChange("", () => this.renderLabel(), { attribute: "label" });
71
74
  _prefix = uniqueId("jl-side-nav");
72
75
  /** The parents people opened, or that hold the active item. */
73
76
  _state = { open: /* @__PURE__ */ new Set() };
@@ -122,7 +125,7 @@ var JlSideNav = class extends JlElement {
122
125
  this.toggleItem(item.id);
123
126
  return;
124
127
  }
125
- this.choose(row?.dataset.target ?? item.id);
128
+ this.choose(findItem(this.sections.get(), row?.dataset.target ?? "")?.id ?? item.id);
126
129
  }
127
130
  /** Whether it shows as the rail now: folded, and not in a drawer. */
128
131
  isRail() {
@@ -139,13 +142,21 @@ var JlSideNav = class extends JlElement {
139
142
  this.render();
140
143
  this.renderFold();
141
144
  }
145
+ drawTexts() {
146
+ this.renderLabel();
147
+ this.renderFold();
148
+ this.render();
149
+ }
150
+ renderLabel() {
151
+ this._refs.nav.setAttribute("aria-label", this.label.get() || jlText("mainNavigation"));
152
+ }
142
153
  renderFold() {
143
154
  const fold = this._refs.fold;
144
155
  const rail = this.isRail();
145
156
  fold.hidden = !this.collapsible.get() || this.inDrawer.get();
146
157
  fold.icon.set(rail ? EXPAND_ICON : COLLAPSE_ICON);
147
- fold.label.set(rail ? "" : this.collapseLabel.get());
148
- fold.hint.set(rail ? this.expandLabel.get() : "");
158
+ fold.label.set(rail ? "" : this.collapseLabel.get() || jlText("collapseMenu"));
159
+ fold.hint.set(rail ? this.expandLabel.get() || jlText("expandMenu") : "");
149
160
  }
150
161
  choose(id) {
151
162
  this.value.set(id);
@@ -220,7 +231,7 @@ var JlSideNav = class extends JlElement {
220
231
  class: "expander",
221
232
  type: "button",
222
233
  "data-id": item.id,
223
- "aria-label": `Show the pages of ${item.label}`,
234
+ "aria-label": jlText("showPagesOf", { name: item.label }),
224
235
  "aria-controls": childrenId,
225
236
  children: /* @__PURE__ */ jsx(JlIcon, {
226
237
  name: "chevron-right",