@syware/jlib 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +2 -1
  2. package/dist/all.js +3 -3
  3. package/dist/atoms/jl-chip.d.ts +1 -0
  4. package/dist/atoms/jl-chip.js +4 -2
  5. package/dist/atoms/jl-input.d.ts +2 -0
  6. package/dist/atoms/jl-input.js +9 -3
  7. package/dist/atoms/jl-rating.d.ts +2 -0
  8. package/dist/atoms/jl-rating.js +13 -5
  9. package/dist/atoms/jl-select.d.ts +8 -7
  10. package/dist/atoms/jl-select.js +11 -6
  11. package/dist/atoms/jl-spinner.d.ts +2 -0
  12. package/dist/atoms/jl-spinner.js +6 -2
  13. package/dist/base/jl-element.d.ts +6 -0
  14. package/dist/base/jl-element.js +5 -0
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +3 -3
  17. package/dist/lib/attributes.d.ts +9 -0
  18. package/dist/lib/attributes.js +10 -1
  19. package/dist/lib/nav-tree.d.ts +2 -2
  20. package/dist/lib/palette.d.ts +2 -2
  21. package/dist/lib/table.d.ts +19 -6
  22. package/dist/lib/table.js +42 -7
  23. package/dist/lib/texts-de.d.ts +108 -0
  24. package/dist/lib/texts-de.js +111 -0
  25. package/dist/lib/texts-fr.d.ts +108 -0
  26. package/dist/lib/texts-fr.js +111 -0
  27. package/dist/lib/texts.d.ts +177 -89
  28. package/dist/lib/texts.js +176 -9
  29. package/dist/molecules/jl-alert.d.ts +1 -0
  30. package/dist/molecules/jl-alert.js +4 -2
  31. package/dist/molecules/jl-breadcrumb.d.ts +2 -0
  32. package/dist/molecules/jl-breadcrumb.js +12 -6
  33. package/dist/molecules/jl-calendar.d.ts +1 -0
  34. package/dist/molecules/jl-calendar.js +7 -4
  35. package/dist/molecules/jl-chip-group.d.ts +8 -6
  36. package/dist/molecules/jl-chip-group.js +10 -5
  37. package/dist/molecules/jl-code-block.js +1 -1
  38. package/dist/molecules/jl-combobox.d.ts +3 -1
  39. package/dist/molecules/jl-combobox.js +12 -7
  40. package/dist/molecules/jl-copy-button.d.ts +1 -0
  41. package/dist/molecules/jl-copy-button.js +7 -5
  42. package/dist/molecules/jl-date-picker.d.ts +1 -0
  43. package/dist/molecules/jl-date-picker.js +10 -7
  44. package/dist/molecules/jl-file-drop.d.ts +1 -0
  45. package/dist/molecules/jl-file-drop.js +15 -6
  46. package/dist/molecules/jl-input-list.d.ts +3 -2
  47. package/dist/molecules/jl-input-list.js +10 -7
  48. package/dist/molecules/jl-load-more.d.ts +4 -2
  49. package/dist/molecules/jl-load-more.js +15 -8
  50. package/dist/molecules/jl-load-state.d.ts +4 -0
  51. package/dist/molecules/jl-load-state.js +13 -9
  52. package/dist/molecules/jl-menu.d.ts +8 -4
  53. package/dist/molecules/jl-menu.js +8 -1
  54. package/dist/molecules/jl-number-input.d.ts +1 -0
  55. package/dist/molecules/jl-number-input.js +6 -3
  56. package/dist/molecules/jl-pagination.d.ts +2 -0
  57. package/dist/molecules/jl-pagination.js +17 -9
  58. package/dist/molecules/jl-radio-group.d.ts +9 -7
  59. package/dist/molecules/jl-radio-group.js +14 -7
  60. package/dist/molecules/jl-search-button.d.ts +2 -1
  61. package/dist/molecules/jl-search-button.js +6 -4
  62. package/dist/molecules/jl-search.d.ts +2 -0
  63. package/dist/molecules/jl-search.js +9 -3
  64. package/dist/molecules/jl-segmented.d.ts +8 -7
  65. package/dist/molecules/jl-segmented.js +10 -5
  66. package/dist/molecules/jl-steps.d.ts +2 -0
  67. package/dist/molecules/jl-steps.js +9 -4
  68. package/dist/molecules/jl-tag-input.d.ts +1 -0
  69. package/dist/molecules/jl-tag-input.js +8 -4
  70. package/dist/molecules/jl-toast.d.ts +1 -0
  71. package/dist/molecules/jl-toast.js +4 -2
  72. package/dist/organisms/jl-command-palette.d.ts +9 -5
  73. package/dist/organisms/jl-command-palette.js +15 -11
  74. package/dist/organisms/jl-confirm.d.ts +3 -0
  75. package/dist/organisms/jl-confirm.js +12 -11
  76. package/dist/organisms/jl-dialog.d.ts +1 -0
  77. package/dist/organisms/jl-dialog.js +4 -2
  78. package/dist/organisms/jl-drawer.d.ts +1 -0
  79. package/dist/organisms/jl-drawer.js +4 -2
  80. package/dist/organisms/jl-flow.d.ts +2 -0
  81. package/dist/organisms/jl-flow.js +25 -16
  82. package/dist/organisms/jl-navbar.d.ts +3 -0
  83. package/dist/organisms/jl-navbar.js +16 -7
  84. package/dist/organisms/jl-side-nav.d.ts +12 -9
  85. package/dist/organisms/jl-side-nav.js +26 -15
  86. package/dist/organisms/jl-tab-bar.d.ts +9 -7
  87. package/dist/organisms/jl-tab-bar.js +15 -6
  88. package/dist/organisms/jl-table.css_raw.js +1 -1
  89. package/dist/organisms/jl-table.d.ts +56 -17
  90. package/dist/organisms/jl-table.js +227 -43
  91. package/dist/organisms/jl-toaster.d.ts +2 -1
  92. package/dist/organisms/jl-toaster.js +12 -9
  93. package/dist/organisms/jl-tree.d.ts +6 -4
  94. package/dist/organisms/jl-tree.js +21 -15
  95. package/dist/templates/jl-app-shell.d.ts +1 -0
  96. package/dist/templates/jl-app-shell.js +4 -2
  97. package/dist/templates/jl-auth-layout.d.ts +4 -3
  98. package/dist/templates/jl-auth-layout.js +13 -11
  99. package/dist/templates/jl-page.d.ts +1 -0
  100. package/dist/templates/jl-page.js +4 -1
  101. package/dist/templates/jl-split-view.d.ts +1 -0
  102. package/dist/templates/jl-split-view.js +5 -4
  103. package/dist/types/jl-chip-group.types.d.ts +3 -3
  104. package/dist/types/jl-command-palette.types.d.ts +10 -6
  105. package/dist/types/jl-menu.types.d.ts +4 -4
  106. package/dist/types/jl-radio-group.types.d.ts +6 -3
  107. package/dist/types/jl-segmented.types.d.ts +6 -3
  108. package/dist/types/jl-select.types.d.ts +6 -3
  109. package/dist/types/jl-side-nav.types.d.ts +9 -6
  110. package/dist/types/jl-tab-bar.types.d.ts +6 -3
  111. package/dist/types/jl-table.types.d.ts +34 -8
  112. package/dist/types/texts.types.d.ts +29 -4
  113. package/package.json +3 -3
