@syware/jlib 0.12.0 → 0.13.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 (142) hide show
  1. package/README.md +1 -1
  2. package/dist/atoms/jl-avatar.css.js +1 -1
  3. package/dist/atoms/jl-avatar.js +1 -8
  4. package/dist/atoms/jl-button.css.js +1 -1
  5. package/dist/atoms/jl-button.js +4 -6
  6. package/dist/atoms/jl-checkbox.css.js +1 -1
  7. package/dist/atoms/jl-checkbox.js +8 -10
  8. package/dist/atoms/jl-chip.css.js +1 -1
  9. package/dist/atoms/jl-chip.js +3 -11
  10. package/dist/atoms/jl-divider.css.js +1 -1
  11. package/dist/atoms/jl-divider.js +1 -5
  12. package/dist/atoms/jl-icon.css.js +1 -1
  13. package/dist/atoms/jl-icon.d.ts +2 -0
  14. package/dist/atoms/jl-icon.js +5 -1
  15. package/dist/atoms/jl-input.d.ts +7 -2
  16. package/dist/atoms/jl-input.js +36 -31
  17. package/dist/atoms/jl-link.css.js +1 -1
  18. package/dist/atoms/jl-link.js +3 -6
  19. package/dist/atoms/jl-rating.css.js +1 -1
  20. package/dist/atoms/jl-rating.d.ts +2 -2
  21. package/dist/atoms/jl-rating.js +17 -35
  22. package/dist/atoms/jl-select.d.ts +8 -3
  23. package/dist/atoms/jl-select.js +26 -13
  24. package/dist/atoms/jl-skeleton.d.ts +1 -0
  25. package/dist/atoms/jl-skeleton.js +4 -1
  26. package/dist/atoms/jl-slider.d.ts +4 -0
  27. package/dist/atoms/jl-slider.js +29 -15
  28. package/dist/atoms/jl-switch.css.js +1 -1
  29. package/dist/atoms/jl-switch.js +2 -8
  30. package/dist/atoms/jl-textarea.css.js +1 -1
  31. package/dist/atoms/jl-textarea.d.ts +4 -5
  32. package/dist/atoms/jl-textarea.js +15 -30
  33. package/dist/lib/calendar.js +3 -2
  34. package/dist/lib/floating.d.ts +10 -0
  35. package/dist/lib/floating.js +27 -8
  36. package/dist/lib/flow.d.ts +7 -3
  37. package/dist/lib/flow.js +19 -8
  38. package/dist/lib/indicator.d.ts +16 -0
  39. package/dist/lib/indicator.js +32 -6
  40. package/dist/lib/intl.d.ts +6 -0
  41. package/dist/lib/intl.js +19 -0
  42. package/dist/lib/palette.js +1 -6
  43. package/dist/lib/table.d.ts +14 -2
  44. package/dist/lib/table.js +50 -39
  45. package/dist/molecules/jl-accordion-item.css.js +1 -1
  46. package/dist/molecules/jl-accordion-item.js +1 -5
  47. package/dist/molecules/jl-account-button.css.js +1 -1
  48. package/dist/molecules/jl-account-button.js +1 -5
  49. package/dist/molecules/jl-alert.css.js +1 -1
  50. package/dist/molecules/jl-alert.d.ts +5 -5
  51. package/dist/molecules/jl-alert.js +4 -13
  52. package/dist/molecules/jl-avatar-group.d.ts +7 -5
  53. package/dist/molecules/jl-avatar-group.js +15 -5
  54. package/dist/molecules/jl-breadcrumb.d.ts +7 -4
  55. package/dist/molecules/jl-breadcrumb.js +32 -8
  56. package/dist/molecules/jl-calendar.d.ts +12 -3
  57. package/dist/molecules/jl-calendar.js +79 -48
  58. package/dist/molecules/jl-card.css.js +1 -1
  59. package/dist/molecules/jl-card.js +2 -8
  60. package/dist/molecules/jl-chip-group.css.js +1 -1
  61. package/dist/molecules/jl-chip-group.d.ts +6 -2
  62. package/dist/molecules/jl-chip-group.js +13 -18
  63. package/dist/molecules/jl-code-block.css.js +1 -1
  64. package/dist/molecules/jl-code-block.d.ts +7 -5
  65. package/dist/molecules/jl-code-block.js +19 -22
  66. package/dist/molecules/jl-combobox.css.js +1 -1
  67. package/dist/molecules/jl-combobox.d.ts +4 -0
  68. package/dist/molecules/jl-combobox.js +33 -19
  69. package/dist/molecules/jl-date-picker.d.ts +6 -0
  70. package/dist/molecules/jl-date-picker.js +29 -9
  71. package/dist/molecules/jl-empty.css.js +1 -1
  72. package/dist/molecules/jl-empty.js +4 -19
  73. package/dist/molecules/jl-field.css.js +1 -1
  74. package/dist/molecules/jl-field.d.ts +7 -1
  75. package/dist/molecules/jl-field.js +35 -23
  76. package/dist/molecules/jl-file-drop.css.js +1 -1
  77. package/dist/molecules/jl-file-drop.js +1 -3
  78. package/dist/molecules/jl-input-list.css.js +1 -1
  79. package/dist/molecules/jl-input-list.d.ts +12 -1
  80. package/dist/molecules/jl-input-list.js +81 -51
  81. package/dist/molecules/jl-list-item.css.js +1 -1
  82. package/dist/molecules/jl-list-item.d.ts +3 -1
  83. package/dist/molecules/jl-list-item.js +26 -27
  84. package/dist/molecules/jl-load-state.css.js +1 -1
  85. package/dist/molecules/jl-load-state.d.ts +6 -1
  86. package/dist/molecules/jl-load-state.js +15 -18
  87. package/dist/molecules/jl-menu.d.ts +1 -0
  88. package/dist/molecules/jl-menu.js +9 -2
  89. package/dist/molecules/jl-pagination.css.js +1 -1
  90. package/dist/molecules/jl-pagination.d.ts +7 -1
  91. package/dist/molecules/jl-pagination.js +43 -35
  92. package/dist/molecules/jl-search.css.js +1 -1
  93. package/dist/molecules/jl-search.js +4 -12
  94. package/dist/molecules/jl-segmented.css.js +1 -1
  95. package/dist/molecules/jl-segmented.d.ts +4 -2
  96. package/dist/molecules/jl-segmented.js +19 -26
  97. package/dist/molecules/jl-stat.css.js +1 -1
  98. package/dist/molecules/jl-stat.js +2 -8
  99. package/dist/molecules/jl-steps.d.ts +10 -3
  100. package/dist/molecules/jl-steps.js +82 -49
  101. package/dist/molecules/jl-tabs.d.ts +5 -2
  102. package/dist/molecules/jl-tabs.js +31 -25
  103. package/dist/molecules/jl-tag-input.css.js +1 -1
  104. package/dist/molecules/jl-tag-input.d.ts +13 -1
  105. package/dist/molecules/jl-tag-input.js +57 -30
  106. package/dist/molecules/jl-timeline.css.js +1 -1
  107. package/dist/molecules/jl-timeline.d.ts +3 -1
  108. package/dist/molecules/jl-timeline.js +9 -14
  109. package/dist/molecules/jl-toast.css.js +1 -1
  110. package/dist/molecules/jl-toast.js +2 -10
  111. package/dist/molecules/jl-tooltip.d.ts +2 -1
  112. package/dist/molecules/jl-tooltip.js +11 -15
  113. package/dist/organisms/jl-command-palette.css.js +1 -1
  114. package/dist/organisms/jl-command-palette.d.ts +8 -1
  115. package/dist/organisms/jl-command-palette.js +73 -42
  116. package/dist/organisms/jl-confirm.css.js +1 -1
  117. package/dist/organisms/jl-confirm.js +1 -5
  118. package/dist/organisms/jl-dialog.css.js +1 -1
  119. package/dist/organisms/jl-dialog.js +1 -5
  120. package/dist/organisms/jl-drawer.css.js +1 -1
  121. package/dist/organisms/jl-drawer.js +1 -3
  122. package/dist/organisms/jl-flow.d.ts +18 -2
  123. package/dist/organisms/jl-flow.js +128 -44
  124. package/dist/organisms/jl-navbar.css.js +1 -1
  125. package/dist/organisms/jl-navbar.d.ts +1 -1
  126. package/dist/organisms/jl-navbar.js +3 -5
  127. package/dist/organisms/jl-page-header.css.js +1 -1
  128. package/dist/organisms/jl-page-header.js +1 -5
  129. package/dist/organisms/jl-page-outlet.d.ts +4 -3
  130. package/dist/organisms/jl-page-outlet.js +7 -8
  131. package/dist/organisms/jl-side-nav.css.js +1 -1
  132. package/dist/organisms/jl-side-nav.d.ts +9 -2
  133. package/dist/organisms/jl-side-nav.js +44 -16
  134. package/dist/organisms/jl-tab-bar.css.js +1 -1
  135. package/dist/organisms/jl-tab-bar.js +0 -2
  136. package/dist/organisms/jl-table.css.js +1 -1
  137. package/dist/organisms/jl-table.d.ts +18 -6
  138. package/dist/organisms/jl-table.js +91 -57
  139. package/dist/organisms/jl-tree.css.js +1 -1
  140. package/dist/organisms/jl-tree.d.ts +22 -2
  141. package/dist/organisms/jl-tree.js +101 -41
  142. package/package.json +1 -1
