@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
@@ -4,20 +4,21 @@ export declare const RADIO_GROUP_ORIENTATIONS: readonly RadioGroupOrientation[];
4
4
  export declare const RADIO_GROUP_VARIANTS: readonly RadioGroupVariant[];
5
5
  /**
6
6
  * One choice among a few, all in view. It behaves as native radios: Tab reaches the chosen option, the arrow keys
7
- * move the choice, Space chooses the focused option. `variant="cards"` draws each option as a card.
7
+ * move the choice, Space chooses the focused option. `variant="cards"` draws each option as a card. Typed by its
8
+ * values, `JlRadioGroup<'card' | 'invoice'>` takes options of those values and gives `change` one of them.
8
9
  */
9
- export declare class JlRadioGroup extends JlFormControl {
10
+ export declare class JlRadioGroup<Value extends string = string> extends JlFormControl {
10
11
  static readonly selector = "jl-radio-group";
11
12
  readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
12
- change: string;
13
+ change: Value;
13
14
  }>>;
14
15
  readonly options: Readonly<Readonly<{
15
- get(): RadioOption[];
16
- set(setter: RadioOption[] | ((prevState: RadioOption[]) => RadioOption[])): void;
16
+ get(): RadioOption<Value>[];
17
+ set(setter: RadioOption<Value>[] | ((prevState: RadioOption<Value>[]) => RadioOption<Value>[])): void;
17
18
  }>>;
18
19
  readonly value: Readonly<Readonly<{
19
- get(): string;
20
- set(setter: string | ((prevState: string) => string)): void;
20
+ get(): "" | Value;
21
+ set(setter: "" | Value | ((prevState: "" | Value) => "" | Value)): void;
21
22
  }>>;
22
23
  readonly orientation: Readonly<Readonly<{
23
24
  get(): RadioGroupOrientation;
@@ -1,6 +1,7 @@
1
1
  import { BASE_STYLES } from "../styles/shared.js";
2
2
  import { JlFormControl } from "../base/jl-form-control.js";
3
- import { jsonOf, oneOf } from "../lib/attributes.js";
3
+ import { jsonOf, oneOf, textOf } from "../lib/attributes.js";
4
+ import { jlText } from "../lib/texts.js";
4
5
  import { rovingIndex } from "../lib/roving-index.js";
5
6
  import jl_radio_group_default from "./jl-radio-group.css_raw.js";
6
7
  import { css } from "@jadis/core";
@@ -10,7 +11,6 @@ var RADIO_GROUP_ORIENTATIONS = ["vertical", "horizontal"];
10
11
  var RADIO_GROUP_VARIANTS = ["plain", "cards"];
11
12
  var NO_VALUE = "";
12
13
  var OPTION_SELECTOR = "[role=\"radio\"]";
13
- var VALUE_MISSING = "Please select one of these options.";
14
14
  /** The keys that move the choice, as with native radios: both arrow pairs whatever the orientation. */
15
15
  var MOVES = /* @__PURE__ */ new Map([
16
16
  ["ArrowDown", "next"],
@@ -23,7 +23,8 @@ var MOVES = /* @__PURE__ */ new Map([
23
23
  var SPACE = " ";
24
24
  /**
25
25
  * One choice among a few, all in view. It behaves as native radios: Tab reaches the chosen option, the arrow keys
26
- * move the choice, Space chooses the focused option. `variant="cards"` draws each option as a card.
26
+ * move the choice, Space chooses the focused option. `variant="cards"` draws each option as a card. Typed by its
27
+ * values, `JlRadioGroup<'card' | 'invoice'>` takes options of those values and gives `change` one of them.
27
28
  */
28
29
  var JlRadioGroup = class extends JlFormControl {
29
30
  static selector = "jl-radio-group";
@@ -32,7 +33,10 @@ var JlRadioGroup = class extends JlFormControl {
32
33
  attribute: "options",
33
34
  parse: jsonOf([])
34
35
  });
35
- value = this.useChange(NO_VALUE, () => this.renderValue(), { attribute: "value" });
36
+ value = this.useChange(NO_VALUE, () => this.renderValue(), {
37
+ attribute: "value",
38
+ parse: textOf(NO_VALUE)
39
+ });
36
40
  orientation = this.useChange("vertical", (value) => {
37
41
  this.reflect("orientation", value);
38
42
  this._refs.group.setAttribute("aria-orientation", value);
@@ -95,7 +99,7 @@ var JlRadioGroup = class extends JlFormControl {
95
99
  this.on(list, "keydown", (event) => this.onKey(event));
96
100
  }
97
101
  resetValue() {
98
- this.value.set(this.getAttribute("value") ?? NO_VALUE);
102
+ this.value.set(textOf(NO_VALUE)(this.getAttribute("value")));
99
103
  }
100
104
  /** The browser calls it for a disabled fieldset and for the element's own disabled attribute, even before render. */
101
105
  setDisabledByForm(disabled) {
@@ -124,8 +128,8 @@ var JlRadioGroup = class extends JlFormControl {
124
128
  }
125
129
  choose(radio) {
126
130
  radio.focus();
127
- const value = radio.dataset.value ?? NO_VALUE;
128
- if (value === this.value.get()) return;
131
+ const value = this.options.get().find((option) => option.value === radio.dataset.value)?.value;
132
+ if (value === void 0 || value === this.value.get()) return;
129
133
  this.value.set(value);
130
134
  this.events.emit("change", value);
131
135
  }
@@ -195,7 +199,7 @@ var JlRadioGroup = class extends JlFormControl {
195
199
  this.internals.setValidity({});
196
200
  return;
197
201
  }
198
- this.internals.setValidity({ valueMissing: true }, VALUE_MISSING, this.radios()[0] ?? this._refs.group);
202
+ this.internals.setValidity({ valueMissing: true }, jlText("selectOption"), this.radios()[0] ?? this._refs.group);
199
203
  }
200
204
  };
201
205
  JlRadioGroup.register();
@@ -1,6 +1,7 @@
1
1
  import { BASE_STYLES } from "../styles/shared.js";
2
2
  import { JlElement } from "../base/jl-element.js";
3
3
  import { registerIcons } from "../lib/icons.js";
4
+ import { jlText } from "../lib/texts.js";
4
5
  import { JlIcon } from "../atoms/jl-icon.js";
5
6
  import { setOrRemove } from "../lib/dom.js";
6
7
  import { JlKbd } from "../atoms/jl-kbd.js";
@@ -11,7 +12,6 @@ import { Search } from "lucide";
11
12
  import { jsx, jsxs } from "@jadis/core/jsx-runtime";
12
13
  // src/molecules/jl-search-button.tsx
13
14
  registerIcons({ search: Search });
14
- var DEFAULT_LABEL = "Search";
15
15
  var DEFAULT_HOTKEY = "mod+k";
16
16
  var NO_HOTKEY = "none";
17
17
  var ICON_SIZE = 15;
@@ -26,14 +26,14 @@ var JlSearchButton = class extends JlElement {
26
26
  static selector = "jl-search-button";
27
27
  events = this.useEvents();
28
28
  /** The text, and the button's name: "Search". */
29
- label = this.useChange(DEFAULT_LABEL, () => this.renderLabel(), { attribute: "label" });
29
+ label = this.useChange(jlText("search"), () => this.renderLabel(), { attribute: "label" });
30
30
  /** The keys that open the palette, as `jl-kbd` writes them: `mod+k`; `none` for no keys. */
31
31
  hotkey = this.useChange(DEFAULT_HOTKEY, () => this.renderHotkey(), { attribute: "hotkey" });
32
32
  /** The icon alone, the label as its tooltip. */
33
33
  compact = this.useChange(false, (value) => this.reflect("compact", value), { attribute: "compact" });
34
34
  _refs = this.useRefs((ref) => ({
35
35
  button: ref("button"),
36
- keys: ref("jl-kbd"),
36
+ keys: ref(JlKbd),
37
37
  text: ref(".text")
38
38
  }));
39
39
  focus(options) {
@@ -63,7 +63,7 @@ var JlSearchButton = class extends JlElement {
63
63
  this.on(this._refs.button, "click", () => this.events.emit("press"));
64
64
  }
65
65
  renderLabel() {
66
- const label = this.label.get() || DEFAULT_LABEL;
66
+ const label = this.label.get() || jlText("search");
67
67
  this._refs.text.textContent = label;
68
68
  this._refs.button.setAttribute("aria-label", label);
69
69
  this._refs.button.title = label;
@@ -3,6 +3,7 @@ import { JlFormControl } from "../base/jl-form-control.js";
3
3
  import { oneOf } from "../lib/attributes.js";
4
4
  import { registerIcons } from "../lib/icons.js";
5
5
  import { CONTROL_SIZES } from "../lib/options.js";
6
+ import { jlText } from "../lib/texts.js";
6
7
  import { JlIcon } from "../atoms/jl-icon.js";
7
8
  import { setOrRemove } from "../lib/dom.js";
8
9
  import { JlSpinner } from "../atoms/jl-spinner.js";
@@ -19,7 +20,6 @@ registerIcons({
19
20
  var DEFAULT_DEBOUNCE_MS = 250;
20
21
  var ICON_SIZE = 16;
21
22
  var ACTION_ICON_SIZE = 14;
22
- var DEFAULT_LABEL = "Search";
23
23
  var MAC_PATTERN = /Mac|iPhone|iPad|iPod/;
24
24
  var TYPING_TARGETS = "input, textarea, select, [contenteditable]";
25
25
  var isMac = () => MAC_PATTERN.test(navigator.userAgent);
@@ -38,7 +38,7 @@ var JlSearch = class extends JlFormControl {
38
38
  value = this.useChange("", (value) => this.renderValue(value), { attribute: "value" });
39
39
  placeholder = this.useChange("", (value) => setOrRemove(this._refs.native, "placeholder", value), { attribute: "placeholder" });
40
40
  /** The field's name for screen readers; "Search" when nothing else names it. */
41
- label = this.useChange("", (value) => this._refs.native.setAttribute("aria-label", value || DEFAULT_LABEL), { attribute: "label" });
41
+ label = this.useChange("", (value) => this._refs.native.setAttribute("aria-label", value || jlText("search")), { attribute: "label" });
42
42
  /** How long typing must pause, in milliseconds, before `search` fires. */
43
43
  debounce = this.useChange(DEFAULT_DEBOUNCE_MS, () => void 0, { attribute: "debounce" });
44
44
  /** Keys that focus the field from anywhere: "/" or "mod+k" (⌘ on a Mac, Ctrl elsewhere). */
@@ -68,7 +68,7 @@ var JlSearch = class extends JlFormControl {
68
68
  icon: ref(".icon"),
69
69
  keys: ref(".keys"),
70
70
  native: ref("input"),
71
- spinner: ref("jl-spinner")
71
+ spinner: ref(JlSpinner)
72
72
  }));
73
73
  focus(options) {
74
74
  this._refs.native.focus(options);
@@ -108,7 +108,7 @@ var JlSearch = class extends JlFormControl {
108
108
  /* @__PURE__ */ jsx("button", {
109
109
  class: "action clear",
110
110
  type: "button",
111
- "aria-label": "Clear the search",
111
+ "aria-label": jlText("clearSearch"),
112
112
  tabIndex: -1,
113
113
  hidden: true,
114
114
  children: /* @__PURE__ */ jsx(JlIcon, {
@@ -3,21 +3,22 @@ import type { SegmentedOption } from '../types/jl-segmented.types';
3
3
  import type { ControlSize } from '../types/options.types';
4
4
  /**
5
5
  * A row of a few exclusive choices with a thumb that slides to the chosen one: a view switch, a period, a
6
- * density. It takes part in forms like a radio group; `change` fires with the value people pick.
6
+ * density. It takes part in forms like a radio group; `change` fires with the value people pick. Typed by its values,
7
+ * `JlSegmented<'list' | 'grid'>` takes options of those values and gives `change` one of them.
7
8
  */
8
- export declare class JlSegmented extends JlFormControl {
9
+ export declare class JlSegmented<Value extends string = string> extends JlFormControl {
9
10
  static readonly selector = "jl-segmented";
10
11
  readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
11
- change: string;
12
+ change: Value;
12
13
  }>>;
13
14
  readonly options: Readonly<Readonly<{
14
- get(): SegmentedOption[];
15
- set(setter: SegmentedOption[] | ((prevState: SegmentedOption[]) => SegmentedOption[])): void;
15
+ get(): SegmentedOption<Value>[];
16
+ set(setter: SegmentedOption<Value>[] | ((prevState: SegmentedOption<Value>[]) => SegmentedOption<Value>[])): void;
16
17
  }>>;
17
18
  /** The chosen option's value; the first option that can be chosen when it names none. */
18
19
  readonly value: Readonly<Readonly<{
19
- get(): string;
20
- set(setter: string | ((prevState: string) => string)): void;
20
+ get(): "" | Value;
21
+ set(setter: "" | Value | ((prevState: "" | Value) => "" | Value)): void;
21
22
  }>>;
22
23
  readonly size: Readonly<Readonly<{
23
24
  get(): ControlSize;
@@ -1,11 +1,12 @@
1
1
  import { BASE_STYLES } from "../styles/shared.js";
2
2
  import { JlFormControl } from "../base/jl-form-control.js";
3
- import { jsonOf, oneOf } from "../lib/attributes.js";
3
+ import { jsonOf, oneOf, textOf } from "../lib/attributes.js";
4
4
  import { CONTROL_SIZES } from "../lib/options.js";
5
5
  import { JlIcon } from "../atoms/jl-icon.js";
6
6
  import { setOrRemove } from "../lib/dom.js";
7
7
  import { firstIndex, lastIndex, stepIndex } from "../lib/roving.js";
8
8
  import { moveIndicator } from "../lib/indicator.js";
9
+ import { watchSizes } from "../lib/resize.js";
9
10
  import jl_segmented_default from "./jl-segmented.css_raw.js";
10
11
  import { css } from "@jadis/core";
11
12
  import { jsx, jsxs } from "@jadis/core/jsx-runtime";
@@ -15,6 +16,7 @@ var ICON_SIZES = {
15
16
  md: 16,
16
17
  sm: 14
17
18
  };
19
+ var NO_VALUE = "";
18
20
  var KEY_MOVES = /* @__PURE__ */ new Map([
19
21
  ["ArrowDown", (enabled, from) => stepIndex(enabled, from, 1)],
20
22
  ["ArrowLeft", (enabled, from) => stepIndex(enabled, from, -1)],
@@ -25,7 +27,8 @@ var KEY_MOVES = /* @__PURE__ */ new Map([
25
27
  ]);
26
28
  /**
27
29
  * A row of a few exclusive choices with a thumb that slides to the chosen one: a view switch, a period, a
28
- * density. It takes part in forms like a radio group; `change` fires with the value people pick.
30
+ * density. It takes part in forms like a radio group; `change` fires with the value people pick. Typed by its values,
31
+ * `JlSegmented<'list' | 'grid'>` takes options of those values and gives `change` one of them.
29
32
  */
30
33
  var JlSegmented = class extends JlFormControl {
31
34
  static selector = "jl-segmented";
@@ -35,7 +38,10 @@ var JlSegmented = class extends JlFormControl {
35
38
  parse: jsonOf([])
36
39
  });
37
40
  /** The chosen option's value; the first option that can be chosen when it names none. */
38
- value = this.useChange("", () => this.renderValue(), { attribute: "value" });
41
+ value = this.useChange(NO_VALUE, () => this.renderValue(), {
42
+ attribute: "value",
43
+ parse: textOf(NO_VALUE)
44
+ });
39
45
  size = this.useChange("md", (value) => {
40
46
  this.reflect("size", value);
41
47
  this.renderOptions();
@@ -55,7 +61,7 @@ var JlSegmented = class extends JlFormControl {
55
61
  /** The group's name for screen readers, when no visible label names it. */
56
62
  label = this.useChange("", (value) => setOrRemove(this._refs.group, "aria-label", value), { attribute: "label" });
57
63
  _state = { disabledByForm: false };
58
- _resize = new ResizeObserver(() => this.placeThumb());
64
+ _resize = watchSizes(() => this.placeThumb());
59
65
  _refs = this.useRefs((ref) => ({
60
66
  group: ref(".group"),
61
67
  thumb: ref(".thumb")
@@ -90,7 +96,7 @@ var JlSegmented = class extends JlFormControl {
90
96
  this._resize.disconnect();
91
97
  }
92
98
  resetValue() {
93
- this.value.set(this.getAttribute("value") ?? "");
99
+ this.value.set(textOf(NO_VALUE)(this.getAttribute("value")));
94
100
  }
95
101
  /** The browser calls it for a disabled fieldset and for the element's own `disabled`, even before it renders. */
96
102
  setDisabledByForm(disabled) {
@@ -154,7 +160,7 @@ var JlSegmented = class extends JlFormControl {
154
160
  this.value.set(option.value);
155
161
  return;
156
162
  }
157
- const value = option?.value ?? "";
163
+ const value = option?.value ?? NO_VALUE;
158
164
  this.segments().forEach((segment) => {
159
165
  const checked = segment.dataset.value === value;
160
166
  segment.setAttribute("aria-checked", String(checked));
@@ -1,3 +1,3 @@
1
1
  // src/molecules/jl-steps.css?raw
2
- var jl_steps_default = ":host {\n display: block;\n container-type: inline-size;\n --marker: 28px;\n}\n\nol {\n display: flex;\n padding: 0;\n list-style: none;\n}\n\n.step {\n display: flex;\n flex: 1;\n min-width: 0;\n}\n\n.step:last-child {\n flex: none;\n}\n\n.head {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n min-width: 0;\n padding: 0;\n border: none;\n border-radius: var(--jl-radius-xs);\n background: none;\n text-align: start;\n}\n\nbutton.head {\n cursor: pointer;\n}\n\n.marker {\n display: inline-flex;\n flex: none;\n align-items: center;\n justify-content: center;\n width: var(--marker);\n height: var(--marker);\n border: 1px solid var(--jl-line-strong);\n border-radius: 50%;\n background: var(--jl-surface);\n color: var(--jl-muted);\n font-size: var(--jl-font-sm);\n font-weight: 650;\n font-variant-numeric: tabular-nums;\n}\n\n.text {\n display: grid;\n gap: 2px;\n min-width: 0;\n padding-top: 4px;\n}\n\n.label {\n color: var(--jl-muted);\n font-size: var(--jl-font-md);\n font-weight: 600;\n line-height: 20px;\n}\n\n.description {\n color: var(--jl-muted);\n font-size: var(--jl-font-xs);\n line-height: 1.45;\n}\n\n.step[data-status=\"done\"] .marker {\n border-color: var(--jl-accent-line);\n background: var(--jl-accent-soft);\n color: var(--jl-accent);\n}\n\n.step[data-status=\"done\"] .label {\n color: var(--jl-text);\n}\n\n.step[data-status=\"current\"] .marker {\n border-color: var(--jl-accent);\n background: var(--jl-accent);\n color: var(--jl-on-accent);\n box-shadow: 0 0 0 4px var(--jl-accent-soft);\n}\n\n.step[data-status=\"current\"] .label {\n color: var(--jl-accent);\n font-weight: 700;\n}\n\nbutton.head:hover .label {\n text-decoration: underline;\n text-underline-offset: 3px;\n}\n\n.line {\n flex: 1;\n min-width: 24px;\n height: 1px;\n /* Further from the label before it than from the next marker: a label reads as its own step's. */\n margin: calc(var(--marker) / 2) 12px 0 20px;\n background: var(--jl-line-strong);\n}\n\n.step[data-status=\"done\"] .line {\n background: var(--jl-accent);\n}\n\n.step:last-child .line {\n display: none;\n}\n\n/* Vertical: the markers in a column joined by a rule, the text beside them. */\n:host([orientation=\"vertical\"]) ol {\n flex-direction: column;\n}\n\n:host([orientation=\"vertical\"]) .step {\n position: relative;\n flex: none;\n padding-bottom: 24px;\n}\n\n:host([orientation=\"vertical\"]) .step:last-child {\n padding-bottom: 0;\n}\n\n:host([orientation=\"vertical\"]) .line {\n position: absolute;\n top: calc(var(--marker) + 4px);\n bottom: 4px;\n left: calc(var(--marker) / 2 - 0.5px);\n width: 1px;\n height: auto;\n min-width: 0;\n margin: 0;\n}\n\n/* Narrow, the horizontal steps keep their markers and only the current step's text. */\n@container (width < 560px) {\n /* Out of sight, still read: the same rules as .sr-only. */\n :host(:not([orientation=\"vertical\"])) .step:not([data-status=\"current\"]) .text {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n\n :host(:not([orientation=\"vertical\"])) .description {\n display: none;\n }\n\n :host(:not([orientation=\"vertical\"])) .line {\n min-width: 8px;\n margin: calc(var(--marker) / 2) 8px 0;\n }\n\n /* The current step takes three shares of the room, the others one, never less than their marker and line: the\n label never runs into the next step, and takes an ellipsis only when there is no room at all. */\n :host(:not([orientation=\"vertical\"])) .step:not([data-status=\"current\"]) {\n min-width: min-content;\n }\n\n :host(:not([orientation=\"vertical\"])) .step[data-status=\"current\"] {\n flex: 3 1 0;\n }\n\n :host(:not([orientation=\"vertical\"])) .step[data-status=\"current\"] .label {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n :host(:not([orientation=\"vertical\"])) .step[data-status=\"current\"] .line {\n min-width: 24px;\n margin-left: 16px;\n }\n}\n";
2
+ var jl_steps_default = ":host {\n display: block;\n container-type: inline-size;\n --marker: 28px;\n}\n\nol {\n display: flex;\n padding: 0;\n list-style: none;\n}\n\n.step {\n display: flex;\n flex: 1;\n min-width: 0;\n}\n\n.step:last-child {\n flex: none;\n}\n\n.head {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n min-width: 0;\n padding: 0;\n border: none;\n border-radius: var(--jl-radius-xs);\n background: none;\n text-align: start;\n}\n\nbutton.head {\n cursor: pointer;\n}\n\n.marker {\n display: inline-flex;\n flex: none;\n align-items: center;\n justify-content: center;\n width: var(--marker);\n height: var(--marker);\n border: 1px solid var(--jl-line-strong);\n border-radius: 50%;\n background: var(--jl-surface);\n color: var(--jl-muted);\n font-size: var(--jl-font-sm);\n font-weight: 650;\n font-variant-numeric: tabular-nums;\n}\n\n.text {\n display: grid;\n gap: 2px;\n min-width: 0;\n padding-top: 4px;\n}\n\n.label {\n color: var(--jl-muted);\n font-size: var(--jl-font-md);\n font-weight: 600;\n line-height: 20px;\n}\n\n.description {\n color: var(--jl-muted);\n font-size: var(--jl-font-xs);\n line-height: 1.45;\n}\n\n.step[data-status=\"done\"] .marker {\n border-color: var(--jl-accent-line);\n background: var(--jl-accent-soft);\n color: var(--jl-accent);\n}\n\n.step[data-status=\"done\"] .label {\n color: var(--jl-text);\n}\n\n.step[data-status=\"current\"] .marker {\n border-color: var(--jl-accent);\n background: var(--jl-accent);\n color: var(--jl-on-accent);\n box-shadow: 0 0 0 4px var(--jl-accent-soft);\n}\n\n.step[data-status=\"current\"] .label {\n color: var(--jl-accent);\n font-weight: 700;\n}\n\n.step[data-failed] .marker {\n border-color: color-mix(in srgb, var(--jl-danger) 40%, var(--jl-line));\n background: var(--jl-danger-soft);\n color: var(--jl-danger);\n box-shadow: none;\n}\n\n.step[data-failed] .label {\n color: var(--jl-danger);\n}\n\nbutton.head:hover .label {\n text-decoration: underline;\n text-underline-offset: 3px;\n}\n\n.line {\n flex: 1;\n min-width: 24px;\n height: 1px;\n /* Further from the label before it than from the next marker: a label reads as its own step's. */\n margin: calc(var(--marker) / 2) 12px 0 20px;\n background: var(--jl-line-strong);\n}\n\n.step[data-status=\"done\"] .line {\n background: var(--jl-accent);\n}\n\n.step:last-child .line {\n display: none;\n}\n\n/* Vertical: the markers in a column joined by a rule, the text beside them. */\n:host([orientation=\"vertical\"]) ol {\n flex-direction: column;\n}\n\n:host([orientation=\"vertical\"]) .step {\n position: relative;\n flex: none;\n padding-bottom: 24px;\n}\n\n:host([orientation=\"vertical\"]) .step:last-child {\n padding-bottom: 0;\n}\n\n:host([orientation=\"vertical\"]) .line {\n position: absolute;\n top: calc(var(--marker) + 4px);\n bottom: 4px;\n left: calc(var(--marker) / 2 - 0.5px);\n width: 1px;\n height: auto;\n min-width: 0;\n margin: 0;\n}\n\n/* Narrow, the horizontal steps keep their markers and only the current step's text. */\n@container (width < 560px) {\n /* Out of sight, still read: the same rules as .sr-only. */\n :host(:not([orientation=\"vertical\"])) .step:not([data-status=\"current\"]) .text {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n\n :host(:not([orientation=\"vertical\"])) .description {\n display: none;\n }\n\n :host(:not([orientation=\"vertical\"])) .line {\n min-width: 8px;\n margin: calc(var(--marker) / 2) 8px 0;\n }\n\n /* The current step takes three shares of the room, the others one, never less than their marker and line: the\n label never runs into the next step, and takes an ellipsis only when there is no room at all. */\n :host(:not([orientation=\"vertical\"])) .step:not([data-status=\"current\"]) {\n min-width: min-content;\n }\n\n :host(:not([orientation=\"vertical\"])) .step[data-status=\"current\"] {\n flex: 3 1 0;\n }\n\n :host(:not([orientation=\"vertical\"])) .step[data-status=\"current\"] .label {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n :host(:not([orientation=\"vertical\"])) .step[data-status=\"current\"] .line {\n min-width: 24px;\n margin-left: 16px;\n }\n}\n";
3
3
  export { jl_steps_default as default };
@@ -38,6 +38,8 @@ export declare class JlSteps extends JlElement {
38
38
  templateCss(): string;
39
39
  onConnect(): void;
40
40
  private render;
41
+ /** A failed step's ×, a done one's check, or the step's number. */
42
+ private markerOf;
41
43
  private step;
42
44
  /** Goes back to a done step people picked, and says so. */
43
45
  private goBackTo;
@@ -2,21 +2,28 @@ import { BASE_STYLES } from "../styles/shared.js";
2
2
  import { JlElement } from "../base/jl-element.js";
3
3
  import { clampedNumber, jsonOf, oneOf } 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_steps_default from "./jl-steps.css_raw.js";
7
8
  import { css } from "@jadis/core";
8
- import { Check } from "lucide";
9
+ import { Check, X } from "lucide";
9
10
  import { jsx, jsxs } from "@jadis/core/jsx-runtime";
10
11
  // src/molecules/jl-steps.tsx
11
- registerIcons({ check: Check });
12
+ registerIcons({
13
+ check: Check,
14
+ x: X
15
+ });
12
16
  var STEPS_ORIENTATIONS = ["horizontal", "vertical"];
13
17
  var CHECK_SIZE = 14;
14
18
  var MAX_STEPS = 100;
15
- var DEFAULT_LABEL = "Progress";
16
- var STATUS_TEXT = {
17
- current: ", current step",
18
- done: ", completed",
19
- upcoming: ""
19
+ var STATUS_TEXTS = {
20
+ current: "stepCurrent",
21
+ done: "stepDone",
22
+ upcoming: null
23
+ };
24
+ var statusText = (status) => {
25
+ const key = STATUS_TEXTS[status];
26
+ return key === null ? "" : jlText(key);
20
27
  };
21
28
  var statusOf = (index, current) => {
22
29
  if (index < current) return "done";
@@ -45,8 +52,8 @@ var JlSteps = class extends JlElement {
45
52
  /** Done steps become buttons that go back to them. */
46
53
  clickable = this.useChange(false, () => this.render(), { attribute: "clickable" });
47
54
  /** The list's name for screen readers. */
48
- label = this.useChange(DEFAULT_LABEL, (value) => {
49
- this._refs.list.setAttribute("aria-label", value || DEFAULT_LABEL);
55
+ label = this.useChange(jlText("progress"), (value) => {
56
+ this._refs.list.setAttribute("aria-label", value || jlText("progress"));
50
57
  }, { attribute: "label" });
51
58
  _refs = this.useRefs((ref) => ({ list: ref("ol") }));
52
59
  templateHtml() {
@@ -65,21 +72,29 @@ var JlSteps = class extends JlElement {
65
72
  const current = this.current.get();
66
73
  this._refs.list.replaceChildren(...this.items.get().map((item, index) => this.step(item, index, statusOf(index, current))));
67
74
  }
75
+ /** A failed step's ×, a done one's check, or the step's number. */
76
+ markerOf(item, index, status) {
77
+ if (item.failed) return /* @__PURE__ */ jsx(JlIcon, {
78
+ name: "x",
79
+ size: CHECK_SIZE
80
+ });
81
+ return status === "done" ? /* @__PURE__ */ jsx(JlIcon, {
82
+ name: "check",
83
+ size: CHECK_SIZE
84
+ }) : String(index + 1);
85
+ }
68
86
  step(item, index, status) {
69
87
  const content = [/* @__PURE__ */ jsx("span", {
70
88
  class: "marker",
71
89
  "aria-hidden": "true",
72
- children: status === "done" ? /* @__PURE__ */ jsx(JlIcon, {
73
- name: "check",
74
- size: CHECK_SIZE
75
- }) : String(index + 1)
90
+ children: this.markerOf(item, index, status)
76
91
  }), /* @__PURE__ */ jsxs("span", {
77
92
  class: "text",
78
93
  children: [/* @__PURE__ */ jsxs("span", {
79
94
  class: "label",
80
95
  children: [item.label, /* @__PURE__ */ jsx("span", {
81
96
  class: "sr-only",
82
- children: STATUS_TEXT[status]
97
+ children: item.failed ? jlText("failedStep") : statusText(status)
83
98
  })]
84
99
  }), item.description === void 0 ? "" : /* @__PURE__ */ jsx("span", {
85
100
  class: "description",
@@ -90,6 +105,7 @@ var JlSteps = class extends JlElement {
90
105
  return /* @__PURE__ */ jsxs("li", {
91
106
  class: "step",
92
107
  "data-status": status,
108
+ "data-failed": item.failed ? "" : void 0,
93
109
  "aria-current": status === "current" ? "step" : void 0,
94
110
  children: [canGoBack ? /* @__PURE__ */ jsx("button", {
95
111
  type: "button",
@@ -6,6 +6,7 @@ import { JlIcon } from "../atoms/jl-icon.js";
6
6
  import { setOrRemove, uniqueId } from "../lib/dom.js";
7
7
  import { firstIndex, lastIndex, stepIndex } from "../lib/roving.js";
8
8
  import { moveIndicator } from "../lib/indicator.js";
9
+ import { watchSizes } from "../lib/resize.js";
9
10
  import { JlTabPanel } from "./jl-tab-panel.js";
10
11
  import jl_tabs_default from "./jl-tabs.css_raw.js";
11
12
  import { css } from "@jadis/core";
@@ -55,7 +56,7 @@ var JlTabs = class extends JlElement {
55
56
  label = this.useChange("", (value) => setOrRemove(this._refs.list, "aria-label", value), { attribute: "label" });
56
57
  _observers = {
57
58
  mutations: new MutationObserver((records) => this.onMutations(records)),
58
- resize: new ResizeObserver(() => this.placeIndicator())
59
+ resize: watchSizes(() => this.placeIndicator())
59
60
  };
60
61
  _refs = this.useRefs((ref) => ({
61
62
  indicator: ref(".indicator"),
@@ -4,6 +4,7 @@ import { clampedNumber, jsonOf, oneOf } from "../lib/attributes.js";
4
4
  import { followAnchor } from "../lib/floating.js";
5
5
  import { registerIcons } from "../lib/icons.js";
6
6
  import { CONTROL_SIZES } from "../lib/options.js";
7
+ import { jlText } from "../lib/texts.js";
7
8
  import { JlIcon } from "../atoms/jl-icon.js";
8
9
  import { setOrRemove, uniqueId } from "../lib/dom.js";
9
10
  import { keepInView } from "../lib/keep-in-view.js";
@@ -18,7 +19,6 @@ registerIcons({ x: X });
18
19
  var REMOVE_ICON_SIZE = 12;
19
20
  var NONE = -1;
20
21
  var PLACEMENT = "bottom-start";
21
- var VALUE_MISSING = "Add at least one tag.";
22
22
  var NO_LIMIT = 0;
23
23
  var COMMA = ",";
24
24
  var MAX_SUGGESTIONS = 8;
@@ -413,7 +413,7 @@ var JlTagInput = class extends JlFormControl {
413
413
  }
414
414
  renderValidity() {
415
415
  if (this.required.get() && this.value.get().length === 0) {
416
- this.internals.setValidity({ valueMissing: true }, VALUE_MISSING, this._refs.native);
416
+ this.internals.setValidity({ valueMissing: true }, jlText("addTag"), this._refs.native);
417
417
  return;
418
418
  }
419
419
  this.internals.setValidity({});
@@ -1,3 +1,3 @@
1
1
  // src/molecules/jl-toast.css?raw
2
- var jl_toast_default = ":host {\n display: block;\n /* Coloured as jl-alert is, from the same tokens: a toned toast is tinted, its border and icon in its tone. */\n --fg: var(--jl-text-2);\n --bg: var(--jl-surface);\n --border: var(--jl-line);\n --bar: var(--jl-brand);\n}\n\n:host([tone=\"ok\"]),\n:host([tone=\"warn\"]),\n:host([tone=\"danger\"]),\n:host([tone=\"info\"]) {\n --border: color-mix(in srgb, var(--fg) 24%, var(--bg));\n --bar: var(--fg);\n}\n\n:host([tone=\"ok\"]) {\n --fg: var(--jl-ok);\n --bg: var(--jl-ok-soft);\n}\n\n:host([tone=\"warn\"]) {\n --fg: var(--jl-warn);\n --bg: var(--jl-warn-soft);\n}\n\n:host([tone=\"danger\"]) {\n --fg: var(--jl-danger);\n --bg: var(--jl-danger-soft);\n}\n\n:host([tone=\"info\"]) {\n --fg: var(--jl-info);\n --bg: var(--jl-info-soft);\n}\n\n.toast {\n position: relative;\n display: flex;\n align-items: flex-start;\n gap: 12px;\n padding: 14px 12px 14px 16px;\n overflow: hidden;\n border: 1px solid var(--border);\n border-radius: var(--jl-radius-lg);\n background: var(--bg);\n color: var(--jl-text);\n font-size: var(--jl-font-md);\n line-height: 20px;\n box-shadow: var(--jl-shadow-lg);\n}\n\n.icon {\n margin-top: 1px;\n color: var(--fg);\n}\n\n.content {\n display: grid;\n flex: 1;\n gap: 2px;\n min-width: 0;\n overflow-wrap: anywhere;\n}\n\n.heading {\n font-weight: 650;\n}\n\n.text {\n color: var(--jl-muted);\n font-size: var(--jl-font-sm);\n}\n\n.heading[hidden] + .text {\n color: var(--jl-text-2);\n font-size: var(--jl-font-md);\n}\n\n.buttons {\n display: flex;\n flex: none;\n align-items: center;\n gap: 2px;\n margin: -5px -4px -5px 0;\n}\n\n.buttons:not(:has(jl-button:not([hidden]))) {\n display: none;\n}\n\n.close {\n --jl-accent: var(--fg);\n --jl-accent-soft: color-mix(in srgb, var(--fg) 12%, transparent);\n}\n\n.progress {\n position: absolute;\n right: 0;\n bottom: 0;\n left: 0;\n height: 2px;\n}\n\n.bar {\n height: 100%;\n background: var(--bar);\n transform-origin: left center;\n}\n\n:host([paused]) .bar {\n opacity: 0.55;\n}\n\n/* The line still counts the time, but does not move for people who asked for less motion. */\n@media (prefers-reduced-motion: reduce) {\n .progress {\n visibility: hidden;\n }\n}\n";
2
+ var jl_toast_default = ":host {\n display: block;\n /* Coloured as jl-alert is, from the same tokens: a toned toast is tinted, its border and icon in its tone. */\n --fg: var(--jl-text-2);\n --bg: var(--jl-surface);\n --border: var(--jl-line);\n --bar: var(--jl-brand);\n}\n\n:host([tone=\"ok\"]),\n:host([tone=\"warn\"]),\n:host([tone=\"danger\"]),\n:host([tone=\"info\"]) {\n --border: color-mix(in srgb, var(--fg) 24%, var(--bg));\n --bar: var(--fg);\n}\n\n:host([tone=\"ok\"]) {\n --fg: var(--jl-ok);\n --bg: var(--jl-ok-soft);\n}\n\n:host([tone=\"warn\"]) {\n --fg: var(--jl-warn);\n --bg: var(--jl-warn-soft);\n}\n\n:host([tone=\"danger\"]) {\n --fg: var(--jl-danger);\n --bg: var(--jl-danger-soft);\n}\n\n:host([tone=\"info\"]) {\n --fg: var(--jl-info);\n --bg: var(--jl-info-soft);\n}\n\n.toast {\n position: relative;\n display: flex;\n align-items: flex-start;\n gap: 12px;\n padding: 14px 12px 14px 16px;\n overflow: hidden;\n border: 1px solid var(--border);\n border-radius: var(--jl-radius-lg);\n background: var(--bg);\n color: var(--jl-text);\n font-size: var(--jl-font-md);\n line-height: 20px;\n box-shadow: var(--jl-shadow-lg);\n}\n\n.icon {\n margin-top: 1px;\n color: var(--fg);\n}\n\n.content {\n display: grid;\n flex: 1;\n gap: 2px;\n min-width: 0;\n overflow-wrap: anywhere;\n}\n\n.heading {\n font-weight: 650;\n}\n\n.text {\n color: var(--jl-muted);\n font-size: var(--jl-font-sm);\n}\n\n.heading[hidden] + .text {\n color: var(--jl-text-2);\n font-size: var(--jl-font-md);\n}\n\n.buttons {\n display: flex;\n flex: none;\n align-items: center;\n gap: 2px;\n margin: -5px -4px -5px 0;\n}\n\n.buttons:not(:has(jl-button:not([hidden]))) {\n display: none;\n}\n\n.close {\n --jl-accent: var(--fg);\n --jl-accent-soft: color-mix(in srgb, var(--fg) 12%, transparent);\n}\n\n.work {\n margin-top: 8px;\n}\n\n.progress {\n position: absolute;\n right: 0;\n bottom: 0;\n left: 0;\n height: 2px;\n}\n\n.bar {\n height: 100%;\n background: var(--bar);\n transform-origin: left center;\n}\n\n:host([paused]) .bar {\n opacity: 0.55;\n}\n\n/* The line still counts the time, but does not move for people who asked for less motion. */\n@media (prefers-reduced-motion: reduce) {\n .progress {\n visibility: hidden;\n }\n}\n";
3
3
  export { jl_toast_default as default };
@@ -4,7 +4,9 @@ export declare const TOAST_TONES: readonly ToastTone[];
4
4
  /**
5
5
  * One notification: a heading, a line of text, an icon in its tone's colour, and maybe an action such as "Undo".
6
6
  * With a `duration` it closes by itself, a thin line showing the time left; hovering or focusing it pauses the
7
- * line. It emits `dismiss` once it has closed. Most pages call `toast()` rather than writing it.
7
+ * line. While `working`, it shows the progress of the work it tells about (a download): `progress` percent, or a
8
+ * bar running back and forth without it. It emits `dismiss` once it has closed. Most pages call `toast()` rather
9
+ * than writing it.
8
10
  */
9
11
  export declare class JlToast extends JlElement {
10
12
  static readonly selector = "jl-toast";
@@ -44,6 +46,16 @@ export declare class JlToast extends JlElement {
44
46
  get(): number;
45
47
  set(setter: number | ((prevState: number) => number)): void;
46
48
  }>>;
49
+ /** Shows a progress bar under the text, while the work it tells about runs. */
50
+ readonly working: Readonly<Readonly<{
51
+ get(): boolean;
52
+ set(setter: boolean | ((prevState: boolean) => boolean)): void;
53
+ }>>;
54
+ /** How far the work is, in percent; `null` (no attribute) for work of unknown length. */
55
+ readonly progress: Readonly<Readonly<{
56
+ get(): number | null;
57
+ set(setter: number | ((prevState: number | null) => number | null) | null): void;
58
+ }>>;
47
59
  private readonly _timer;
48
60
  private readonly _hold;
49
61
  private readonly _refs;
@@ -3,8 +3,11 @@ import { JlElement } from "../base/jl-element.js";
3
3
  import { oneOf } from "../lib/attributes.js";
4
4
  import { registerIcons } from "../lib/icons.js";
5
5
  import { TONE_ICONS, TONE_ICON_FILLED } from "../lib/options.js";
6
+ import { jlText } from "../lib/texts.js";
6
7
  import { JlIcon } from "../atoms/jl-icon.js";
7
8
  import { JlButton } from "../atoms/jl-button.js";
9
+ import { optionalNumber } from "../lib/progress.js";
10
+ import { JlProgress } from "../atoms/jl-progress.js";
8
11
  import jl_toast_default from "./jl-toast.css_raw.js";
9
12
  import { css } from "@jadis/core";
10
13
  import { CircleCheck, CircleX, Info, Sparkles, TriangleAlert, X } from "lucide";
@@ -45,7 +48,9 @@ var prefersReducedMotion = () => window.matchMedia(REDUCED_MOTION).matches;
45
48
  /**
46
49
  * One notification: a heading, a line of text, an icon in its tone's colour, and maybe an action such as "Undo".
47
50
  * With a `duration` it closes by itself, a thin line showing the time left; hovering or focusing it pauses the
48
- * line. It emits `dismiss` once it has closed. Most pages call `toast()` rather than writing it.
51
+ * line. While `working`, it shows the progress of the work it tells about (a download): `progress` percent, or a
52
+ * bar running back and forth without it. It emits `dismiss` once it has closed. Most pages call `toast()` rather
53
+ * than writing it.
49
54
  */
50
55
  var JlToast = class extends JlElement {
51
56
  static selector = "jl-toast";
@@ -79,6 +84,15 @@ var JlToast = class extends JlElement {
79
84
  }, { attribute: "action-label" });
80
85
  /** How long it stays, in milliseconds; 0 keeps it until it is closed. */
81
86
  duration = this.useChange(0, () => this.startTimer(), { attribute: "duration" });
87
+ /** Shows a progress bar under the text, while the work it tells about runs. */
88
+ working = this.useChange(false, (value) => {
89
+ this._refs.work.hidden = !value;
90
+ }, { attribute: "working" });
91
+ /** How far the work is, in percent; `null` (no attribute) for work of unknown length. */
92
+ progress = this.useChange(null, (value) => this._refs.work.value.set(value), {
93
+ attribute: "progress",
94
+ parse: optionalNumber
95
+ });
82
96
  _timer = {
83
97
  animation: null,
84
98
  entered: false
@@ -95,7 +109,8 @@ var JlToast = class extends JlElement {
95
109
  icon: ref(".icon"),
96
110
  progress: ref(".progress"),
97
111
  text: ref(".text"),
98
- toast: ref(".toast")
112
+ toast: ref(".toast"),
113
+ work: ref(JlProgress)
99
114
  }));
100
115
  /** Closes the toast: it leaves, hides, then emits `dismiss`. */
101
116
  dismiss() {
@@ -146,6 +161,11 @@ var JlToast = class extends JlElement {
146
161
  class: "text",
147
162
  hidden: true
148
163
  }),
164
+ /* @__PURE__ */ jsx(JlProgress, {
165
+ class: "work",
166
+ size: "sm",
167
+ hidden: true
168
+ }),
149
169
  /* @__PURE__ */ jsx("slot", {})
150
170
  ]
151
171
  }),
@@ -161,7 +181,7 @@ var JlToast = class extends JlElement {
161
181
  variant: "ghost",
162
182
  size: "sm",
163
183
  icon: "x",
164
- hint: "Close",
184
+ hint: jlText("close"),
165
185
  hidden: true
166
186
  })]
167
187
  }),
@@ -1,3 +1,3 @@
1
1
  // src/organisms/jl-command-palette.css?raw
2
- var jl_command_palette_default = ":host {\n display: contents;\n}\n\ndialog {\n flex-direction: column;\n width: min(620px, calc(100vw - 24px));\n max-width: none;\n max-height: min(520px, calc(100dvh - 24vh));\n margin: 12vh auto auto;\n padding: 0;\n overflow: hidden;\n border: 1px solid var(--jl-line);\n border-radius: var(--jl-radius-lg);\n background: var(--jl-surface);\n color: var(--jl-text);\n font-size: var(--jl-font-md);\n box-shadow: var(--jl-shadow-lg);\n}\n\ndialog[open] {\n display: flex;\n animation: drop var(--jl-fast) var(--jl-ease);\n}\n\ndialog::backdrop {\n background: var(--jl-scrim);\n backdrop-filter: blur(2px);\n}\n\n.search {\n display: flex;\n flex: none;\n align-items: center;\n gap: 10px;\n height: 52px;\n padding: 0 14px 0 16px;\n border-bottom: 1px solid var(--jl-line);\n}\n\n.search-icon {\n color: var(--jl-faint);\n}\n\ninput {\n flex: 1;\n min-width: 0;\n height: 100%;\n padding: 0;\n border: none;\n outline: none;\n background: none;\n /* At least the text of fields: 16px on touch screens, where phones zoom into smaller text. */\n font-size: max(15px, var(--jl-control-font));\n}\n\ninput::placeholder {\n color: var(--jl-faint);\n}\n\ninput:focus-visible {\n box-shadow: none;\n}\n\nkbd {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 20px;\n height: 20px;\n padding: 0 5px;\n border: 1px solid var(--jl-line-strong);\n border-bottom-width: 2px;\n border-radius: var(--jl-radius-xs);\n background: var(--jl-surface);\n color: var(--jl-muted);\n font-size: 11px;\n font-weight: 500;\n line-height: 1;\n}\n\n.results {\n flex: 1;\n min-height: 0;\n padding: 6px;\n overflow-y: auto;\n overscroll-behavior: contain;\n scroll-padding: 6px;\n}\n\n[role=\"group\"] + [role=\"group\"] {\n margin-top: 4px;\n padding-top: 4px;\n border-top: 1px solid var(--jl-line-soft);\n}\n\n.group-label {\n padding: 8px 10px 4px;\n color: var(--jl-muted);\n font-size: var(--jl-font-xs);\n font-weight: 600;\n}\n\n.option {\n display: flex;\n align-items: center;\n gap: 10px;\n min-height: 38px;\n padding: 0 10px;\n border-radius: var(--jl-radius-sm);\n color: var(--jl-text-2);\n cursor: pointer;\n}\n\n.option[aria-selected=\"true\"] {\n background: var(--jl-accent-soft);\n color: var(--jl-text);\n}\n\n.option-icon {\n flex: none;\n width: 16px;\n color: var(--jl-muted);\n}\n\n.option[aria-selected=\"true\"] .option-icon {\n color: var(--jl-accent);\n}\n\n.option-label {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\nmark {\n background: none;\n color: var(--jl-accent);\n font-weight: 700;\n}\n\n.keys {\n display: inline-flex;\n flex: none;\n gap: 3px;\n}\n\n.empty {\n padding: 36px 16px;\n color: var(--jl-muted);\n text-align: center;\n}\n\nfooter {\n display: flex;\n flex: none;\n flex-wrap: wrap;\n align-items: center;\n gap: 6px 16px;\n padding: 8px 16px;\n border-top: 1px solid var(--jl-line);\n background: var(--jl-surface-2);\n color: var(--jl-muted);\n font-size: var(--jl-font-xs);\n}\n\n.hint,\n.hotkey-keys {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n}\n\n.hotkey-hint {\n margin-left: auto;\n}\n\n@media (width < 520px) {\n dialog {\n margin-top: 12px;\n max-height: calc(100dvh - 24px);\n }\n\n .hotkey-hint {\n display: none;\n }\n}\n\n@keyframes drop {\n from {\n opacity: 0;\n transform: translateY(-6px) scale(0.98);\n }\n}\n";
2
+ var jl_command_palette_default = ":host {\n display: contents;\n}\n\ndialog {\n flex-direction: column;\n width: min(620px, calc(100vw - 24px));\n max-width: none;\n max-height: min(520px, calc(100dvh - 24vh));\n margin: 12vh auto auto;\n padding: 0;\n overflow: hidden;\n border: 1px solid var(--jl-line);\n border-radius: var(--jl-radius-lg);\n background: var(--jl-surface);\n color: var(--jl-text);\n font-size: var(--jl-font-md);\n box-shadow: var(--jl-shadow-lg);\n}\n\ndialog[open] {\n display: flex;\n animation: drop var(--jl-fast) var(--jl-ease);\n}\n\ndialog::backdrop {\n background: var(--jl-scrim);\n backdrop-filter: blur(2px);\n}\n\n.search {\n display: flex;\n flex: none;\n align-items: center;\n gap: 10px;\n height: 52px;\n padding: 0 14px 0 16px;\n border-bottom: 1px solid var(--jl-line);\n}\n\n.search-icon,\n.search-spinner {\n flex: none;\n color: var(--jl-faint);\n}\n\ninput {\n flex: 1;\n min-width: 0;\n height: 100%;\n padding: 0;\n border: none;\n outline: none;\n background: none;\n /* At least the text of fields: 16px on touch screens, where phones zoom into smaller text. */\n font-size: max(15px, var(--jl-control-font));\n}\n\ninput::placeholder {\n color: var(--jl-faint);\n}\n\ninput:focus-visible {\n box-shadow: none;\n}\n\nkbd {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 20px;\n height: 20px;\n padding: 0 5px;\n border: 1px solid var(--jl-line-strong);\n border-bottom-width: 2px;\n border-radius: var(--jl-radius-xs);\n background: var(--jl-surface);\n color: var(--jl-muted);\n font-size: 11px;\n font-weight: 500;\n line-height: 1;\n}\n\n.results {\n flex: 1;\n min-height: 0;\n padding: 6px;\n overflow-y: auto;\n overscroll-behavior: contain;\n scroll-padding: 6px;\n}\n\n[role=\"group\"] + [role=\"group\"] {\n margin-top: 4px;\n padding-top: 4px;\n border-top: 1px solid var(--jl-line-soft);\n}\n\n.group-label {\n padding: 8px 10px 4px;\n color: var(--jl-muted);\n font-size: var(--jl-font-xs);\n font-weight: 600;\n}\n\n.option {\n display: flex;\n align-items: center;\n gap: 10px;\n min-height: 38px;\n padding: 0 10px;\n border-radius: var(--jl-radius-sm);\n color: var(--jl-text-2);\n cursor: pointer;\n}\n\n.option[aria-selected=\"true\"] {\n background: var(--jl-accent-soft);\n color: var(--jl-text);\n}\n\n.option-icon {\n flex: none;\n width: 16px;\n color: var(--jl-muted);\n}\n\n.option[aria-selected=\"true\"] .option-icon {\n color: var(--jl-accent);\n}\n\n.option-label {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.option-description {\n flex: none;\n max-width: 40%;\n overflow: hidden;\n color: var(--jl-muted);\n font-size: var(--jl-font-xs);\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\nmark {\n background: none;\n color: var(--jl-accent);\n font-weight: 700;\n}\n\n.keys {\n display: inline-flex;\n flex: none;\n gap: 3px;\n}\n\n.empty {\n padding: 36px 16px;\n color: var(--jl-muted);\n text-align: center;\n}\n\nfooter {\n display: flex;\n flex: none;\n flex-wrap: wrap;\n align-items: center;\n gap: 6px 16px;\n padding: 8px 16px;\n border-top: 1px solid var(--jl-line);\n background: var(--jl-surface-2);\n color: var(--jl-muted);\n font-size: var(--jl-font-xs);\n}\n\n.hint,\n.hotkey-keys {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n}\n\n.hotkey-hint {\n margin-left: auto;\n}\n\n@media (width < 520px) {\n dialog {\n margin-top: 12px;\n max-height: calc(100dvh - 24px);\n }\n\n .hotkey-hint {\n display: none;\n }\n}\n\n@keyframes drop {\n from {\n opacity: 0;\n transform: translateY(-6px) scale(0.98);\n }\n}\n";
3
3
  export { jl_command_palette_default as default };
@@ -4,17 +4,21 @@ import type { PaletteCommand } from '../types/jl-command-palette.types';
4
4
  * A search box over every command of an app, opened by ⌘K (Ctrl+K off Apple) or `show()`. Typing filters the
5
5
  * commands by their letters in order, best matches first, under their groups; arrows move, Enter runs the command
6
6
  * (`select` with its id) and Escape closes. It sits near the top of the window, on the browser's modal `<dialog>`.
7
+ * Typed by its ids, `JlCommandPalette<'theme' | 'logout'>` takes commands of those ids and gives `select` one of
8
+ * them.
7
9
  */
8
- export declare class JlCommandPalette extends JlElement {
10
+ export declare class JlCommandPalette<Id extends string = string> extends JlElement {
9
11
  static readonly selector = "jl-command-palette";
12
+ /** `search`: what was typed, once typing pauses (and empty when it opens), for a page that answers it. */
10
13
  readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
11
- select: string;
14
+ select: Id;
12
15
  open: undefined;
13
16
  close: undefined;
17
+ search: string;
14
18
  }>>;
15
19
  readonly commands: Readonly<Readonly<{
16
- get(): PaletteCommand[];
17
- set(setter: PaletteCommand[] | ((prevState: PaletteCommand[]) => PaletteCommand[])): void;
20
+ get(): PaletteCommand<Id>[];
21
+ set(setter: PaletteCommand<Id>[] | ((prevState: PaletteCommand<Id>[]) => PaletteCommand<Id>[])): void;
18
22
  }>>;
19
23
  readonly open: Readonly<Readonly<{
20
24
  get(): boolean;
@@ -34,6 +38,16 @@ export declare class JlCommandPalette extends JlElement {
34
38
  get(): string;
35
39
  set(setter: string | ((prevState: string) => string)): void;
36
40
  }>>;
41
+ /** How long typing pauses, in milliseconds, before `search` fires. */
42
+ readonly debounce: Readonly<Readonly<{
43
+ get(): number;
44
+ set(setter: number | ((prevState: number) => number)): void;
45
+ }>>;
46
+ /** Shows a spinner in place of the search icon, while the page looks for what was typed. */
47
+ readonly loading: Readonly<Readonly<{
48
+ get(): boolean;
49
+ set(setter: boolean | ((prevState: boolean) => boolean)): void;
50
+ }>>;
37
51
  /** The dialog's name for screen readers. */
38
52
  readonly label: Readonly<Readonly<{
39
53
  get(): string;
@@ -52,6 +66,8 @@ export declare class JlCommandPalette extends JlElement {
52
66
  private move;
53
67
  private choose;
54
68
  private renderOpen;
69
+ private scheduleSearch;
70
+ private search;
55
71
  private renderHotkey;
56
72
  private renderResults;
57
73
  private groupNode;