@syware/jlib 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.
Files changed (130) hide show
  1. package/dist/all.js +10 -5
  2. package/dist/atoms/jl-app-icon.d.ts +5 -0
  3. package/dist/atoms/jl-app-icon.js +26 -4
  4. package/dist/atoms/jl-badge.js +1 -1
  5. package/dist/atoms/jl-button.d.ts +5 -0
  6. package/dist/atoms/jl-button.js +4 -1
  7. package/dist/atoms/jl-chip.js +3 -2
  8. package/dist/atoms/jl-input.js +4 -3
  9. package/dist/atoms/jl-link.js +1 -1
  10. package/dist/atoms/jl-rating.js +4 -5
  11. package/dist/atoms/jl-select.css_raw.js +1 -1
  12. package/dist/atoms/jl-select.d.ts +10 -8
  13. package/dist/atoms/jl-select.js +15 -9
  14. package/dist/atoms/jl-spinner.js +2 -2
  15. package/dist/base/jl-form-control.js +2 -1
  16. package/dist/index.d.ts +8 -0
  17. package/dist/index.js +9 -4
  18. package/dist/lib/app-icon.d.ts +8 -0
  19. package/dist/lib/app-icon.js +37 -0
  20. package/dist/lib/attributes.d.ts +9 -0
  21. package/dist/lib/attributes.js +10 -1
  22. package/dist/lib/dom.d.ts +2 -0
  23. package/dist/lib/dom.js +3 -1
  24. package/dist/lib/download.d.ts +10 -0
  25. package/dist/lib/download.js +62 -0
  26. package/dist/lib/icons.d.ts +4 -0
  27. package/dist/lib/icons.js +7 -4
  28. package/dist/lib/input-list.d.ts +12 -0
  29. package/dist/lib/input-list.js +14 -0
  30. package/dist/lib/internals.d.ts +5 -0
  31. package/dist/lib/internals.js +18 -0
  32. package/dist/lib/nav-tree.d.ts +2 -2
  33. package/dist/lib/palette.d.ts +2 -2
  34. package/dist/lib/palette.js +6 -0
  35. package/dist/lib/resize.d.ts +2 -0
  36. package/dist/lib/resize.js +10 -0
  37. package/dist/lib/table.d.ts +22 -4
  38. package/dist/lib/table.js +55 -5
  39. package/dist/lib/text.d.ts +2 -0
  40. package/dist/lib/text.js +4 -1
  41. package/dist/lib/texts.d.ts +99 -0
  42. package/dist/lib/texts.js +104 -0
  43. package/dist/lib/tree.d.ts +10 -1
  44. package/dist/lib/tree.js +37 -3
  45. package/dist/molecules/jl-account-button.js +1 -1
  46. package/dist/molecules/jl-alert.js +2 -1
  47. package/dist/molecules/jl-breadcrumb.js +3 -3
  48. package/dist/molecules/jl-calendar.js +4 -4
  49. package/dist/molecules/jl-chip-group.d.ts +7 -6
  50. package/dist/molecules/jl-chip-group.js +8 -6
  51. package/dist/molecules/jl-code-block.css_raw.js +1 -1
  52. package/dist/molecules/jl-code-block.d.ts +5 -0
  53. package/dist/molecules/jl-code-block.js +5 -2
  54. package/dist/molecules/jl-combobox.js +5 -6
  55. package/dist/molecules/jl-copy-button.js +5 -4
  56. package/dist/molecules/jl-date-picker.js +6 -7
  57. package/dist/molecules/jl-empty.js +1 -1
  58. package/dist/molecules/jl-facts.css_raw.js +3 -0
  59. package/dist/molecules/jl-facts.d.ts +35 -0
  60. package/dist/molecules/jl-facts.js +64 -0
  61. package/dist/molecules/jl-file-drop.d.ts +5 -0
  62. package/dist/molecules/jl-file-drop.js +17 -14
  63. package/dist/molecules/jl-input-list.css_raw.js +3 -0
  64. package/dist/molecules/jl-input-list.d.ts +79 -0
  65. package/dist/molecules/jl-input-list.js +177 -0
  66. package/dist/molecules/jl-load-more.css_raw.js +3 -0
  67. package/dist/molecules/jl-load-more.d.ts +41 -0
  68. package/dist/molecules/jl-load-more.js +62 -0
  69. package/dist/molecules/jl-load-state.js +6 -7
  70. package/dist/molecules/jl-menu.d.ts +8 -4
  71. package/dist/molecules/jl-menu.js +8 -1
  72. package/dist/molecules/jl-number-input.js +4 -4
  73. package/dist/molecules/jl-pagination.js +5 -5
  74. package/dist/molecules/jl-radio-group.d.ts +8 -7
  75. package/dist/molecules/jl-radio-group.js +12 -8
  76. package/dist/molecules/jl-search-button.js +4 -4
  77. package/dist/molecules/jl-search.js +4 -4
  78. package/dist/molecules/jl-segmented.d.ts +8 -7
  79. package/dist/molecules/jl-segmented.js +12 -6
  80. package/dist/molecules/jl-steps.css_raw.js +1 -1
  81. package/dist/molecules/jl-steps.d.ts +2 -0
  82. package/dist/molecules/jl-steps.js +30 -14
  83. package/dist/molecules/jl-tabs.js +2 -1
  84. package/dist/molecules/jl-tag-input.js +2 -2
  85. package/dist/molecules/jl-toast.css_raw.js +1 -1
  86. package/dist/molecules/jl-toast.d.ts +13 -1
  87. package/dist/molecules/jl-toast.js +23 -3
  88. package/dist/organisms/jl-command-palette.css_raw.js +1 -1
  89. package/dist/organisms/jl-command-palette.d.ts +20 -4
  90. package/dist/organisms/jl-command-palette.js +41 -9
  91. package/dist/organisms/jl-confirm.js +5 -7
  92. package/dist/organisms/jl-dialog.js +2 -1
  93. package/dist/organisms/jl-drawer.js +2 -1
  94. package/dist/organisms/jl-flow.js +12 -12
  95. package/dist/organisms/jl-navbar.js +6 -6
  96. package/dist/organisms/jl-side-nav.css_raw.js +1 -1
  97. package/dist/organisms/jl-side-nav.d.ts +40 -7
  98. package/dist/organisms/jl-side-nav.js +78 -16
  99. package/dist/organisms/jl-tab-bar.d.ts +8 -7
  100. package/dist/organisms/jl-tab-bar.js +12 -6
  101. package/dist/organisms/jl-table.css_raw.js +1 -1
  102. package/dist/organisms/jl-table.d.ts +62 -15
  103. package/dist/organisms/jl-table.js +246 -35
  104. package/dist/organisms/jl-toaster.d.ts +9 -1
  105. package/dist/organisms/jl-toaster.js +148 -7
  106. package/dist/organisms/jl-tree.css_raw.js +1 -1
  107. package/dist/organisms/jl-tree.d.ts +71 -4
  108. package/dist/organisms/jl-tree.js +303 -40
  109. package/dist/templates/jl-app-shell.css_raw.js +1 -1
  110. package/dist/templates/jl-app-shell.d.ts +10 -0
  111. package/dist/templates/jl-app-shell.js +16 -2
  112. package/dist/templates/jl-auth-layout.js +1 -1
  113. package/dist/templates/jl-page.js +3 -3
  114. package/dist/templates/jl-split-view.js +5 -4
  115. package/dist/types/jl-app-icon.types.d.ts +5 -0
  116. package/dist/types/jl-chip-group.types.d.ts +3 -3
  117. package/dist/types/jl-command-palette.types.d.ts +17 -6
  118. package/dist/types/jl-facts.types.d.ts +17 -0
  119. package/dist/types/jl-menu.types.d.ts +4 -4
  120. package/dist/types/jl-radio-group.types.d.ts +6 -3
  121. package/dist/types/jl-segmented.types.d.ts +6 -3
  122. package/dist/types/jl-select.types.d.ts +6 -3
  123. package/dist/types/jl-side-nav.types.d.ts +11 -6
  124. package/dist/types/jl-steps.types.d.ts +2 -0
  125. package/dist/types/jl-tab-bar.types.d.ts +6 -3
  126. package/dist/types/jl-table.types.d.ts +42 -9
  127. package/dist/types/jl-toaster.types.d.ts +42 -1
  128. package/dist/types/jl-tree.types.d.ts +26 -0
  129. package/dist/types/texts.types.d.ts +5 -0
  130. package/package.json +3 -3