@@ -28,6 +28,8 @@ var parseTextList = (value) => {
28
28
  const parsed = jsonOf([])(value);
29
29
  return Array.isArray(parsed) ? parsed.map(String) : [];
30
30
  };
31
+ /** The tag a chip shows. */
32
+ var chipTag = (chip) => chip.dataset.tag ?? "";
31
33
  var highlighted = (label, query) => matchParts(label, query).map((part) => part.matched ? /* @__PURE__ */ jsx("mark", { children: part.text }) : part.text);
32
34
  /**
33
35
  * A field that collects short texts as chips: Enter or a comma adds what was typed, Backspace in the empty field
@@ -36,7 +38,7 @@ var highlighted = (label, query) => matchParts(label, query).map((part) => part.
36
38
  var JlTagInput = class extends JlFormControl {
37
39
  static selector = "jl-tag-input";
38
40
  events = this.useEvents();
39
- value = this.useChange([], () => this.renderTags(), {
41
+ value = this.useChange([], (value) => this.renderValue(value), {
40
42
  attribute: "value",
41
43
  parse: parseTextList
42
44
  });
@@ -44,7 +46,7 @@ var JlTagInput = class extends JlFormControl {
44
46
  /** The field's name for screen readers, when no visible label names it. */
45
47
  label = this.useChange("", (value) => setOrRemove(this._refs.native, "aria-label", value), { attribute: "label" });
46
48
  /** The most tags the field takes; 0 for no limit. */