@@ -4,17 +4,19 @@ import type { MenuItem } from '../types/jl-menu.types';
4
4
  /**
5
5
  * A list of actions that opens from its trigger (`slot="trigger"`, any button): on a press or with ArrowDown. Arrows,
6
6
  * Home, End and the first letter move through it; Enter chooses, Escape closes. `select` fires with the value.
7
+ * Typed by its values, `JlMenu<'edit' | 'delete'>` takes actions of those values and gives `select` one of them:
8
+ * a page handles them with a `Record<'edit' | 'delete', () => void>`, which misses none.
7
9
  */
8
- export declare class JlMenu extends JlElement {
10
+ export declare class JlMenu<Value extends string = string> extends JlElement {
9
11
  static readonly selector = "jl-menu";
10
12
  readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
11
- select: string;
13
+ select: Value;
12
14
  open: undefined;
13
15
  close: undefined;
14
16
  }>>;
15
17
  readonly items: Readonly<Readonly<{
16
- get(): MenuItem[];
17
- set(setter: MenuItem[] | ((prevState: MenuItem[]) => MenuItem[])): void;
18
+ get(): MenuItem<Value>[];
19
+ set(setter: MenuItem<Value>[] | ((prevState: MenuItem<Value>[]) => MenuItem<Value>[])): void;
18
20
  }>>;
19
21
  /** Where the menu goes; it flips to the other side when there is no room. */
20
22
  readonly placement: Readonly<Readonly<{
@@ -50,6 +52,8 @@ export declare class JlMenu extends JlElement {
50
52
  private focusItem;
51
53
  /** Chooses an item people picked: the menu closes, the focus goes back to the trigger, and `select` fires. */
52
54
  private chooseItem;
55
+ /** The action an item of the list draws. */
56
+ private actionOf;
53
57
  private onToggle;
54
58
  private focusIsInMenu;
55
59
  /** Keeps the menu by the trigger while it is open. */
@@ -44,6 +44,8 @@ var isTypeahead = (event) => event.key.length === 1 && event.key !== " " && !eve
44
44
  /**
45
45
  * A list of actions that opens from its trigger (`slot="trigger"`, any button): on a press or with ArrowDown. Arrows,
46
46
  * Home, End and the first letter move through it; Enter chooses, Escape closes. `select` fires with the value.
47
+ * Typed by its values, `JlMenu<'edit' | 'delete'>` takes actions of those values and gives `select` one of them:
48
+ * a page handles them with a `Record<'edit' | 'delete', () => void>`, which misses none.
47
49
  */
48
50
  var JlMenu = class extends JlElement {
49
51
  static selector = "jl-menu";
@@ -192,9 +194,14 @@ var JlMenu = class extends JlElement {
192
194
  /** Chooses an item people picked: the menu closes, the focus goes back to the trigger, and `select` fires. */
193
195
  chooseItem(item) {
194
196
  if (!(item instanceof HTMLElement) || item.hasAttribute("aria-disabled")) return;
197
+ const action = this.actionOf(item);
195
198
  this.close();
196
199
  this.triggerElement()?.focus();
197
- this.events.emit("select", item.dataset.value ?? "");
200
+ if (action !== void 0) this.events.emit("select", action.value);
201
+ }
202
+ /** The action an item of the list draws. */
203
+ actionOf(item) {
204
+ return this.items.get().find((entry) => "value" in entry && entry.value === item.dataset.value);
198
205
  }
199
206
  onToggle(open) {
200
207
  this.renderTrigger();
@@ -77,5 +77,6 @@ export declare class JlNumberInput extends JlFormControl {
77
77
  private renderDisabled;
78
78
  /** A button that cannot move the value further is disabled. */
79
79
  private renderButtons;
80
+ protected drawTexts(): void;
80
81
  private renderValidity;
81
82
  }
@@ -1,9 +1,9 @@
1
+ import { jlText } from "../lib/texts.js";
1
2
  import { BASE_STYLES, CONTROL_STYLES } from "../styles/shared.js";
2
3
  import { JlFormControl } from "../base/jl-form-control.js";
3
4
  import { oneOf } from "../lib/attributes.js";
4
5
  import { registerIcons } from "../lib/icons.js";
5
6
  import { CONTROL_SIZES } from "../lib/options.js";
6
- import { jlText } from "../lib/texts.js";
7
7
  import { JlIcon } from "../atoms/jl-icon.js";
8
8
  import { setOrRemove } from "../lib/dom.js";
9
9
  import { clamp, parseNumber, stepValue } from "../lib/numeric.js";
@@ -89,7 +89,6 @@ var JlNumberInput = class extends JlFormControl {
89
89
  class: "action step down",
90
90
  type: "button",
91
91
  tabIndex: -1,
92
- "aria-label": jlText("decrease"),
93
92
  children: /* @__PURE__ */ jsx(JlIcon, {
94
93
  name: "minus",
95
94
  size: ICON_SIZE
@@ -106,7 +105,6 @@ var JlNumberInput = class extends JlFormControl {
106
105
  class: "action step up",
107
106
  type: "button",
108
107
  tabIndex: -1,
109
- "aria-label": jlText("increase"),
110
108
  children: /* @__PURE__ */ jsx(JlIcon, {
111
109
  name: "plus",
112
110
  size: ICON_SIZE
@@ -208,6 +206,11 @@ var JlNumberInput = class extends JlFormControl {
208
206
  this._refs.down.disabled = off || value !== null && min !== null && value <= min;
209
207
  this._refs.up.disabled = off || value !== null && max !== null && value >= max;
210
208
  }
209
+ drawTexts() {
210
+ this._refs.down.setAttribute("aria-label", jlText("decrease"));
211
+ this._refs.up.setAttribute("aria-label", jlText("increase"));
212
+ this.renderValidity();
213
+ }
211
214
  renderValidity() {
212
215
  if (!(this.required.get() && this.value.get() === null)) {
213
216
  this.internals.setValidity({});
@@ -46,6 +46,8 @@ export declare class JlPagination extends JlElement {
46
46
  private readonly _refs;
47
47
  templateHtml(): Node;
48
48
  templateCss(): string;
49
+ protected drawTexts(): void;
50
+ private renderLabel;
49
51
  onConnect(): void;
50
52
  /** The current page, kept within the pages there are. */
51
53
  private currentPage;
@@ -1,9 +1,9 @@
1
+ import { jlText } from "../lib/texts.js";
1
2
  import { BASE_STYLES } from "../styles/shared.js";
2
3
  import { JlElement } from "../base/jl-element.js";
3
4
  import { clampedNumber, oneOf } from "../lib/attributes.js";
4
5
  import { registerIcons } from "../lib/icons.js";
5
6
  import { CONTROL_SIZES } from "../lib/options.js";
6
- import { jlText } from "../lib/texts.js";
7
7
  import { JlIcon } from "../atoms/jl-icon.js";
8
8
  import { clampPage, pageItems } from "../lib/pagination.js";
9
9
  import jl_pagination_default from "./jl-pagination.css_raw.js";
@@ -61,9 +61,7 @@ var JlPagination = class extends JlElement {
61
61
  parse: oneOf(CONTROL_SIZES, "md")
62
62
  });
63
63
  /** The navigation's name for screen readers, when a page has more than one. */
64
- label = this.useChange(jlText("pagination"), (value) => {
65
- this._refs.nav.setAttribute("aria-label", value || jlText("pagination"));
66
- }, { attribute: "label" });
64
+ label = this.useChange("", () => this.renderLabel(), { attribute: "label" });
67
65
  _refs = this.useRefs((ref) => ({
68
66
  list: ref(".pages"),
69
67
  nav: ref("nav"),
@@ -80,7 +78,6 @@ var JlPagination = class extends JlElement {
80
78
  /* @__PURE__ */ jsx("button", {
81
79
  type: "button",
82
80
  class: "button previous",
83
- "aria-label": jlText("previousPage"),
84
81
  children: /* @__PURE__ */ jsx(JlIcon, { name: "chevron-left" })
85
82
  }),
86
83
  /* @__PURE__ */ jsx("ol", { class: "pages" }),
@@ -91,7 +88,6 @@ var JlPagination = class extends JlElement {
91
88
  /* @__PURE__ */ jsx("button", {
92
89
  type: "button",
93
90
  class: "button next",
94
- "aria-label": jlText("nextPage"),
95
91
  children: /* @__PURE__ */ jsx(JlIcon, { name: "chevron-right" })
96
92
  })
97
93
  ]
@@ -100,6 +96,15 @@ var JlPagination = class extends JlElement {
100
96
  templateCss() {
101
97
  return css`${BASE_STYLES}${jl_pagination_default}`;
102
98
  }
99
+ drawTexts() {
100
+ this._refs.previous.setAttribute("aria-label", jlText("previousPage"));
101
+ this._refs.next.setAttribute("aria-label", jlText("nextPage"));
102
+ this.renderLabel();
103
+ this.render();
104
+ }
105
+ renderLabel() {
106
+ this._refs.nav.setAttribute("aria-label", this.label.get() || jlText("pagination"));
107
+ }
103
108
  onConnect() {
104
109
  this.on(this._refs.previous, "click", () => this.step(STEP_BACK));
105
110
  this.on(this._refs.next, "click", () => this.step(STEP_FORWARD));
@@ -125,8 +130,11 @@ var JlPagination = class extends JlElement {
125
130
  this._refs.status.hidden = !compact;
126
131
  this._refs.status.replaceChildren(/* @__PURE__ */ jsx("span", {
127
132
  class: "sr-only",
128
- children: "Page "
129
- }), `${page} of ${Math.max(pages, 1)}`);
133
+ children: `${jlText("page")} `
134
+ }), jlText("pageOfTotal", {
135
+ page,
136
+ total: Math.max(pages, 1)
137
+ }));
130
138
  if (!compact) {
131
139
  const items = pageItems(page, pages, this.siblings.get(), this.boundaries.get());
132
140
  this._refs.list.replaceChildren(...items.map((item) => this.entry(item, page)));
@@ -143,7 +151,7 @@ var JlPagination = class extends JlElement {
143
151
  type: "button",
144
152
  class: "button page",
145
153
  "data-page": item.page,
146
- "aria-label": `Page ${item.page}`,
154
+ "aria-label": jlText("pageNumber", { page: item.page }),
147
155
  "aria-current": isCurrent ? "page" : void 0,
148
156
  children: String(item.page)
149
157
  }) });
@@ -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;
@@ -67,5 +68,6 @@ export declare class JlRadioGroup extends JlFormControl {
67
68
  /** Checks the option with the value, and gives the Tab stop to it, or else to the first option enabled. */
68
69
  private renderValue;
69
70
  private tabStop;
71
+ protected drawTexts(): void;
70
72
  private renderValidity;
71
73
  }
@@ -1,7 +1,7 @@
1
+ import { jlText } from "../lib/texts.js";
1
2
  import { BASE_STYLES } from "../styles/shared.js";
2
3
  import { JlFormControl } from "../base/jl-form-control.js";
3
- import { jsonOf, oneOf } from "../lib/attributes.js";
4
- import { jlText } from "../lib/texts.js";
4
+ import { jsonOf, oneOf, textOf } from "../lib/attributes.js";
5
5
  import { rovingIndex } from "../lib/roving-index.js";
6
6
  import jl_radio_group_default from "./jl-radio-group.css_raw.js";
7
7
  import { css } from "@jadis/core";
@@ -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
  }
@@ -190,6 +194,9 @@ var JlRadioGroup = class extends JlFormControl {
190
194
  const enabled = radios.filter((radio) => this.isEnabled(radio));
191
195
  return enabled.find((radio) => radio.dataset.value === value) ?? enabled[0];
192
196
  }
197
+ drawTexts() {
198
+ this.renderValidity();
199
+ }
193
200
  renderValidity() {
194
201
  if (!(this.required.get() && this.value.get() === NO_VALUE)) {
195
202
  this.internals.setValidity({});
@@ -9,7 +9,7 @@ export declare class JlSearchButton extends JlElement {
9
9
  readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
10
10
  press: undefined;
11
11
  }>>;
12
- /** The text, and the button's name: "Search". */
12
+ /** The text, and the button's name; jlib's own when empty. */
13
13
  readonly label: Readonly<Readonly<{
14
14
  get(): string;
15
15
  set(setter: string | ((prevState: string) => string)): void;
@@ -28,6 +28,7 @@ export declare class JlSearchButton extends JlElement {
28
28
  focus(options?: FocusOptions): void;
29
29
  templateHtml(): Node;
30
30
  templateCss(): string;
31
+ protected drawTexts(): void;
31
32
  onConnect(): void;
32
33
  private renderLabel;
33
34
  private renderHotkey;
@@ -1,7 +1,7 @@
1
+ import { jlText } from "../lib/texts.js";
1
2
  import { BASE_STYLES } from "../styles/shared.js";
2
3
  import { JlElement } from "../base/jl-element.js";
3
4
  import { registerIcons } from "../lib/icons.js";
4
- import { jlText } from "../lib/texts.js";
5
5
  import { JlIcon } from "../atoms/jl-icon.js";
6
6
  import { setOrRemove } from "../lib/dom.js";
7
7
  import { JlKbd } from "../atoms/jl-kbd.js";
@@ -25,8 +25,8 @@ var isMac = () => MAC_PATTERN.test(navigator.userAgent);
25
25
  var JlSearchButton = class extends JlElement {
26
26
  static selector = "jl-search-button";
27
27
  events = this.useEvents();
28
- /** The text, and the button's name: "Search". */
29
- label = this.useChange(jlText("search"), () => this.renderLabel(), { attribute: "label" });
28
+ /** The text, and the button's name; jlib's own when empty. */
29
+ label = this.useChange("", () => 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. */
@@ -57,8 +57,10 @@ var JlSearchButton = class extends JlElement {
57
57
  templateCss() {
58
58
  return css`${BASE_STYLES}${jl_search_button_default}`;
59
59
  }
60
- onConnect() {
60
+ drawTexts() {
61
61
  this.renderLabel();
62
+ }
63
+ onConnect() {
62
64
  this.renderHotkey();
63
65
  this.on(this._refs.button, "click", () => this.events.emit("press"));
64
66
  }
@@ -57,6 +57,8 @@ export declare class JlSearch extends JlFormControl {
57
57
  clear(): void;
58
58
  templateHtml(): Node;
59
59
  templateCss(): string;
60
+ protected drawTexts(): void;
61
+ private renderLabel;
60
62
  onConnect(): void;
61
63
  onDisconnect(): void;
62
64
  protected resetValue(): void;
@@ -1,9 +1,9 @@
1
+ import { jlText } from "../lib/texts.js";
1
2
  import { BASE_STYLES, CONTROL_STYLES } from "../styles/shared.js";
2
3
  import { JlFormControl } from "../base/jl-form-control.js";
3
4
  import { oneOf } from "../lib/attributes.js";
4
5
  import { registerIcons } from "../lib/icons.js";
5
6
  import { CONTROL_SIZES } from "../lib/options.js";
6
- import { jlText } from "../lib/texts.js";
7
7
  import { JlIcon } from "../atoms/jl-icon.js";
8
8
  import { setOrRemove } from "../lib/dom.js";
9
9
  import { JlSpinner } from "../atoms/jl-spinner.js";
@@ -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 || jlText("search")), { attribute: "label" });
41
+ label = this.useChange("", () => this.renderLabel(), { 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). */
@@ -108,7 +108,6 @@ var JlSearch = class extends JlFormControl {
108
108
  /* @__PURE__ */ jsx("button", {
109
109
  class: "action clear",
110
110
  type: "button",
111
- "aria-label": jlText("clearSearch"),
112
111
  tabIndex: -1,
113
112
  hidden: true,
114
113
  children: /* @__PURE__ */ jsx(JlIcon, {
@@ -127,6 +126,13 @@ var JlSearch = class extends JlFormControl {
127
126
  templateCss() {
128
127
  return css`${BASE_STYLES}${CONTROL_STYLES}${jl_search_default}`;
129
128
  }
129
+ drawTexts() {
130
+ this._refs.clear.setAttribute("aria-label", jlText("clearSearch"));
131
+ this.renderLabel();
132
+ }
133
+ renderLabel() {
134
+ this._refs.native.setAttribute("aria-label", this.label.get() || jlText("search"));
135
+ }
130
136
  onConnect() {
131
137
  const native = this._refs.native;
132
138
  this.on(native, "input", (event) => {
@@ -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,6 +1,6 @@
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";
@@ -16,6 +16,7 @@ var ICON_SIZES = {
16
16
  md: 16,
17
17
  sm: 14
18
18
  };
19
+ var NO_VALUE = "";
19
20
  var KEY_MOVES = /* @__PURE__ */ new Map([
20
21
  ["ArrowDown", (enabled, from) => stepIndex(enabled, from, 1)],
21
22
  ["ArrowLeft", (enabled, from) => stepIndex(enabled, from, -1)],
@@ -26,7 +27,8 @@ var KEY_MOVES = /* @__PURE__ */ new Map([
26
27
  ]);
27
28
  /**
28
29
  * A row of a few exclusive choices with a thumb that slides to the chosen one: a view switch, a period, a
29
- * 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.
30
32
  */
31
33
  var JlSegmented = class extends JlFormControl {
32
34
  static selector = "jl-segmented";
@@ -36,7 +38,10 @@ var JlSegmented = class extends JlFormControl {
36
38
  parse: jsonOf([])
37
39
  });
38
40
  /** The chosen option's value; the first option that can be chosen when it names none. */
39
- value = this.useChange("", () => this.renderValue(), { attribute: "value" });
41
+ value = this.useChange(NO_VALUE, () => this.renderValue(), {
42
+ attribute: "value",
43
+ parse: textOf(NO_VALUE)
44
+ });
40
45
  size = this.useChange("md", (value) => {
41
46
  this.reflect("size", value);
42
47
  this.renderOptions();
@@ -91,7 +96,7 @@ var JlSegmented = class extends JlFormControl {
91
96
  this._resize.disconnect();
92
97
  }
93
98
  resetValue() {
94
- this.value.set(this.getAttribute("value") ?? "");
99
+ this.value.set(textOf(NO_VALUE)(this.getAttribute("value")));
95
100
  }
96
101
  /** The browser calls it for a disabled fieldset and for the element's own `disabled`, even before it renders. */
97
102
  setDisabledByForm(disabled) {
@@ -155,7 +160,7 @@ var JlSegmented = class extends JlFormControl {
155
160
  this.value.set(option.value);
156
161
  return;
157
162
  }
158
- const value = option?.value ?? "";
163
+ const value = option?.value ?? NO_VALUE;
159
164
  this.segments().forEach((segment) => {
160
165
  const checked = segment.dataset.value === value;
161
166
  segment.setAttribute("aria-checked", String(checked));
@@ -37,6 +37,8 @@ export declare class JlSteps extends JlElement {
37
37
  templateHtml(): Node;
38
38
  templateCss(): string;
39
39
  onConnect(): void;
40
+ protected drawTexts(): void;
41
+ private renderLabel;
40
42
  private render;
41
43
  /** A failed step's ×, a done one's check, or the step's number. */
42
44
  private markerOf;
@@ -1,8 +1,8 @@
1
+ import { jlText } from "../lib/texts.js";
1
2
  import { BASE_STYLES } from "../styles/shared.js";
2
3
  import { JlElement } from "../base/jl-element.js";
3
4
  import { clampedNumber, jsonOf, oneOf } from "../lib/attributes.js";
4
5
  import { registerIcons } from "../lib/icons.js";
5
- import { jlText } from "../lib/texts.js";
6
6
  import { JlIcon } from "../atoms/jl-icon.js";
7
7
  import jl_steps_default from "./jl-steps.css_raw.js";
8
8
  import { css } from "@jadis/core";
@@ -52,9 +52,7 @@ var JlSteps = class extends JlElement {
52
52
  /** Done steps become buttons that go back to them. */
53
53
  clickable = this.useChange(false, () => this.render(), { attribute: "clickable" });
54
54
  /** The list's name for screen readers. */
55
- label = this.useChange(jlText("progress"), (value) => {
56
- this._refs.list.setAttribute("aria-label", value || jlText("progress"));
57
- }, { attribute: "label" });
55
+ label = this.useChange("", () => this.renderLabel(), { attribute: "label" });
58
56
  _refs = this.useRefs((ref) => ({ list: ref("ol") }));
59
57
  templateHtml() {
60
58
  return /* @__PURE__ */ jsx("ol", { attrs: { part: "base" } });
@@ -68,6 +66,13 @@ var JlSteps = class extends JlElement {
68
66
  if (target !== null) this.goBackTo(Number(target.dataset.index));
69
67
  });
70
68
  }
69
+ drawTexts() {
70
+ this.renderLabel();
71
+ this.render();
72
+ }
73
+ renderLabel() {
74
+ this._refs.list.setAttribute("aria-label", this.label.get() || jlText("progress"));
75
+ }
71
76
  render() {
72
77
  const current = this.current.get();
73
78
  this._refs.list.replaceChildren(...this.items.get().map((item, index) => this.step(item, index, statusOf(index, current))));
@@ -56,6 +56,7 @@ export declare class JlTagInput extends JlFormControl {
56
56
  focus(options?: FocusOptions): void;
57
57
  templateHtml(): Node;
58
58
  templateCss(): string;
59
+ protected drawTexts(): void;
59
60
  onConnect(): void;
60
61
  onDisconnect(): void;
61
62
  protected resetValue(): void;
@@ -1,10 +1,10 @@
1
+ import { jlText } from "../lib/texts.js";
1
2
  import { BASE_STYLES, CONTROL_STYLES, FLOATING_STYLES } from "../styles/shared.js";
2
3
  import { JlFormControl } from "../base/jl-form-control.js";
3
4
  import { clampedNumber, jsonOf, oneOf } from "../lib/attributes.js";
4
5
  import { followAnchor } from "../lib/floating.js";
5
6
  import { registerIcons } from "../lib/icons.js";
6
7
  import { CONTROL_SIZES } from "../lib/options.js";
7
- import { jlText } from "../lib/texts.js";
8
8
  import { JlIcon } from "../atoms/jl-icon.js";
9
9
  import { setOrRemove, uniqueId } from "../lib/dom.js";
10
10
  import { keepInView } from "../lib/keep-in-view.js";
@@ -118,6 +118,10 @@ var JlTagInput = class extends JlFormControl {
118
118
  templateCss() {
119
119
  return css`${BASE_STYLES}${CONTROL_STYLES}${FLOATING_STYLES}${jl_tag_input_default}`;
120
120
  }
121
+ drawTexts() {
122
+ this.renderTags();
123
+ this.renderValidity();
124
+ }
121
125
  onConnect() {
122
126
  const native = this._refs.native;
123
127
  this._nameWatch.observe(this, {
@@ -232,7 +236,7 @@ var JlTagInput = class extends JlFormControl {
232
236
  this.closeList();
233
237
  if (added.length > 0) {
234
238
  this.value.set(result.tags);
235
- this.announce(`Added ${added.join(", ")}`);
239
+ this.announce(jlText("addedNamed", { names: added.join(", ") }));
236
240
  this.events.emit("change", result.tags);
237
241
  }
238
242
  this.flash(result.duplicates);
@@ -243,7 +247,7 @@ var JlTagInput = class extends JlFormControl {
243
247
  if (removed === void 0 || this.disabled.get()) return;
244
248
  const next = tags.filter((_, position) => position !== index);
245
249
  this.value.set(next);
246
- this.announce(`Removed ${removed}`);
250
+ this.announce(jlText("removedNamed", { name: removed }));
247
251
  this.events.emit("change", next);
248
252
  }
249
253
  removeAndFocus(index) {
@@ -381,7 +385,7 @@ var JlTagInput = class extends JlFormControl {
381
385
  class: "tag-remove",
382
386
  type: "button",
383
387
  tabIndex: -1,
384
- "aria-label": `Remove ${tag}`,
388
+ "aria-label": jlText("removeNamed", { name: tag }),
385
389
  "data-index": String(index),
386
390
  children: /* @__PURE__ */ jsx(JlIcon, {
387
391
  name: "x",
@@ -65,6 +65,7 @@ export declare class JlToast extends JlElement {
65
65
  show(): void;
66
66
  templateHtml(): Node;
67
67
  templateCss(): string;
68
+ protected drawTexts(): void;
68
69
  onConnect(): void;
69
70
  onDisconnect(): void;
70
71
  /** The way in, once per showing; WAAPI so that the toaster moving in the top layer does not replay it. */
@@ -1,9 +1,9 @@
1
+ import { jlText } from "../lib/texts.js";
1
2
  import { BASE_STYLES } from "../styles/shared.js";
2
3
  import { JlElement } from "../base/jl-element.js";
3
4
  import { oneOf } from "../lib/attributes.js";
4
5
  import { registerIcons } from "../lib/icons.js";
5
6
  import { TONE_ICONS, TONE_ICON_FILLED } from "../lib/options.js";
6
- import { jlText } from "../lib/texts.js";
7
7
  import { JlIcon } from "../atoms/jl-icon.js";
8
8
  import { JlButton } from "../atoms/jl-button.js";
9
9
  import { optionalNumber } from "../lib/progress.js";
@@ -181,7 +181,6 @@ var JlToast = class extends JlElement {
181
181
  variant: "ghost",
182
182
  size: "sm",
183
183
  icon: "x",
184
- hint: jlText("close"),
185
184
  hidden: true
186
185
  })]
187
186
  }),
@@ -197,6 +196,9 @@ var JlToast = class extends JlElement {
197
196
  templateCss() {
198
197
  return css`${BASE_STYLES}${jl_toast_default}`;
199
198
  }
199
+ drawTexts() {
200
+ this._refs.close.hint.set(jlText("close"));
201
+ }
200
202
  onConnect() {
201
203
  this._refs.close.events.register("press", () => this.dismiss());
202
204
  this._refs.action.events.register("press", () => {