@@ -2,8 +2,10 @@ import { BASE_STYLES } from "../styles/shared.js";
2
2
  import { JlElement } from "../base/jl-element.js";
3
3
  import { jsonOf } from "../lib/attributes.js";
4
4
  import { registerIcons } from "../lib/icons.js";
5
+ import { jlText } from "../lib/texts.js";
5
6
  import { JlIcon } from "../atoms/jl-icon.js";
6
7
  import { setOrRemove } from "../lib/dom.js";
8
+ import { JlSpinner } from "../atoms/jl-spinner.js";
7
9
  import { highlightSegments } from "../lib/fuzzy.js";
8
10
  import { hotkeyLabels, isApplePlatform, matchesHotkey, parseHotkey } from "../lib/hotkey.js";
9
11
  import { groupMatches, matchCommands } from "../lib/palette.js";
@@ -15,10 +17,8 @@ import { jsx, jsxs } from "@jadis/core/jsx-runtime";
15
17
  registerIcons({ search: Search });
16
18
  var DEFAULT_HOTKEY = "mod+k";
17
19
  var NO_HOTKEY = "none";
18
- var DEFAULT_PLACEHOLDER = "Type a command or search…";
19
- var DEFAULT_EMPTY_TEXT = "No matching commands";
20
- var DEFAULT_LABEL = "Command palette";
21
20
  var SEARCH_ICON_SIZE = 18;
21
+ var DEFAULT_DEBOUNCE_MS = 250;
22
22
  var OPTION_ICON_SIZE = 16;
23
23
  /** How far each key moves the active command. */
24
24
  var MOVES = /* @__PURE__ */ new Map([["ArrowDown", 1], ["ArrowUp", -1]]);
@@ -34,29 +34,40 @@ 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";
42
+ /** `search`: what was typed, once typing pauses (and empty when it opens), for a page that answers it. */
40
43
  events = this.useEvents();
41
44
  commands = this.useChange([], () => this.renderResults(), {
42
45
  attribute: "commands",
43
46
  parse: jsonOf([])
44
47
  });
45
48
  open = this.useChange(false, (value) => this.renderOpen(value), { attribute: "open" });