47
- max = this.useChange(NO_LIMIT, () => this.renderTags(), {
49
+ max = this.useChange(NO_LIMIT, () => this.renderFull(), {
48
50
  attribute: "max",
49
51
  parse: clampedNumber(NO_LIMIT, 0, Number.MAX_SAFE_INTEGER)
50
52
  });
@@ -120,7 +122,7 @@ var JlTagInput = class extends JlFormControl {
120
122
  return css`${BASE_STYLES}${CONTROL_STYLES}${FLOATING_STYLES}${jl_tag_input_default}`;
121
123
  }
122
124
  drawTexts() {
123
- this.renderTags();
125
+ for (const chip of this.chips()) this.nameRemoveButton(chip);
124
126
  this.renderValidity();
125
127
  }
126
128
  onConnect() {
@@ -205,7 +207,7 @@ var JlTagInput = class extends JlFormControl {
205
207
  onControlClick(event) {
206
208
  const remove = event.target.closest(".tag-remove");
207
209
  if (remove !== null) {
208
- this.removeAt(Number(remove.dataset.index));
210
+ this.removeAt(this.chipIndex(remove));
209
211
  this.focus();
210
212
  return;
211
213
  }
@@ -215,7 +217,7 @@ var JlTagInput = class extends JlFormControl {
215
217
  onTagKey(event) {
216
218
  const button = event.target.closest(".tag-remove");
217
219
  if (button === null) return;
218
- const index = Number(button.dataset.index);
220
+ const index = this.chipIndex(button);
219
221
  const handler = (/* @__PURE__ */ new Map([
220
222
  ["ArrowLeft", () => this.focusTag(Math.max(0, index - 1))],
221
223
  ["ArrowRight", () => this.focusTag(index + 1)],
@@ -279,7 +281,7 @@ var JlTagInput = class extends JlFormControl {
279
281
  }
280
282
  /** Focuses a chip's remove button; past the last chip, the field. */
281
283
  focusTag(index) {
282
- const button = this._refs.tags.querySelector(`.tag-remove[data-index="${index}"]`);
284
+ const button = this.chips()[index]?.querySelector(".tag-remove") ?? null;
283
285
  if (button === null) {
284
286
  this.focus();
285
287
  return;
@@ -288,10 +290,8 @@ var JlTagInput = class extends JlFormControl {
288
290
  }
289
291
  /** Points at the chips people tried to add again. */
290
292
  flash(duplicates) {
291
- const tags = this.value.get();
292
- for (const chip of this._refs.tags.querySelectorAll(".tag")) {
293
- const tag = tags[Number(chip.dataset.index)];
294
- if (tag === void 0 || !hasTag(duplicates, tag)) continue;
293
+ for (const chip of this.chips()) {
294
+ if (!hasTag(duplicates, chipTag(chip))) continue;
295
295
  chip.classList.add("flash");
296
296
  window.setTimeout(() => chip.classList.remove("flash"), FLASH_MS);
297
297
  }
@@ -354,11 +354,7 @@ var JlTagInput = class extends JlFormControl {
354
354
  }
355
355
  renderActive() {
356
356
  const active = this._state.active;
357
- for (const item of this._refs.listbox.querySelectorAll("[data-index]")) {
358
- const isActive = Number(item.dataset.index) === active;
359
- item.classList.toggle("active", isActive);
360
- item.setAttribute("aria-selected", String(isActive));
361
- }
357
+ for (const item of this._refs.listbox.querySelectorAll("[data-index]")) item.setAttribute("aria-selected", String(Number(item.dataset.index) === active));
362
358
  setOrRemove(this._refs.native, "aria-activedescendant", active === NONE ? "" : `${this._listId}-${active}`);
363
359
  }
364
360
  suggestionAt(event) {
@@ -379,32 +375,64 @@ var JlTagInput = class extends JlFormControl {
379
375
  setOrRemove(native, "aria-controls", offers ? this._listId : "");
380
376
  setOrRemove(native, "aria-expanded", offers ? String(this.isOpen()) : "");
381
377
  }
382
- renderTags() {
383
- const tags = this.value.get();
384
- const editable = !this.disabled.get();
385
- this._refs.tags.replaceChildren(...tags.map((tag, index) => /* @__PURE__ */ jsxs("li", {
378
+ renderValue(tags) {
379
+ this.renderChips(tags);
380
+ this.renderFull();
381
+ this.renderPlaceholder();
382
+ this.renderFormValue();
383
+ this.renderValidity();
384
+ }
385
+ /**
386
+ * Makes the chips match the tags: those of tags taken out go, a chip is made for each tag added, and the others stay
387
+ * as they are, so adding or removing a tag makes or removes one chip.
388
+ */
389
+ renderChips(tags) {
390
+ const list = this._refs.tags;
391
+ const kept = new Set(tags);
392
+ for (const chip of this.chips()) if (!kept.has(chipTag(chip))) chip.remove();
393
+ tags.forEach((tag, index) => {
394
+ const chips = this.chips();
395
+ const chip = chips[index];
396
+ if (chip !== void 0 && chipTag(chip) === tag) return;
397
+ const later = chips.slice(index + 1).find((other) => chipTag(other) === tag);
398
+ list.insertBefore(later ?? this.chip(tag), chip ?? null);
399
+ });
400
+ for (const extra of this.chips().slice(tags.length)) extra.remove();
401
+ }
402
+ /** A chip, its remove button hidden by the CSS while the field is disabled. */
403
+ chip(tag) {
404
+ const chip = /* @__PURE__ */ jsxs("li", {
386
405
  class: "tag",
387
- "data-index": String(index),
406
+ "data-tag": tag,
388
407
  children: [/* @__PURE__ */ jsx("span", {
389
408
  class: "tag-text",
390
409
  children: tag
391
- }), editable ? /* @__PURE__ */ jsx("button", {
410
+ }), /* @__PURE__ */ jsx("button", {
392
411
  class: "tag-remove",
393
412
  type: "button",
394
413
  tabIndex: -1,
395
- "aria-label": jlText("removeNamed", { name: tag }),
396
- "data-index": String(index),
397
414
  children: /* @__PURE__ */ jsx(JlIcon, {
398
415
  name: "x",
399
416
  size: REMOVE_ICON_SIZE
400
417
  })
401
- }) : null]
402
- })));
418
+ })]
419
+ });
420
+ this.nameRemoveButton(chip);
421
+ return chip;
422
+ }
423
+ nameRemoveButton(chip) {
424
+ chip.querySelector(".tag-remove")?.setAttribute("aria-label", jlText("removeNamed", { name: chipTag(chip) }));
425
+ }
426
+ chips() {
427
+ return [...this._refs.tags.children];
428
+ }
429
+ /** The place of the chip an element is in. */
430
+ chipIndex(element) {
431
+ return this.chips().findIndex((chip) => chip.contains(element));
432
+ }
433
+ renderFull() {
403
434
  const max = this.max.get();
404
- this.reflect("full", max !== NO_LIMIT && tags.length >= max);
405
- this.renderPlaceholder();
406
- this.renderFormValue();
407
- this.renderValidity();
435
+ this.reflect("full", max !== NO_LIMIT && this.value.get().length >= max);
408
436
  }
409
437
  /** The placeholder shows while there is no tag; chips take its place. */
410
438
  renderPlaceholder() {
@@ -433,7 +461,6 @@ var JlTagInput = class extends JlFormControl {
433
461
  this._refs.native.disabled = disabled;
434
462
  this.reflect("disabled", disabled);
435
463
  this.closeList();
436
- this.renderTags();
437
464
  }
438
465
  };
439
466
  JlTagInput.register();
@@ -1,3 +1,3 @@
1
1
  // src/molecules/jl-timeline.css?inline
2
- var jl_timeline_default = ":host{--marker:22px;--gap:20px;--title-size:var(--jl-font-md);display:block}:host([compact]){--marker:18px;--gap:12px;--title-size:var(--jl-font-sm)}.timeline{grid-template-columns:calc(var(--marker) + 12px) auto minmax(0, 1fr);margin:0;padding:0;list-style:none;display:grid}.event{grid-column:1/-1;grid-template-columns:calc(var(--marker) + 12px) auto minmax(0, 1fr);padding-bottom:var(--gap);--tone:var(--jl-muted);--soft:var(--jl-surface-3);display:grid;position:relative}@supports (grid-template-columns:subgrid){.event{grid-template-columns:subgrid}}.event:last-child{padding-bottom:0}.event[data-tone=accent]{--tone:var(--jl-accent);--soft:var(--jl-accent-soft)}.event[data-tone=ok]{--tone:var(--jl-ok);--soft:var(--jl-ok-soft)}.event[data-tone=warn]{--tone:var(--jl-warn);--soft:var(--jl-warn-soft)}.event[data-tone=danger]{--tone:var(--jl-danger);--soft:var(--jl-danger-soft)}.event[data-tone=info]{--tone:var(--jl-info);--soft:var(--jl-info-soft)}.event:not(:last-child):before{top:10px;bottom:-10px;left:calc(var(--marker) / 2 - .5px);background:var(--jl-line-strong);content:\"\";width:1px;position:absolute}.rail{width:var(--marker);z-index:1;grid-column:1;justify-content:center;align-items:center;height:20px;display:flex;position:relative}.marker{border-radius:50%;flex:none;justify-content:center;align-items:center;display:inline-flex}.dot{background:var(--tone);width:10px;height:10px;box-shadow:0 0 0 3px var(--jl-surface)}:host([compact]) .dot{width:8px;height:8px}.circle{width:var(--marker);height:var(--marker);border:1px solid color-mix(in srgb, var(--tone) 30%, var(--soft));background:var(--soft);color:var(--tone);box-shadow:0 0 0 3px var(--jl-surface)}.content{grid-column:3;gap:2px;display:grid}.title{color:var(--jl-text);font-size:var(--title-size);font-weight:600;line-height:20px}.time{color:var(--jl-muted);font-family:var(--jl-font-mono);font-size:var(--jl-font-xs);white-space:nowrap;grid-column:2;padding-right:12px;line-height:20px}.description{color:var(--jl-muted);font-size:var(--jl-font-sm);line-height:1.5}:host([compact]) .description{font-size:var(--jl-font-xs)}";
2
+ var jl_timeline_default = ":host{--marker:22px;--gap:20px;--title-size:var(--jl-font-md);display:block}:host([compact]){--marker:18px;--gap:12px;--title-size:var(--jl-font-sm)}.timeline{grid-template-columns:calc(var(--marker) + 12px) auto minmax(0, 1fr);margin:0;padding:0;list-style:none;display:grid}.event{grid-column:1/-1;grid-template-columns:calc(var(--marker) + 12px) auto minmax(0, 1fr);padding-bottom:var(--gap);--tone:var(--jl-muted);--soft:var(--jl-surface-3);display:grid;position:relative}@supports (grid-template-columns:subgrid){.event{grid-template-columns:subgrid}}.event:last-child{padding-bottom:0}.event[data-tone=accent]{--tone:var(--jl-accent);--soft:var(--jl-accent-soft)}.event[data-tone=ok]{--tone:var(--jl-ok);--soft:var(--jl-ok-soft)}.event[data-tone=warn]{--tone:var(--jl-warn);--soft:var(--jl-warn-soft)}.event[data-tone=danger]{--tone:var(--jl-danger);--soft:var(--jl-danger-soft)}.event[data-tone=info]{--tone:var(--jl-info);--soft:var(--jl-info-soft)}.event:not(:last-child):before{top:10px;bottom:-10px;left:calc(var(--marker) / 2 - .5px);background:var(--jl-line-strong);content:\"\";width:1px;position:absolute}.rail{width:var(--marker);z-index:1;grid-column:1;justify-content:center;align-items:center;height:20px;display:flex;position:relative}.marker{border-radius:50%;flex:none;justify-content:center;align-items:center;display:inline-flex}.dot{background:var(--tone);width:10px;height:10px;box-shadow:0 0 0 3px var(--jl-surface)}:host([compact]) .dot{width:8px;height:8px}.circle{width:var(--marker);height:var(--marker);border:1px solid color-mix(in srgb, var(--tone) 30%, var(--soft));background:var(--soft);color:var(--tone);box-shadow:0 0 0 3px var(--jl-surface)}.content{grid-column:3;gap:2px;display:grid}.title{color:var(--jl-text);font-size:var(--title-size);font-weight:600;line-height:20px}.time{color:var(--jl-muted);font-family:var(--jl-font-mono);font-size:var(--jl-font-xs);white-space:nowrap;grid-column:2;padding-right:12px;line-height:20px}.description{color:var(--jl-muted);font-size:var(--jl-font-sm);line-height:1.5}:host([compact]) .description{font-size:var(--jl-font-xs)}.marker jl-icon{--icon-size:14px}:host([compact]) .marker jl-icon{--icon-size:12px}";
3
3
  export { jl_timeline_default as default };
@@ -21,9 +21,11 @@ export declare class JlTimeline extends JlElement {
21
21
  get(): string;
22
22
  set(setter: string | ((prevState: string) => string)): void;
23
23
  }>>;
24
+ private readonly _drawn;
24
25
  private readonly _refs;
25
26
  templateHtml(): Node;
26
27
  templateCss(): string;
27
- private render;
28
+ private renderItems;
29
+ /** An event; the CSS sizes its icon, smaller when compact (--icon-size). */
28
30
  private itemNode;
29
31
  }
@@ -7,8 +7,6 @@ import jl_timeline_default from "./jl-timeline.css.js";
7
7
  import { css } from "@jadis/core";
8
8
  import { jsx, jsxs } from "@jadis/core/jsx-runtime";
9
9
  // src/molecules/jl-timeline.tsx
10
- var ICON_SIZE = 14;
11
- var COMPACT_ICON_SIZE = 12;
12
10
  /**
13
11
  * What happened, in order, along a vertical line: each event a dot (or an icon in a circle) in its tone's colour,
14
12
  * its time beside the marker (the times in one column), a title and an optional description. `compact` tightens it
@@ -16,17 +14,15 @@ var COMPACT_ICON_SIZE = 12;
16
14
  */
17
15
  var JlTimeline = class extends JlElement {
18
16
  static selector = "jl-timeline";
19
- items = this.useChange([], () => this.render(), {
17
+ items = this.useChange([], (value) => this.renderItems(value), {
20
18
  attribute: "items",
21
19
  parse: jsonOf([])
22
20
  });
23
21
  /** Smaller markers and less space between events. */
24
- compact = this.useChange(false, (value) => {
25
- this.reflect("compact", value);
26
- this.render();
27
- }, { attribute: "compact" });
22
+ compact = this.useChange(false, (value) => this.reflect("compact", value), { attribute: "compact" });
28
23
  /** The list's name for screen readers. */
29
24
  label = this.useChange("", (value) => setOrRemove(this._refs.list, "aria-label", value), { attribute: "label" });
25
+ _drawn = {};
30
26
  _refs = this.useRefs((ref) => ({ list: ref("ol") }));
31
27
  templateHtml() {
32
28
  return /* @__PURE__ */ jsx("ol", {
@@ -37,21 +33,20 @@ var JlTimeline = class extends JlElement {
37
33
  templateCss() {
38
34
  return css`${BASE_STYLES}${jl_timeline_default}`;
39
35
  }
40
- render() {
41
- this._refs.list.replaceChildren(...this.items.get().map((item) => this.itemNode(item)));
36
+ renderItems(items) {
37
+ if (items === this._drawn.items) return;
38
+ this._drawn.items = items;
39
+ this._refs.list.replaceChildren(...items.map((item) => this.itemNode(item)));
42
40
  }
41
+ /** An event; the CSS sizes its icon, smaller when compact (--icon-size). */
43
42
  itemNode(item) {
44
- const size = this.compact.get() ? COMPACT_ICON_SIZE : ICON_SIZE;
45
43
  const marker = item.icon === void 0 ? /* @__PURE__ */ jsx("span", {
46
44
  class: "marker dot",
47
45
  "aria-hidden": "true"
48
46
  }) : /* @__PURE__ */ jsx("span", {
49
47
  class: "marker circle",
50
48
  "aria-hidden": "true",
51
- children: /* @__PURE__ */ jsx(JlIcon, {
52
- name: item.icon,
53
- size
54
- })
49
+ children: /* @__PURE__ */ jsx(JlIcon, { name: item.icon })
55
50
  });
56
51
  return /* @__PURE__ */ jsxs("li", {
57
52
  class: "event",
@@ -1,3 +1,3 @@
1
1
  // src/molecules/jl-toast.css?inline
2
- var jl_toast_default = ":host{--fg:var(--jl-text-2);--bg:var(--jl-surface);--border:var(--jl-line);--bar:var(--jl-brand);display:block}:host([tone=ok]),:host([tone=warn]),:host([tone=danger]),:host([tone=info]){--border:color-mix(in srgb, var(--fg) 24%, var(--bg));--bar:var(--fg)}:host([tone=ok]){--fg:var(--jl-ok);--bg:var(--jl-ok-soft)}:host([tone=warn]){--fg:var(--jl-warn);--bg:var(--jl-warn-soft)}:host([tone=danger]){--fg:var(--jl-danger);--bg:var(--jl-danger-soft)}:host([tone=info]){--fg:var(--jl-info);--bg:var(--jl-info-soft)}.toast{border:1px solid var(--border);border-radius:var(--jl-radius-lg);background:var(--bg);color:var(--jl-text);font-size:var(--jl-font-md);box-shadow:var(--jl-shadow-lg);align-items:flex-start;gap:12px;padding:14px 12px 14px 16px;line-height:20px;display:flex;position:relative;overflow:hidden}.icon{color:var(--fg);margin-top:1px}.content{overflow-wrap:anywhere;flex:1;gap:2px;min-width:0;display:grid}.heading{font-weight:650}.text{color:var(--jl-muted);font-size:var(--jl-font-sm)}.heading[hidden]+.text{color:var(--jl-text-2);font-size:var(--jl-font-md)}.buttons{flex:none;align-items:center;gap:2px;margin:-5px -4px -5px 0;display:flex}.buttons:not(:has(jl-button:not([hidden]))){display:none}.close{--jl-accent:var(--fg);--jl-accent-soft:color-mix(in srgb, var(--fg) 12%, transparent)}.work{margin-top:8px}.progress{height:2px;position:absolute;bottom:0;left:0;right:0}.bar{background:var(--bar);transform-origin:0;height:100%}:host([paused]) .bar{opacity:.55}@media (prefers-reduced-motion:reduce){.progress{visibility:hidden}}";
2
+ var jl_toast_default = ":host{--fg:var(--jl-text-2);--bg:var(--jl-surface);--border:var(--jl-line);--bar:var(--jl-brand);display:block}:host([tone=ok]),:host([tone=warn]),:host([tone=danger]),:host([tone=info]){--border:color-mix(in srgb, var(--fg) 24%, var(--bg));--bar:var(--fg)}:host([tone=ok]){--fg:var(--jl-ok);--bg:var(--jl-ok-soft)}:host([tone=warn]){--fg:var(--jl-warn);--bg:var(--jl-warn-soft)}:host([tone=danger]){--fg:var(--jl-danger);--bg:var(--jl-danger-soft)}:host([tone=info]){--fg:var(--jl-info);--bg:var(--jl-info-soft)}.toast{border:1px solid var(--border);border-radius:var(--jl-radius-lg);background:var(--bg);color:var(--jl-text);font-size:var(--jl-font-md);box-shadow:var(--jl-shadow-lg);align-items:flex-start;gap:12px;padding:14px 12px 14px 16px;line-height:20px;display:flex;position:relative;overflow:hidden}.icon{color:var(--fg);margin-top:1px}.content{overflow-wrap:anywhere;flex:1;gap:2px;min-width:0;display:grid}.heading{font-weight:650}.text{color:var(--jl-muted);font-size:var(--jl-font-sm)}.heading:empty,.text:empty{display:none}.heading:empty+.text{color:var(--jl-text-2);font-size:var(--jl-font-md)}.buttons{flex:none;align-items:center;gap:2px;margin:-5px -4px -5px 0;display:flex}.buttons:not(:has(jl-button:not([hidden]))){display:none}.close{--jl-accent:var(--fg);--jl-accent-soft:color-mix(in srgb, var(--fg) 12%, transparent)}.work{margin-top:8px}.progress{height:2px;position:absolute;bottom:0;left:0;right:0}.bar{background:var(--bar);transform-origin:0;height:100%}:host([paused]) .bar{opacity:.55}@media (prefers-reduced-motion:reduce){.progress{visibility:hidden}}";
3
3
  export { jl_toast_default as default };
@@ -65,11 +65,9 @@ var JlToast = class extends JlElement {
65
65
  });
66
66
  heading = this.useChange("", (value) => {
67
67
  this._refs.heading.textContent = value;
68
- this._refs.heading.hidden = value === "";
69
68
  }, { attribute: "heading" });
70
69
  text = this.useChange("", (value) => {
71
70
  this._refs.text.textContent = value;
72
- this._refs.text.hidden = value === "";
73
71
  }, { attribute: "text" });
74
72
  /** An icon name; the tone's icon when empty. */
75
73
  icon = this.useChange("", () => this.renderIcon(), { attribute: "icon" });
@@ -153,14 +151,8 @@ var JlToast = class extends JlElement {
153
151
  /* @__PURE__ */ jsxs("div", {
154
152
  class: "content",
155
153
  children: [
156
- /* @__PURE__ */ jsx("p", {
157
- class: "heading",
158
- hidden: true
159
- }),
160
- /* @__PURE__ */ jsx("p", {
161
- class: "text",
162
- hidden: true
163
- }),
154
+ /* @__PURE__ */ jsx("p", { class: "heading" }),
155
+ /* @__PURE__ */ jsx("p", { class: "text" }),
164
156
  /* @__PURE__ */ jsx(JlProgress, {
165
157
  class: "work",
166
158
  size: "sm",
@@ -65,7 +65,8 @@ export declare class JlTooltip extends JlElement {
65
65
  private scheduleHide;
66
66
  private open;
67
67
  private reposition;
68
- private placeArrow;
68
+ /** Puts the bubble by its trigger, and points its arrow at the trigger from what the placing measured. */
69
+ private place;
69
70
  private renderText;
70
71
  /** Gives the trigger the text as its description, and takes it back from a trigger that left. */
71
72
  private describeTrigger;
@@ -1,7 +1,7 @@
1
1
  import { BASE_STYLES, FLOATING_STYLES } from "../styles/shared.js";
2
2
  import { JlElement } from "../base/jl-element.js";
3
3
  import { clampedNumber, oneOf } from "../lib/attributes.js";
4
- import { PLACEMENTS, followAnchor, placeFloating } from "../lib/floating.js";
4
+ import { PLACEMENTS, positionFloating } from "../lib/floating.js";
5
5
  import { accessibleTarget, deepActiveElement } from "../lib/trigger.js";
6
6
  import { arrowOffset } from "../lib/arrow.js";
7
7
  import jl_tooltip_default from "./jl-tooltip.css.js";
@@ -239,17 +239,15 @@ var JlTooltip = class extends JlElement {
239
239
  }
240
240
  open() {
241
241
  if (this.text.get() === "" || this.isOpen()) return;
242
- const bubble = this._refs.bubble;
243
- bubble.showPopover();
242
+ this._refs.bubble.showPopover();
244
243
  const following = new AbortController();
245
244
  this._state.following = following;
246
- followAnchor(this.trigger(), bubble, this.placement.get(), following.signal, GAP);
247
- window.addEventListener("scroll", () => this.placeArrow(), {
245
+ window.addEventListener("scroll", () => this.place(), {
248
246
  capture: true,
249
247
  passive: true,
250
248
  signal: following.signal
251
249
  });
252
- window.addEventListener("resize", () => this.placeArrow(), {
250
+ window.addEventListener("resize", () => this.place(), {
253
251
  passive: true,
254
252
  signal: following.signal
255
253
  });
@@ -259,18 +257,16 @@ var JlTooltip = class extends JlElement {
259
257
  document.addEventListener("keydown", (event) => {
260
258
  if (event.key === "Escape") this.close();
261
259
  }, { signal: following.signal });
262
- this.placeArrow();
260
+ this.place();
263
261
  }
264
262
  reposition() {
265
- if (!this.isOpen()) return;
266
- placeFloating(this.trigger(), this._refs.bubble, this.placement.get(), GAP);
267
- this.placeArrow();
263
+ if (this.isOpen()) this.place();
268
264
  }
269
- placeArrow() {
270
- const bubble = this._refs.bubble;
271
- const placement = bubble.dataset.placement ?? this.placement.get();
272
- const offset = arrowOffset(this.trigger().getBoundingClientRect(), bubble.getBoundingClientRect(), sideOf(placement), ARROW_MARGIN);
273
- bubble.style.setProperty("--arrow", `${offset}px`);
265
+ /** Puts the bubble by its trigger, and points its arrow at the trigger from what the placing measured. */
266
+ place() {
267
+ const placed = positionFloating(this.trigger(), this._refs.bubble, this.placement.get(), GAP);
268
+ const offset = arrowOffset(placed.anchor, placed.floating, sideOf(placed.placement), ARROW_MARGIN);
269
+ this._refs.bubble.style.setProperty("--arrow", `${offset}px`);
274
270
  }
275
271
  renderText(text) {
276
272
  this._refs.text.textContent = text;
@@ -1,3 +1,3 @@
1
1
  // src/organisms/jl-command-palette.css?inline
2
- var jl_command_palette_default = ":host{display:contents}dialog{border:1px solid var(--jl-line);border-radius:var(--jl-radius-lg);background:var(--jl-surface);width:min(620px,100vw - 24px);max-width:none;max-height:min(520px,100dvh - 24vh);color:var(--jl-text);font-size:var(--jl-font-md);box-shadow:var(--jl-shadow-lg);flex-direction:column;margin:12vh auto auto;padding:0;overflow:hidden}dialog[open]{animation:drop var(--jl-fast) var(--jl-ease);display:flex}dialog::backdrop{background:var(--jl-scrim);-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.search{border-bottom:1px solid var(--jl-line);flex:none;align-items:center;gap:10px;height:52px;padding:0 14px 0 16px;display:flex}.search-icon,.search-spinner{color:var(--jl-faint);flex:none}input{min-width:0;height:100%;font-size:max(15px, var(--jl-control-font));background:0 0;border:none;outline:none;flex:1;padding:0}input::placeholder{color:var(--jl-faint)}input:focus-visible{box-shadow:none}kbd{border:1px solid var(--jl-line-strong);border-radius:var(--jl-radius-xs);background:var(--jl-surface);min-width:20px;height:20px;color:var(--jl-muted);border-bottom-width:2px;justify-content:center;align-items:center;padding:0 5px;font-size:11px;font-weight:500;line-height:1;display:inline-flex}.results{overscroll-behavior:contain;flex:1;min-height:0;padding:6px;scroll-padding:6px;overflow-y:auto}[role=group]+[role=group]{border-top:1px solid var(--jl-line-soft);margin-top:4px;padding-top:4px}.group-label{color:var(--jl-muted);font-size:var(--jl-font-xs);padding:8px 10px 4px;font-weight:600}.option{border-radius:var(--jl-radius-sm);min-height:38px;color:var(--jl-text-2);cursor:pointer;align-items:center;gap:10px;padding:0 10px;display:flex}.option[aria-selected=true]{background:var(--jl-accent-soft);color:var(--jl-text)}.option-icon{width:16px;color:var(--jl-muted);flex:none}.option[aria-selected=true] .option-icon{color:var(--jl-accent)}.option-label{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;overflow:hidden}.option-description{max-width:40%;color:var(--jl-muted);font-size:var(--jl-font-xs);text-overflow:ellipsis;white-space:nowrap;flex:none;overflow:hidden}mark{color:var(--jl-accent);background:0 0;font-weight:700}.keys{flex:none;gap:3px;display:inline-flex}.empty{color:var(--jl-muted);text-align:center;padding:36px 16px}footer{border-top:1px solid var(--jl-line);background:var(--jl-surface-2);color:var(--jl-muted);font-size:var(--jl-font-xs);flex-wrap:wrap;flex:none;align-items:center;gap:6px 16px;padding:8px 16px;display:flex}.hint,.hotkey-keys{align-items:center;gap:4px;display:inline-flex}.hotkey-hint{margin-left:auto}@media (width<520px){dialog{max-height:calc(100dvh - 24px);margin-top:12px}.hotkey-hint{display:none}}@keyframes drop{0%{opacity:0;transform:translateY(-6px)scale(.98)}}";
2
+ var jl_command_palette_default = ":host{display:contents}dialog{border:1px solid var(--jl-line);border-radius:var(--jl-radius-lg);background:var(--jl-surface);width:min(620px,100vw - 24px);max-width:none;max-height:min(520px,100dvh - 24vh);color:var(--jl-text);font-size:var(--jl-font-md);box-shadow:var(--jl-shadow-lg);flex-direction:column;margin:12vh auto auto;padding:0;overflow:hidden}dialog[open]{animation:drop var(--jl-fast) var(--jl-ease);display:flex}dialog::backdrop{background:var(--jl-scrim);-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.search{border-bottom:1px solid var(--jl-line);flex:none;align-items:center;gap:10px;height:52px;padding:0 14px 0 16px;display:flex}.search-icon,.search-spinner{color:var(--jl-faint);flex:none}input{min-width:0;height:100%;font-size:max(15px, var(--jl-control-font));background:0 0;border:none;outline:none;flex:1;padding:0}input::placeholder{color:var(--jl-faint)}input:focus-visible{box-shadow:none}kbd{border:1px solid var(--jl-line-strong);border-radius:var(--jl-radius-xs);background:var(--jl-surface);min-width:20px;height:20px;color:var(--jl-muted);border-bottom-width:2px;justify-content:center;align-items:center;padding:0 5px;font-size:11px;font-weight:500;line-height:1;display:inline-flex}.results{overscroll-behavior:contain;flex:1;min-height:0;padding:6px;scroll-padding:6px;overflow-y:auto}[role=group]+[role=group]{border-top:1px solid var(--jl-line-soft);margin-top:4px;padding-top:4px}.group-label{color:var(--jl-muted);font-size:var(--jl-font-xs);padding:8px 10px 4px;font-weight:600}.option{border-radius:var(--jl-radius-sm);min-height:38px;color:var(--jl-text-2);cursor:pointer;align-items:center;gap:10px;padding:0 10px;display:flex}.option[aria-selected=true]{background:var(--jl-accent-soft);color:var(--jl-text)}.option-icon{width:16px;color:var(--jl-muted);flex:none}.option[aria-selected=true] .option-icon{color:var(--jl-accent)}.option-label{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;overflow:hidden}.option-description{max-width:40%;color:var(--jl-muted);font-size:var(--jl-font-xs);text-overflow:ellipsis;white-space:nowrap;flex:none;overflow:hidden}mark{color:var(--jl-accent);background:0 0;font-weight:700}.keys{flex:none;gap:3px;display:inline-flex}.empty{color:var(--jl-muted);text-align:center;padding:36px 16px}.results:empty,.results:not(:empty)+.empty{display:none}footer{border-top:1px solid var(--jl-line);background:var(--jl-surface-2);color:var(--jl-muted);font-size:var(--jl-font-xs);flex-wrap:wrap;flex:none;align-items:center;gap:6px 16px;padding:8px 16px;display:flex}.hint,.hotkey-keys{align-items:center;gap:4px;display:inline-flex}.hotkey-hint{margin-left:auto}@media (width<520px){dialog{max-height:calc(100dvh - 24px);margin-top:12px}.hotkey-hint{display:none}}@keyframes drop{0%{opacity:0;transform:translateY(-6px)scale(.98)}}";
3
3
  export { jl_command_palette_default as default };
@@ -54,6 +54,7 @@ export declare class JlCommandPalette<Id extends string = string> extends JlElem
54
54
  get(): string;
55
55
  set(setter: string | ((prevState: string) => string)): void;
56
56
  }>>;
57
+ /** The matches listed, their options in the same order, the one active, and every option drawn by its command. */
57
58
  private readonly _state;
58
59
  private readonly _refs;
59
60
  show(): void;
@@ -71,8 +72,14 @@ export declare class JlCommandPalette<Id extends string = string> extends JlElem
71
72
  private scheduleSearch;
72
73
  private search;
73
74
  private renderHotkey;
75
+ /** Forgets the options of commands that left; the list is drawn again only while it shows, and when it opens. */
76
+ private renderCommands;
77
+ /** Lists the matches in their groups, moving the options already drawn; the CSS hides an empty list. */
74
78
  private renderResults;
75
79
  private groupNode;
76
- private optionNode;
80
+ /** The match's option, made the first time its command is listed, its label's marks changed when they do. */
81
+ private drawOption;
82
+ private makeOption;
83
+ /** Marks the option that becomes active and clears the one that was: the others are left alone. */
77
84
  private activate;
78
85
  }
@@ -22,7 +22,7 @@ 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]]);
25
- var optionId = (index) => `option-${index}`;
25
+ var OPTION_ID_PREFIX = "option-";
26
26
  var onApple = () => isApplePlatform(navigator.platform);
27
27
  function keycaps(shortcut) {
28
28
  return hotkeyLabels(shortcut, onApple()).map((label) => /* @__PURE__ */ jsx("kbd", { children: label }));
@@ -41,7 +41,7 @@ var JlCommandPalette = class extends JlElement {
41
41
  static selector = "jl-command-palette";
42
42
  /** `search`: what was typed, once typing pauses (and empty when it opens), for a page that answers it. */
43
43
  events = this.useEvents();
44
- commands = this.useChange([], () => this.renderResults(), {
44
+ commands = this.useChange([], (commands) => this.renderCommands(commands), {
45
45
  attribute: "commands",
46
46
  parse: jsonOf([])
47
47
  });
@@ -61,9 +61,14 @@ var JlCommandPalette = class extends JlElement {
61
61
  }, { attribute: "loading" });
62
62
  /** The dialog's name for screen readers. */
63
63
  label = this.useChange("", () => this.drawTexts(), { attribute: "label" });
64
+ /** The matches listed, their options in the same order, the one active, and every option drawn by its command. */
64
65
  _state = {
65
66
  active: 0,
67
+ activeOption: void 0,
68
+ made: 0,
66
69
  matches: [],
70
+ options: /* @__PURE__ */ new Map(),
71
+ shown: [],
67
72
  timer: 0
68
73
  };
69
74
  _refs = this.useRefs((ref) => ({
@@ -125,8 +130,7 @@ var JlCommandPalette = class extends JlElement {
125
130
  }),
126
131
  /* @__PURE__ */ jsx("p", {
127
132
  class: "empty",
128
- role: "status",
129
- hidden: true
133
+ role: "status"
130
134
  }),
131
135
  /* @__PURE__ */ jsxs("footer", {
132
136
  "aria-hidden": "true",
@@ -213,7 +217,8 @@ var JlCommandPalette = class extends JlElement {
213
217
  }
214
218
  indexOf(target) {
215
219
  const option = target instanceof Element ? target.closest("[role=\"option\"]") : null;
216
- return option === null ? null : Number(option.dataset.index);
220
+ const index = option === null ? -1 : this._state.shown.indexOf(option);
221
+ return index === -1 ? null : index;
217
222
  }
218
223
  move(step) {
219
224
  const count = this._state.matches.length;
@@ -256,18 +261,26 @@ var JlCommandPalette = class extends JlElement {
256
261
  this._refs.hotkeyHint.hidden = none;
257
262
  this._refs.hotkeyKeys.replaceChildren(...none ? [] : keycaps(hotkey));
258
263
  }
264
+ /** Forgets the options of commands that left; the list is drawn again only while it shows, and when it opens. */
265
+ renderCommands(commands) {
266
+ const kept = new Set(commands);
267
+ for (const command of this._state.options.keys()) if (!kept.has(command)) this._state.options.delete(command);
268
+ if (this._refs.dialog.open) this.renderResults();
269
+ }
270
+ /** Lists the matches in their groups, moving the options already drawn; the CSS hides an empty list. */
259
271
  renderResults() {
260
272
  const groups = groupMatches(matchCommands(this.commands.get(), this._refs.input.value));
273
+ const lists = groups.map((group) => ({
274
+ label: group.label,
275
+ options: group.matches.map((match) => this.drawOption(match))
276
+ }));
261
277
  this._state.matches = groups.flatMap((group) => group.matches);
262
- this._refs.results.replaceChildren(...groups.map((group, index) => this.groupNode(group, index)));
263
- this._refs.results.hidden = this._state.matches.length === 0;
264
- this._refs.empty.hidden = this._state.matches.length > 0;
278
+ this._state.shown = lists.flatMap((list) => list.options);
279
+ this._refs.results.replaceChildren(...lists.map((list, index) => this.groupNode(list.label, list.options, index)));
265
280
  this.activate(0);
266
281
  }
267
- groupNode(group, groupIndex) {
268
- const first = this._state.matches.indexOf(group.matches[0]);
269
- const options = group.matches.map((match, index) => this.optionNode(match, first + index));
270
- if (group.label === "") return /* @__PURE__ */ jsx("div", {
282
+ groupNode(label, options, groupIndex) {
283
+ if (label === "") return /* @__PURE__ */ jsx("div", {
271
284
  role: "group",
272
285
  children: options
273
286
  });
@@ -279,47 +292,65 @@ var JlCommandPalette = class extends JlElement {
279
292
  class: "group-label",
280
293
  id: labelId,
281
294
  "aria-hidden": "true",
282
- children: group.label
295
+ children: label
283
296
  }), options]
284
297
  });
285
298
  }
286
- optionNode(match, index) {
287
- const { command } = match;
299
+ /** The match's option, made the first time its command is listed, its label's marks changed when they do. */
300
+ drawOption(match) {
301
+ const drawn = this._state.options.get(match.command) ?? this.makeOption(match.command);
302
+ const marks = match.positions.join();
303
+ if (drawn.marks !== marks) {
304
+ drawn.label.replaceChildren(...highlighted(match.command.label, match.positions));
305
+ drawn.marks = marks;
306
+ }
307
+ return drawn.element;
308
+ }
309
+ makeOption(command) {
310
+ const label = /* @__PURE__ */ jsx("span", {
311
+ class: "option-label",
312
+ children: command.label
313
+ });
314
+ const id = `${OPTION_ID_PREFIX}${this._state.made++}`;
288
315
  const icon = command.icon === void 0 ? /* @__PURE__ */ jsx("span", { class: "option-icon" }) : /* @__PURE__ */ jsx(JlIcon, {
289
316
  class: "option-icon",
290
317
  name: command.icon,
291
318
  size: OPTION_ICON_SIZE
292
319
  });
293
- return /* @__PURE__ */ jsxs("div", {
294
- class: "option",
295
- role: "option",
296
- id: optionId(index),
297
- "data-index": index,
298
- "aria-selected": "false",
299
- children: [
300
- icon,
301
- /* @__PURE__ */ jsx("span", {
302
- class: "option-label",
303
- children: highlighted(command.label, match.positions)
304
- }),
305
- command.description ? /* @__PURE__ */ jsx("span", {
306
- class: "option-description",
307
- children: command.description
308
- }) : null,
309
- command.shortcut === void 0 ? null : /* @__PURE__ */ jsx("span", {
310
- class: "keys",
311
- children: keycaps(command.shortcut)
312
- })
313
- ]
314
- });
320
+ const drawn = {
321
+ element: /* @__PURE__ */ jsxs("div", {
322
+ class: "option",
323
+ role: "option",
324
+ id,
325
+ "aria-selected": "false",
326
+ children: [
327
+ icon,
328
+ label,
329
+ command.description ? /* @__PURE__ */ jsx("span", {
330
+ class: "option-description",
331
+ children: command.description
332
+ }) : null,
333
+ command.shortcut === void 0 ? null : /* @__PURE__ */ jsx("span", {
334
+ class: "keys",
335
+ children: keycaps(command.shortcut)
336
+ })
337
+ ]
338
+ }),
339
+ label,
340
+ marks: ""
341
+ };
342
+ this._state.options.set(command, drawn);
343
+ return drawn;
315
344
  }
345
+ /** Marks the option that becomes active and clears the one that was: the others are left alone. */
316
346
  activate(index) {
317
347
  this._state.active = index;
318
- const options = this._refs.results.querySelectorAll("[role=\"option\"]");
319
- for (const option of options) option.setAttribute("aria-selected", String(Number(option.dataset.index) === index));
320
- const active = options[index];
321
- setOrRemove(this._refs.input, "aria-activedescendant", active === void 0 ? "" : optionId(index));
322
- active?.scrollIntoView({ block: "nearest" });
348
+ this._state.activeOption?.setAttribute("aria-selected", "false");
349
+ const active = this._state.shown[index];
350
+ this._state.activeOption = active;
351
+ active?.setAttribute("aria-selected", "true");
352
+ setOrRemove(this._refs.input, "aria-activedescendant", active?.id ?? "");
353
+ if (active !== void 0) requestAnimationFrame(() => active.scrollIntoView({ block: "nearest" }));
323
354
  }
324
355
  };
325
356
  JlCommandPalette.register();
@@ -1,3 +1,3 @@
1
1
  // src/organisms/jl-confirm.css?inline
2
- var jl_confirm_default = ":host{display:contents}.text{color:var(--jl-text-2)}";
2
+ var jl_confirm_default = ":host{display:contents}.text{color:var(--jl-text-2)}.text:empty{display:none}";
3
3
  export { jl_confirm_default as default };
@@ -27,7 +27,6 @@ var JlConfirm = class extends JlElement {
27
27
  heading = this.useChange("", (value) => this._refs.dialog.heading.set(value), { attribute: "heading" });
28
28
  text = this.useChange("", (value) => {
29
29
  this._refs.text.textContent = value;
30
- this._refs.text.hidden = value === "";
31
30
  }, { attribute: "text" });
32
31
  /** The confirm button's text; jlib's own when empty. */
33
32
  confirmLabel = this.useChange("", () => this.drawTexts(), { attribute: "confirm-label" });
@@ -60,10 +59,7 @@ var JlConfirm = class extends JlElement {
60
59
  return /* @__PURE__ */ jsxs("jl-dialog", {
61
60
  size: "sm",
62
61
  children: [
63
- /* @__PURE__ */ jsx("p", {
64
- class: "text",
65
- hidden: true
66
- }),
62
+ /* @__PURE__ */ jsx("p", { class: "text" }),
67
63
  /* @__PURE__ */ jsx("slot", {}),
68
64
  /* @__PURE__ */ jsx(JlButton, {
69
65
  slot: "actions",
@@ -1,3 +1,3 @@
1
1
  // src/organisms/jl-dialog.css?inline
2
- var jl_dialog_default = ":host{--width:520px;display:contents}:host([size=sm]){--width:400px}:host([size=lg]){--width:820px}:host([size=full]){--width:100vw}dialog{width:min(var(--width), calc(100vw - 32px));border:1px solid var(--jl-line);border-radius:var(--jl-radius-lg);background:var(--jl-surface);max-height:min(760px,100dvh - 48px);color:var(--jl-text);font-size:var(--jl-font-md);box-shadow:var(--jl-shadow-lg);flex-direction:column;padding:0;display:flex}dialog:not([open]){display:none}:host([size=full]) dialog{height:calc(100dvh - 32px);max-height:calc(100dvh - 32px)}dialog[open]{animation:rise var(--jl-slow) var(--jl-ease)}dialog::backdrop{background:var(--jl-scrim);-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}header{align-items:flex-start;gap:12px;padding:20px 16px 4px 24px;display:flex}.titles{flex:1;gap:4px;padding-top:4px;display:grid}h2{letter-spacing:-.01em;font-size:17px;font-weight:650;line-height:1.3}.description{color:var(--jl-muted);font-size:var(--jl-font-sm);line-height:1.5}.body{flex:1;padding:16px 24px;line-height:1.55;position:relative;overflow:auto}footer{flex-wrap:wrap;justify-content:flex-end;gap:8px;padding:0 24px 20px;display:flex}@keyframes rise{0%{opacity:0;transform:translateY(8px)scale(.98)}}";
2
+ var jl_dialog_default = ":host{--width:520px;display:contents}:host([size=sm]){--width:400px}:host([size=lg]){--width:820px}:host([size=full]){--width:100vw}dialog{width:min(var(--width), calc(100vw - 32px));border:1px solid var(--jl-line);border-radius:var(--jl-radius-lg);background:var(--jl-surface);max-height:min(760px,100dvh - 48px);color:var(--jl-text);font-size:var(--jl-font-md);box-shadow:var(--jl-shadow-lg);flex-direction:column;padding:0;display:flex}dialog:not([open]){display:none}:host([size=full]) dialog{height:calc(100dvh - 32px);max-height:calc(100dvh - 32px)}dialog[open]{animation:rise var(--jl-slow) var(--jl-ease)}dialog::backdrop{background:var(--jl-scrim);-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}header{align-items:flex-start;gap:12px;padding:20px 16px 4px 24px;display:flex}.titles{flex:1;gap:4px;padding-top:4px;display:grid}h2{letter-spacing:-.01em;font-size:17px;font-weight:650;line-height:1.3}.description{color:var(--jl-muted);font-size:var(--jl-font-sm);line-height:1.5}.description:empty{display:none}.body{flex:1;padding:16px 24px;line-height:1.55;position:relative;overflow:auto}footer{flex-wrap:wrap;justify-content:flex-end;gap:8px;padding:0 24px 20px;display:flex}@keyframes rise{0%{opacity:0;transform:translateY(8px)scale(.98)}}";
3
3
  export { jl_dialog_default as default };
@@ -28,7 +28,6 @@ var JlDialog = class extends JlElement {
28
28
  }, { attribute: "heading" });
29
29
  description = this.useChange("", (value) => {
30
30
  this._refs.description.textContent = value;
31
- this._refs.description.hidden = value === "";
32
31
  }, { attribute: "description" });
33
32
  size = this.useChange("md", (value) => this.reflect("size", value), {
34
33
  attribute: "size",
@@ -60,10 +59,7 @@ var JlDialog = class extends JlElement {
60
59
  children: [
61
60
  /* @__PURE__ */ jsxs("header", { children: [/* @__PURE__ */ jsxs("div", {
62
61
  class: "titles",
63
- children: [/* @__PURE__ */ jsx("h2", { id: "heading" }), /* @__PURE__ */ jsx("p", {
64
- class: "description",
65
- hidden: true
66
- })]
62
+ children: [/* @__PURE__ */ jsx("h2", { id: "heading" }), /* @__PURE__ */ jsx("p", { class: "description" })]
67
63
  }), /* @__PURE__ */ jsx(JlButton, {
68
64
  class: "close",
69
65
  variant: "ghost",