46
- placeholder = this.useChange(DEFAULT_PLACEHOLDER, (value) => {
49
+ placeholder = this.useChange(jlText("commandPlaceholder"), (value) => {
47
50
  this._refs.input.placeholder = value;
48
51
  }, { attribute: "placeholder" });
49
52
  /** The keys that open and close it from anywhere on the page; `none` for no keys. `mod` is ⌘ or Ctrl. */
50
53
  hotkey = this.useChange(DEFAULT_HOTKEY, () => this.renderHotkey(), { attribute: "hotkey" });
51
54
  /** What it says when nothing matches. */
52
- emptyText = this.useChange(DEFAULT_EMPTY_TEXT, (value) => {
55
+ emptyText = this.useChange(jlText("noCommands"), (value) => {
53
56
  this._refs.empty.textContent = value;
54
57
  }, { attribute: "empty-text" });
58
+ /** How long typing pauses, in milliseconds, before `search` fires. */
59
+ debounce = this.useChange(DEFAULT_DEBOUNCE_MS, () => void 0, { attribute: "debounce" });
60
+ /** Shows a spinner in place of the search icon, while the page looks for what was typed. */
61
+ loading = this.useChange(false, (value) => {
62
+ this._refs.searchIcon.hidden = value;
63
+ this._refs.spinner.hidden = !value;
64
+ }, { attribute: "loading" });
55
65
  /** The dialog's name for screen readers. */
56
- label = this.useChange(DEFAULT_LABEL, (value) => this._refs.dialog.setAttribute("aria-label", value), { attribute: "label" });
66
+ label = this.useChange(jlText("commandPalette"), (value) => this._refs.dialog.setAttribute("aria-label", value), { attribute: "label" });
57
67
  _state = {
58
68
  active: 0,
59
- matches: []
69
+ matches: [],
70
+ timer: 0
60
71
  };
61
72
  _refs = this.useRefs((ref) => ({
62
73
  dialog: ref("dialog"),
@@ -64,7 +75,9 @@ var JlCommandPalette = class extends JlElement {
64
75
  hotkeyHint: ref(".hotkey-hint"),
65
76
  hotkeyKeys: ref(".hotkey-keys"),
66
77
  input: ref("input"),
67
- results: ref(".results")
78
+ results: ref(".results"),
79
+ searchIcon: ref(".search-icon"),
80
+ spinner: ref(JlSpinner)
68
81
  }));
69
82
  show() {
70
83
  this.open.set(true);
@@ -84,6 +97,11 @@ var JlCommandPalette = class extends JlElement {
84
97
  name: "search",
85
98
  size: SEARCH_ICON_SIZE
86
99
  }),
100
+ /* @__PURE__ */ jsx(JlSpinner, {
101
+ class: "search-spinner",
102
+ size: SEARCH_ICON_SIZE,
103
+ hidden: true
104
+ }),
87
105
  /* @__PURE__ */ jsx("input", {
88
106
  type: "text",
89
107
  role: "combobox",
@@ -103,7 +121,7 @@ var JlCommandPalette = class extends JlElement {
103
121
  class: "results",
104
122
  id: "results",
105
123
  role: "listbox",
106
- "aria-label": "Commands"
124
+ "aria-label": jlText("commands")
107
125
  }),
108
126
  /* @__PURE__ */ jsx("p", {
109
127
  class: "empty",
@@ -144,6 +162,7 @@ var JlCommandPalette = class extends JlElement {
144
162
  this.on(input, "input", (event) => {
145
163
  event.stopPropagation();
146
164
  this.renderResults();
165
+ this.scheduleSearch();
147
166
  });
148
167
  this.on(input, "keydown", (event) => this.navigate(event));
149
168
  this.on(this._refs.results, "pointermove", (event) => {
@@ -208,11 +227,20 @@ var JlCommandPalette = class extends JlElement {
208
227
  }
209
228
  this._refs.input.value = "";
210
229
  this.renderResults();
230
+ this.search("");
211
231
  dialog.showModal();
212
232
  this._refs.input.focus();
213
233
  this.reflect("open", true);
214
234
  this.events.emit("open");
215
235
  }
236
+ scheduleSearch() {
237
+ window.clearTimeout(this._state.timer);
238
+ this._state.timer = window.setTimeout(() => this.search(this._refs.input.value), this.debounce.get());
239
+ }
240
+ search(query) {
241
+ window.clearTimeout(this._state.timer);
242
+ this.events.emit("search", query);
243
+ }
216
244
  renderHotkey() {
217
245
  const hotkey = this.hotkey.get();
218
246
  const none = hotkey === "" || hotkey === NO_HOTKEY;
@@ -265,6 +293,10 @@ var JlCommandPalette = class extends JlElement {
265
293
  class: "option-label",
266
294
  children: highlighted(command.label, match.positions)
267
295
  }),
296
+ command.description ? /* @__PURE__ */ jsx("span", {
297
+ class: "option-description",
298
+ children: command.description
299
+ }) : null,
268
300
  command.shortcut === void 0 ? null : /* @__PURE__ */ jsx("span", {
269
301
  class: "keys",
270
302
  children: keycaps(command.shortcut)
@@ -2,6 +2,7 @@ import { BASE_STYLES } from "../styles/shared.js";
2
2
  import { JlElement } from "../base/jl-element.js";
3
3
  import { oneOf } from "../lib/attributes.js";
4
4
  import { define } from "../lib/define.js";
5
+ import { jlText } from "../lib/texts.js";
5
6
  import { JlButton } from "../atoms/jl-button.js";
6
7
  import jl_confirm_default from "./jl-confirm.css_raw.js";
7
8
  import { JlDialog } from "./jl-dialog.js";
@@ -46,7 +47,7 @@ var JlConfirm = class extends JlElement {
46
47
  _refs = this.useRefs((ref) => ({
47
48
  cancel: ref(".cancel"),
48
49
  confirm: ref(".confirm"),
49
- dialog: ref("jl-dialog"),
50
+ dialog: ref(JlDialog),
50
51
  text: ref(".text")
51
52
  }));
52
53
  /** Opens the question; resolves `true` when confirmed, `false` otherwise. Asking again while open waits for the same answer. */
@@ -130,9 +131,6 @@ function confirmDialog(options) {
130
131
  return element.ask().finally(() => element.remove());
131
132
  }
132
133
  var LEAVE_HEADING = "Leave without saving?";
133
- var LEAVE_TEXT = "Your changes are lost.";
134
- var LEAVE_LABEL = "Leave";
135
- var STAY_LABEL = "Keep editing";
136
134
  /**
137
135
  * Guards a form or an editor against leaving with changes not saved. Closing or reloading the tab asks the
138
136
  * browser's own question; the function it returns asks in the page, for the app's router to call before it moves
@@ -147,10 +145,10 @@ function guardLeave(options) {
147
145
  return () => {
148
146
  if (options.signal.aborted || !options.isDirty()) return Promise.resolve(true);
149
147
  asking.pending ??= confirmDialog({
150
- cancelLabel: options.stayLabel ?? STAY_LABEL,
151
- confirmLabel: options.leaveLabel ?? LEAVE_LABEL,
148
+ cancelLabel: options.stayLabel ?? jlText("stay"),
149
+ confirmLabel: options.leaveLabel ?? jlText("leave"),
152
150
  heading: options.heading ?? LEAVE_HEADING,
153
- text: options.text ?? LEAVE_TEXT,
151
+ text: options.text ?? jlText("leaveText"),
154
152
  tone: "danger"
155
153
  }).finally(() => {
156
154
  asking.pending = null;
@@ -2,6 +2,7 @@ import { BASE_STYLES } from "../styles/shared.js";
2
2
  import { JlElement } from "../base/jl-element.js";
3
3
  import { oneOf } from "../lib/attributes.js";
4
4
  import { registerIcons } from "../lib/icons.js";
5
+ import { jlText } from "../lib/texts.js";
5
6
  import { JlButton } from "../atoms/jl-button.js";
6
7
  import jl_dialog_default from "./jl-dialog.css_raw.js";
7
8
  import { css } from "@jadis/core";
@@ -67,7 +68,7 @@ var JlDialog = class extends JlElement {
67
68
  class: "close",
68
69
  variant: "ghost",
69
70
  icon: "x",
70
- hint: "Close",
71
+ hint: jlText("close"),
71
72
  size: "sm"
72
73
  })] }),
73
74
  /* @__PURE__ */ jsx("div", {
@@ -2,6 +2,7 @@ import { BASE_STYLES } from "../styles/shared.js";
2
2
  import { JlElement } from "../base/jl-element.js";
3
3
  import { oneOf } from "../lib/attributes.js";
4
4
  import { registerIcons } from "../lib/icons.js";
5
+ import { jlText } from "../lib/texts.js";
5
6
  import { JlButton } from "../atoms/jl-button.js";
6
7
  import jl_drawer_default from "./jl-drawer.css_raw.js";
7
8
  import { css } from "@jadis/core";
@@ -85,7 +86,7 @@ var JlDrawer = class extends JlElement {
85
86
  class: "close",
86
87
  variant: "ghost",
87
88
  icon: "x",
88
- hint: "Close",
89
+ hint: jlText("close"),
89
90
  size: "sm"
90
91
  })]
91
92
  })] }),
@@ -2,6 +2,7 @@ import { BASE_STYLES } from "../styles/shared.js";
2
2
  import { JlElement } from "../base/jl-element.js";
3
3
  import { jsonOf } from "../lib/attributes.js";
4
4
  import { registerIcons } from "../lib/icons.js";
5
+ import { jlText } from "../lib/texts.js";
5
6
  import { JlIcon } from "../atoms/jl-icon.js";
6
7
  import { setOrRemove, svgElement } from "../lib/dom.js";
7
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";
@@ -26,7 +27,6 @@ var EMPTY = {
26
27
  nodes: []
27
28
  };
28
29
  var IDLE = { kind: "idle" };
29
- var DEFAULT_LABEL = "Flow";
30
30
  var DOT_SPACING = 20;
31
31
  var WHEEL_ZOOM_SPEED = .0018;
32
32
  var CLICK_TOLERANCE = 4;
@@ -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 || DEFAULT_LABEL), { attribute: "label" });
119
+ label = this.useChange("", (value) => this._refs.viewport.setAttribute("aria-label", value || jlText("flow")), { attribute: "label" });
120
120
  _state = {
121
121
  edge: "",
122
122
  fitted: false,
@@ -203,7 +203,7 @@ var JlFlow = class extends JlElement {
203
203
  class: "remove-edge",
204
204
  "data-control": "",
205
205
  hidden: true,
206
- "aria-label": "Remove this edge",
206
+ "aria-label": jlText("removeEdge"),
207
207
  children: /* @__PURE__ */ jsx(JlIcon, {
208
208
  name: "x",
209
209
  size: ADD_ICON_SIZE
@@ -227,8 +227,8 @@ var JlFlow = class extends JlElement {
227
227
  /* @__PURE__ */ jsx("button", {
228
228
  type: "button",
229
229
  class: "control zoom-out",
230
- title: "Zoom out",
231
- "aria-label": "Zoom out",
230
+ title: jlText("zoomOut"),
231
+ "aria-label": jlText("zoomOut"),
232
232
  children: /* @__PURE__ */ jsx(JlIcon, {
233
233
  name: "minus",
234
234
  size: CONTROL_ICON_SIZE
@@ -238,8 +238,8 @@ var JlFlow = class extends JlElement {
238
238
  /* @__PURE__ */ jsx("button", {
239
239
  type: "button",
240
240
  class: "control zoom-in",
241
- title: "Zoom in",
242
- "aria-label": "Zoom in",
241
+ title: jlText("zoomIn"),
242
+ "aria-label": jlText("zoomIn"),
243
243
  children: /* @__PURE__ */ jsx(JlIcon, {
244
244
  name: "plus",
245
245
  size: CONTROL_ICON_SIZE
@@ -248,8 +248,8 @@ var JlFlow = class extends JlElement {
248
248
  /* @__PURE__ */ jsx("button", {
249
249
  type: "button",
250
250
  class: "control fit",
251
- title: "Show every node",
252
- "aria-label": "Show every node",
251
+ title: jlText("fitView"),
252
+ "aria-label": jlText("fitView"),
253
253
  children: /* @__PURE__ */ jsx(JlIcon, {
254
254
  name: "maximize",
255
255
  size: CONTROL_ICON_SIZE
@@ -258,8 +258,8 @@ var JlFlow = class extends JlElement {
258
258
  /* @__PURE__ */ jsx("button", {
259
259
  type: "button",
260
260
  class: "control tidy",
261
- title: "Tidy up the layout",
262
- "aria-label": "Tidy up the layout",
261
+ title: jlText("tidyLayout"),
262
+ "aria-label": jlText("tidyLayout"),
263
263
  children: /* @__PURE__ */ jsx(JlIcon, {
264
264
  name: "wand-sparkles",
265
265
  size: CONTROL_ICON_SIZE
@@ -671,7 +671,7 @@ var JlFlow = class extends JlElement {
671
671
  const element = /* @__PURE__ */ jsxs("span", {
672
672
  class: "port",
673
673
  "data-port": port.id,
674
- title: "Drag to another node to connect",
674
+ title: jlText("dragToConnect"),
675
675
  attrs: { part: "port" },
676
676
  children: [
677
677
  /* @__PURE__ */ jsx("span", { class: "dot" }),
@@ -2,6 +2,7 @@ import { BASE_STYLES } from "../styles/shared.js";
2
2
  import { JlElement } from "../base/jl-element.js";
3
3
  import { jsonOf } from "../lib/attributes.js";
4
4
  import { registerIcons } from "../lib/icons.js";
5
+ import { jlText } from "../lib/texts.js";
5
6
  import { JlIcon } from "../atoms/jl-icon.js";
6
7
  import jl_navbar_default from "./jl-navbar.css_raw.js";
7
8
  import { css } from "@jadis/core";
@@ -13,7 +14,6 @@ registerIcons({
13
14
  x: X
14
15
  });
15
16
  var ICON_SIZE = 18;
16
- var DEFAULT_LABEL = "Main";
17
17
  var MENU_ICON = "menu";
18
18
  var CLOSE_ICON = "x";
19
19
  /**
@@ -30,9 +30,9 @@ 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(DEFAULT_LABEL, (value) => {
34
- this._refs.links.setAttribute("aria-label", value || DEFAULT_LABEL);
35
- this._refs.drawer.setAttribute("aria-label", value || DEFAULT_LABEL);
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
36
  }, { attribute: "label" });
37
37
  _refs = this.useRefs((ref) => ({
38
38
  drawer: ref(".drawer"),
@@ -65,7 +65,7 @@ var JlNavbar = class extends JlElement {
65
65
  class: "toggle",
66
66
  "aria-expanded": "false",
67
67
  "aria-controls": "drawer",
68
- "aria-label": "Menu",
68
+ "aria-label": jlText("menu"),
69
69
  children: /* @__PURE__ */ jsx(JlIcon, {
70
70
  name: MENU_ICON,
71
71
  size: ICON_SIZE
@@ -112,7 +112,7 @@ var JlNavbar = class extends JlElement {
112
112
  setDrawer(open) {
113
113
  this._refs.drawer.hidden = !open;
114
114
  this._refs.toggle.setAttribute("aria-expanded", String(open));
115
- this._refs.toggle.setAttribute("aria-label", open ? "Close the menu" : "Menu");
115
+ this._refs.toggle.setAttribute("aria-label", open ? jlText("closeMenu") : jlText("menu"));
116
116
  this._refs.toggleIcon.name.set(open ? CLOSE_ICON : MENU_ICON);
117
117
  this.reflect("expanded", open);
118
118
  }
@@ -1,3 +1,3 @@
1
1
  // src/organisms/jl-side-nav.css?raw
2
- var jl_side_nav_default = ":host {\n display: block;\n width: var(--width, 248px);\n height: 100%;\n min-height: 0;\n transition: width var(--jl-slow) var(--jl-ease);\n}\n\n:host([collapsed]) {\n width: var(--rail-width, 60px);\n}\n\nnav {\n display: flex;\n flex-direction: column;\n gap: 8px;\n height: 100%;\n padding: 12px 8px;\n overflow-x: hidden;\n overflow-y: auto;\n color: var(--jl-text-2);\n font-size: var(--jl-font-md);\n}\n\n::slotted([slot=\"footer\"]) {\n margin-top: auto;\n}\n\n.sections {\n display: grid;\n gap: 14px;\n}\n\n.section {\n display: grid;\n gap: 2px;\n}\n\n.section-label {\n padding: 4px 10px 6px;\n color: var(--jl-muted);\n font-size: 11px;\n font-weight: 650;\n letter-spacing: 0.08em;\n text-transform: uppercase;\n white-space: nowrap;\n}\n\n.items,\n.children {\n display: grid;\n gap: 2px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.children {\n margin-top: 2px;\n}\n\n.entry {\n position: relative;\n}\n\n.item {\n display: flex;\n align-items: center;\n gap: 10px;\n width: 100%;\n min-height: 34px;\n padding: 0 10px;\n border: none;\n border-radius: var(--jl-radius-sm);\n background: none;\n color: inherit;\n font: inherit;\n font-weight: 550;\n text-align: start;\n text-decoration: none;\n white-space: nowrap;\n cursor: pointer;\n transition:\n background var(--jl-fast) var(--jl-ease),\n color var(--jl-fast) var(--jl-ease);\n}\n\n.item[data-depth=\"1\"] {\n padding-left: 36px;\n}\n\n.item[data-depth=\"2\"] {\n padding-left: 50px;\n}\n\n.item[data-depth=\"3\"] {\n padding-left: 64px;\n}\n\n.item:hover {\n background: var(--jl-surface-3);\n color: var(--jl-text);\n}\n\n.item[aria-current=\"page\"] {\n background: var(--jl-accent-soft);\n color: var(--jl-accent);\n}\n\n.item.holds-active {\n color: var(--jl-text);\n}\n\n.item-icon {\n color: var(--jl-faint);\n}\n\n.item:hover .item-icon,\n.item.holds-active .item-icon {\n color: var(--jl-text-2);\n}\n\n.item[aria-current=\"page\"] .item-icon {\n color: var(--jl-accent);\n}\n\n.item-initial {\n display: none;\n flex: none;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n border-radius: var(--jl-radius-xs);\n background: var(--jl-surface-3);\n color: var(--jl-text-2);\n font-size: 11px;\n font-weight: 700;\n}\n\n/* Nested items without an icon line their labels up under their parent's label. */\n.item:not([data-depth=\"0\"]) .item-initial {\n display: none;\n}\n.item-label {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.item-badge {\n flex: none;\n min-width: 20px;\n padding: 2px 6px;\n border-radius: var(--jl-radius-pill);\n background: var(--jl-surface-3);\n color: var(--jl-text-2);\n font-size: 11px;\n font-weight: 650;\n line-height: 14px;\n text-align: center;\n}\n\n.item[aria-current=\"page\"] .item-badge {\n background: var(--jl-accent);\n color: var(--jl-on-accent);\n}\n\n.expander jl-icon {\n transition: transform var(--jl-fast) var(--jl-ease);\n}\n\n.chevron {\n color: var(--jl-faint);\n transition: transform var(--jl-fast) var(--jl-ease);\n}\n\n.entry.open > .item .chevron,\n.entry.open > .expander jl-icon {\n transform: rotate(90deg);\n}\n\n/* The chevron of a parent that is also a link: its own button, over the end of the row. */\n.expander {\n position: absolute;\n top: 5px;\n right: 6px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n padding: 0;\n border: none;\n border-radius: var(--jl-radius-xs);\n background: none;\n color: var(--jl-faint);\n cursor: pointer;\n}\n\n.expander:hover {\n background: var(--jl-surface-3);\n color: var(--jl-text);\n}\n\n.entry:has(> .expander) > .item {\n padding-right: 36px;\n}\n\n/* The rail: icons only, centred; labels stay for screen readers, and show as tooltips. */\n:host([collapsed]) .section-label {\n height: 1px;\n margin: 4px 10px;\n padding: 0;\n overflow: hidden;\n background: var(--jl-line);\n color: transparent;\n}\n\n:host([collapsed]) .section:first-child .section-label {\n display: none;\n}\n\n:host([collapsed]) .item {\n justify-content: center;\n padding: 0;\n}\n\n:host([collapsed]) .item-label {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n}\n\n:host([collapsed]) .item-initial {\n display: inline-flex;\n}\n\n:host([collapsed]) .item-badge {\n position: absolute;\n top: 5px;\n right: 9px;\n min-width: 0;\n width: 8px;\n height: 8px;\n padding: 0;\n overflow: hidden;\n background: var(--jl-accent);\n color: transparent;\n}\n\n:host([collapsed]) .children {\n display: none;\n}\n";
2
+ var jl_side_nav_default = ":host {\n display: block;\n width: var(--width, 248px);\n height: 100%;\n min-height: 0;\n transition: width var(--jl-slow) var(--jl-ease);\n}\n\n:host([rail]) {\n width: var(--rail-width, 60px);\n}\n\nnav {\n display: flex;\n flex-direction: column;\n gap: 8px;\n height: 100%;\n padding: 12px 8px;\n overflow-x: hidden;\n overflow-y: auto;\n color: var(--jl-text-2);\n font-size: var(--jl-font-md);\n}\n\n/* The footer and the fold button keep to the bottom; the button is centred in the rail. */\n.bottom {\n display: flex;\n flex-direction: column;\n gap: 8px;\n margin-top: auto;\n}\n\n.fold {\n align-self: flex-start;\n}\n\n:host([rail]) .fold {\n align-self: center;\n}\n\n.sections {\n display: grid;\n gap: 14px;\n}\n\n.section {\n display: grid;\n gap: 2px;\n}\n\n.section-label {\n padding: 4px 10px 6px;\n color: var(--jl-muted);\n font-size: 11px;\n font-weight: 650;\n letter-spacing: 0.08em;\n text-transform: uppercase;\n white-space: nowrap;\n}\n\n.items,\n.children {\n display: grid;\n gap: 2px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.children {\n margin-top: 2px;\n}\n\n.entry {\n position: relative;\n}\n\n.item {\n display: flex;\n align-items: center;\n gap: 10px;\n width: 100%;\n min-height: 34px;\n padding: 0 10px;\n border: none;\n border-radius: var(--jl-radius-sm);\n background: none;\n color: inherit;\n font: inherit;\n font-weight: 550;\n text-align: start;\n text-decoration: none;\n white-space: nowrap;\n cursor: pointer;\n transition:\n background var(--jl-fast) var(--jl-ease),\n color var(--jl-fast) var(--jl-ease);\n}\n\n.item[data-depth=\"1\"] {\n padding-left: 36px;\n}\n\n.item[data-depth=\"2\"] {\n padding-left: 50px;\n}\n\n.item[data-depth=\"3\"] {\n padding-left: 64px;\n}\n\n.item:hover {\n background: var(--jl-surface-3);\n color: var(--jl-text);\n}\n\n.item[aria-current=\"page\"] {\n background: var(--jl-accent-soft);\n color: var(--jl-accent);\n}\n\n.item.holds-active {\n color: var(--jl-text);\n}\n\n.item-icon {\n color: var(--jl-faint);\n}\n\n.item:hover .item-icon,\n.item.holds-active .item-icon {\n color: var(--jl-text-2);\n}\n\n.item[aria-current=\"page\"] .item-icon {\n color: var(--jl-accent);\n}\n\n.item-initial {\n display: none;\n flex: none;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n border-radius: var(--jl-radius-xs);\n background: var(--jl-surface-3);\n color: var(--jl-text-2);\n font-size: 11px;\n font-weight: 700;\n}\n\n/* Nested items without an icon line their labels up under their parent's label. */\n.item:not([data-depth=\"0\"]) .item-initial {\n display: none;\n}\n.item-label {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.item-badge {\n flex: none;\n min-width: 20px;\n padding: 2px 6px;\n border-radius: var(--jl-radius-pill);\n background: var(--jl-surface-3);\n color: var(--jl-text-2);\n font-size: 11px;\n font-weight: 650;\n line-height: 14px;\n text-align: center;\n}\n\n.item[aria-current=\"page\"] .item-badge {\n background: var(--jl-accent);\n color: var(--jl-on-accent);\n}\n\n.expander jl-icon {\n transition: transform var(--jl-fast) var(--jl-ease);\n}\n\n.chevron {\n color: var(--jl-faint);\n transition: transform var(--jl-fast) var(--jl-ease);\n}\n\n.entry.open > .item .chevron,\n.entry.open > .expander jl-icon {\n transform: rotate(90deg);\n}\n\n/* The chevron of a parent that is also a link: its own button, over the end of the row. */\n.expander {\n position: absolute;\n top: 5px;\n right: 6px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n padding: 0;\n border: none;\n border-radius: var(--jl-radius-xs);\n background: none;\n color: var(--jl-faint);\n cursor: pointer;\n}\n\n.expander:hover {\n background: var(--jl-surface-3);\n color: var(--jl-text);\n}\n\n.entry:has(> .expander) > .item {\n padding-right: 36px;\n}\n\n/* The rail: icons only, centred; labels stay for screen readers, and show as tooltips. */\n:host([rail]) .section-label {\n height: 1px;\n margin: 4px 10px;\n padding: 0;\n overflow: hidden;\n background: var(--jl-line);\n color: transparent;\n}\n\n:host([rail]) .section:first-child .section-label {\n display: none;\n}\n\n:host([rail]) .item {\n justify-content: center;\n padding: 0;\n}\n\n:host([rail]) .item-label {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n}\n\n:host([rail]) .item-initial {\n display: inline-flex;\n}\n\n:host([rail]) .item-badge {\n position: absolute;\n top: 5px;\n right: 9px;\n min-width: 0;\n width: 8px;\n height: 8px;\n padding: 0;\n overflow: hidden;\n background: var(--jl-accent);\n color: transparent;\n}\n\n:host([rail]) .children {\n display: none;\n}\n";
3
3
  export { jl_side_nav_default as default };
@@ -3,27 +3,54 @@ import type { SideNavSection } from '../types/jl-side-nav.types';
3
3
  /**
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
- * the labels as tooltips. Items with an `href` are links; the others fire `select`.
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`. Typed by its ids, `JlSideNav<'jobs' | 'people'>` takes items of
8
+ * those ids and gives `select` one of them.
7
9
  */
8
- export declare class JlSideNav extends JlElement {
10
+ export declare class JlSideNav<Id extends string = string> extends JlElement {
9
11
  static readonly selector = "jl-side-nav";
12
+ /** `collapse`: people folded the side nav into its rail (true) or unfolded it (false), for the app to remember. */
10
13
  readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
11
- select: string;
14
+ select: Id;
15
+ collapse: boolean;
12
16
  }>>;
13
17
  readonly sections: Readonly<Readonly<{
14
- get(): SideNavSection[];
15
- set(setter: SideNavSection[] | ((prevState: SideNavSection[]) => SideNavSection[])): void;
18
+ get(): SideNavSection<Id>[];
19
+ set(setter: SideNavSection<Id>[] | ((prevState: SideNavSection<Id>[]) => SideNavSection<Id>[])): void;
16
20
  }>>;
17
21
  /** The id of the active item. */
18
22
  readonly value: Readonly<Readonly<{
19
- get(): string;
20
- set(setter: string | ((prevState: string) => string)): void;
23
+ get(): "" | Id;
24
+ set(setter: "" | Id | ((prevState: "" | Id) => "" | Id)): void;
21
25
  }>>;
22
26
  /** Shows only the icons, in a narrow rail; the labels become tooltips. */
23
27
  readonly collapsed: Readonly<Readonly<{
24
28
  get(): boolean;
25
29
  set(setter: boolean | ((prevState: boolean) => boolean)): void;
26
30
  }>>;
31
+ /** Adds a button at the bottom that folds the side nav into its rail and unfolds it. */
32
+ readonly collapsible: Readonly<Readonly<{
33
+ get(): boolean;
34
+ set(setter: boolean | ((prevState: boolean) => boolean)): void;
35
+ }>>;
36
+ /** The fold button's text while the side nav is open. */
37
+ readonly collapseLabel: Readonly<Readonly<{
38
+ get(): string;
39
+ set(setter: string | ((prevState: string) => string)): void;
40
+ }>>;
41
+ /** Its hint while the side nav is a rail. */
42
+ readonly expandLabel: Readonly<Readonly<{
43
+ get(): string;
44
+ set(setter: string | ((prevState: string) => string)): void;
45
+ }>>;
46
+ /**
47
+ * Set by `jl-app-shell` while the side nav is its drawer, on a narrow screen: the drawer shows it whole, and its
48
+ * fold button hides, `collapsed` waiting for a wide screen again.
49
+ */
50
+ readonly inDrawer: Readonly<Readonly<{
51
+ get(): boolean;
52
+ set(setter: boolean | ((prevState: boolean) => boolean)): void;
53
+ }>>;
27
54
  /** The name of the navigation for screen readers. */
28
55
  readonly label: Readonly<Readonly<{
29
56
  get(): string;
@@ -39,6 +66,12 @@ export declare class JlSideNav extends JlElement {
39
66
  /** Opens or closes a parent item. */
40
67
  toggleItem(id: string, force?: boolean): void;
41
68
  private onClick;
69
+ /** Whether it shows as the rail now: folded, and not in a drawer. */
70
+ private isRail;
71
+ private fold;
72
+ /** The rail, or the whole side nav: drawn again, said on the host (`rail`) for the styles and the page. */
73
+ private renderRail;
74
+ private renderFold;
42
75
  private choose;
43
76
  /** Up and Down move between the rows people can see, Right opens a parent, Left closes it or goes up to it. */
44
77
  private onKey;
@@ -1,20 +1,30 @@
1
1
  import { BASE_STYLES } from "../styles/shared.js";
2
2
  import { JlElement } from "../base/jl-element.js";
3
- import { jsonOf } from "../lib/attributes.js";
3
+ import { jsonOf, textOf } from "../lib/attributes.js";
4
4
  import { registerIcons } from "../lib/icons.js";
5
+ import { jlText } from "../lib/texts.js";
5
6
  import { JlIcon } from "../atoms/jl-icon.js";
6
7
  import { setOrRemove, uniqueId } from "../lib/dom.js";
8
+ import { JlButton } from "../atoms/jl-button.js";
7
9
  import { findItem, firstLeaf, pathInSections } from "../lib/nav-tree.js";
8
10
  import jl_side_nav_default from "./jl-side-nav.css_raw.js";
9
11
  import { css } from "@jadis/core";
10
- import { ChevronRight } from "lucide";
12
+ import { ChevronRight, PanelLeftClose, PanelLeftOpen } from "lucide";
11
13
  import { jsx, jsxs } from "@jadis/core/jsx-runtime";
12
14
  // src/organisms/jl-side-nav.tsx
13
- registerIcons({ "chevron-right": ChevronRight });
15
+ registerIcons({
16
+ "chevron-right": ChevronRight,
17
+ "panel-left-close": PanelLeftClose,
18
+ "panel-left-open": PanelLeftOpen
19
+ });
14
20
  var ICON_SIZE = 16;
15
21
  var CHEVRON_SIZE = 14;
16
- var DEFAULT_LABEL = "Main";
22
+ var COLLAPSE_ICON = "panel-left-close";
23
+ var EXPAND_ICON = "panel-left-open";
17
24
  var ROW_SELECTOR = ".item";
25
+ var NEW_TAB = "_blank";
26
+ var SAFE_REL = "noopener noreferrer";
27
+ var NO_ITEM = "";
18
28
  /** A JSON attribute that should hold a list of sections; anything else gives none. */
19
29
  var parseSections = (value) => {
20
30
  const parsed = jsonOf([])(value);
@@ -26,30 +36,48 @@ var isReachable = (row) => row.closest("[hidden]") === null && row.offsetParent
26
36
  /**
27
37
  * The navigation of an app, down its side: sections of items with icons, badges and nested items that open with
28
38
  * a chevron. `value` is the active item (its parents open to show it); `collapsed` makes it a rail of icons, with
29
- * the labels as tooltips. Items with an `href` are links; the others fire `select`.
39
+ * the labels as tooltips, and `collapsible` lets people fold and unfold it with a button at its bottom. Items with
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.
30
42
  */
31
43
  var JlSideNav = class extends JlElement {
32
44
  static selector = "jl-side-nav";
45
+ /** `collapse`: people folded the side nav into its rail (true) or unfolded it (false), for the app to remember. */
33
46
  events = this.useEvents();
34
47
  sections = this.useChange([], () => this.render(), {
35
48
  attribute: "sections",
36
49
  parse: parseSections
37
50
  });
38
51
  /** The id of the active item. */
39
- 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
+ });
40
56
  /** Shows only the icons, in a narrow rail; the labels become tooltips. */
41
57
  collapsed = this.useChange(false, (value) => {
42
58
  this.reflect("collapsed", value);
43
- this.render();
59
+ this.renderRail();
44
60
  }, { attribute: "collapsed" });
61
+ /** Adds a button at the bottom that folds the side nav into its rail and unfolds it. */
62
+ collapsible = this.useChange(false, () => this.renderFold(), { attribute: "collapsible" });
63
+ /** The fold button's text while the side nav is open. */
64
+ collapseLabel = this.useChange(jlText("collapseMenu"), () => this.renderFold(), { attribute: "collapse-label" });
65
+ /** Its hint while the side nav is a rail. */
66
+ expandLabel = this.useChange(jlText("expandMenu"), () => this.renderFold(), { attribute: "expand-label" });
67
+ /**
68
+ * Set by `jl-app-shell` while the side nav is its drawer, on a narrow screen: the drawer shows it whole, and its
69
+ * fold button hides, `collapsed` waiting for a wide screen again.
70
+ */
71
+ inDrawer = this.useChange(false, () => this.renderRail(), { attribute: "in-drawer" });
45
72
  /** The name of the navigation for screen readers. */
46
- label = this.useChange(DEFAULT_LABEL, (value) => {
47
- this._refs.nav.setAttribute("aria-label", value === "" ? DEFAULT_LABEL : value);
73
+ label = this.useChange(jlText("mainNavigation"), (value) => {
74
+ this._refs.nav.setAttribute("aria-label", value === "" ? jlText("mainNavigation") : value);
48
75
  }, { attribute: "label" });
49
76
  _prefix = uniqueId("jl-side-nav");
50
77
  /** The parents people opened, or that hold the active item. */
51
78
  _state = { open: /* @__PURE__ */ new Set() };
52
79
  _refs = this.useRefs((ref) => ({
80
+ fold: ref(JlButton),
53
81
  nav: ref("nav"),
54
82
  sections: ref(".sections")
55
83
  }));
@@ -59,7 +87,15 @@ var JlSideNav = class extends JlElement {
59
87
  children: [
60
88
  /* @__PURE__ */ jsx("slot", { name: "header" }),
61
89
  /* @__PURE__ */ jsx("div", { class: "sections" }),
62
- /* @__PURE__ */ jsx("slot", { name: "footer" })
90
+ /* @__PURE__ */ jsxs("div", {
91
+ class: "bottom",
92
+ children: [/* @__PURE__ */ jsx("slot", { name: "footer" }), /* @__PURE__ */ jsx(JlButton, {
93
+ class: "fold",
94
+ variant: "ghost",
95
+ size: "sm",
96
+ hidden: true
97
+ })]
98
+ })
63
99
  ]
64
100
  });
65
101
  }
@@ -67,6 +103,7 @@ var JlSideNav = class extends JlElement {
67
103
  return css`${BASE_STYLES}${jl_side_nav_default}`;
68
104
  }
69
105
  onConnect() {
106
+ this._refs.fold.events.register("press", () => this.fold());
70
107
  this.on(this._refs.sections, "click", (event) => this.onClick(event));
71
108
  this.on(this._refs.sections, "keydown", (event) => this.onKey(event));
72
109
  }
@@ -86,11 +123,34 @@ var JlSideNav = class extends JlElement {
86
123
  const row = target.closest(ROW_SELECTOR);
87
124
  const item = findItem(this.sections.get(), row?.dataset.id ?? "");
88
125
  if (item === null) return;
89
- if (hasChildren(item) && item.href === void 0 && !this.collapsed.get()) {
126
+ if (hasChildren(item) && item.href === void 0 && !this.isRail()) {
90
127
  this.toggleItem(item.id);
91
128
  return;
92
129
  }
93
- this.choose(row?.dataset.target ?? item.id);
130
+ this.choose(findItem(this.sections.get(), row?.dataset.target ?? "")?.id ?? item.id);
131
+ }
132
+ /** Whether it shows as the rail now: folded, and not in a drawer. */
133
+ isRail() {
134
+ return this.collapsed.get() && !this.inDrawer.get();
135
+ }
136
+ fold() {
137
+ const collapsed = !this.collapsed.get();
138
+ this.collapsed.set(collapsed);
139
+ this.events.emit("collapse", collapsed);
140
+ }
141
+ /** The rail, or the whole side nav: drawn again, said on the host (`rail`) for the styles and the page. */
142
+ renderRail() {
143
+ this.reflect("rail", this.isRail());
144
+ this.render();
145
+ this.renderFold();
146
+ }
147
+ renderFold() {
148
+ const fold = this._refs.fold;
149
+ const rail = this.isRail();
150
+ fold.hidden = !this.collapsible.get() || this.inDrawer.get();
151
+ fold.icon.set(rail ? EXPAND_ICON : COLLAPSE_ICON);
152
+ fold.label.set(rail ? "" : this.collapseLabel.get());
153
+ fold.hint.set(rail ? this.expandLabel.get() : "");
94
154
  }
95
155
  choose(id) {
96
156
  this.value.set(id);
@@ -117,7 +177,7 @@ var JlSideNav = class extends JlElement {
117
177
  }
118
178
  }
119
179
  openOrGoDown(id, row) {
120
- if (row.dataset.parent === void 0 || this.collapsed.get()) return;
180
+ if (row.dataset.parent === void 0 || this.isRail()) return;
121
181
  if (!this._state.open.has(id)) {
122
182
  this.toggleItem(id, true);
123
183
  return;
@@ -161,7 +221,7 @@ var JlSideNav = class extends JlElement {
161
221
  class: "entry",
162
222
  children: [
163
223
  this.rowNode(item, depth, childrenId),
164
- parent && item.href !== void 0 && !this.collapsed.get() ? /* @__PURE__ */ jsx("button", {
224
+ parent && item.href !== void 0 && !this.isRail() ? /* @__PURE__ */ jsx("button", {
165
225
  class: "expander",
166
226
  type: "button",
167
227
  "data-id": item.id,
@@ -187,7 +247,7 @@ var JlSideNav = class extends JlElement {
187
247
  * leaf, since its children cannot show there.
188
248
  */
189
249
  rowNode(item, depth, childrenId) {
190
- const collapsed = this.collapsed.get();
250
+ const collapsed = this.isRail();
191
251
  const parent = hasChildren(item);
192
252
  const target = collapsed ? firstLeaf(item) : item;
193
253
  const toggles = parent && item.href === void 0 && !collapsed;
@@ -202,6 +262,8 @@ var JlSideNav = class extends JlElement {
202
262
  };
203
263
  if (target.href !== void 0) return /* @__PURE__ */ jsx("a", {
204
264
  href: target.href,
265
+ target: target.target,
266
+ rel: target.target === NEW_TAB ? SAFE_REL : void 0,
205
267
  ...attributes,
206
268
  children: content
207
269
  });
@@ -259,7 +321,7 @@ var JlSideNav = class extends JlElement {
259
321
  if (opened.length > 0) this.renderOpen();
260
322
  for (const row of this._refs.sections.querySelectorAll(ROW_SELECTOR)) {
261
323
  const id = row.dataset.id ?? "";
262
- const active = id === value || this.collapsed.get() && row.dataset.target === value;
324
+ const active = id === value || this.isRail() && row.dataset.target === value;
263
325
  setOrRemove(row, "aria-current", active ? "page" : "");
264
326
  row.classList.toggle("holds-active", !active && path.includes(id));
265
327
  }