@syware/jlib 0.8.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 (91) hide show
  1. package/README.md +2 -1
  2. package/dist/all.js +2 -2
  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-spinner.d.ts +2 -0
  10. package/dist/atoms/jl-spinner.js +6 -2
  11. package/dist/base/jl-element.d.ts +6 -0
  12. package/dist/base/jl-element.js +5 -0
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +2 -2
  15. package/dist/lib/texts-de.d.ts +108 -0
  16. package/dist/lib/texts-de.js +111 -0
  17. package/dist/lib/texts-fr.d.ts +108 -0
  18. package/dist/lib/texts-fr.js +111 -0
  19. package/dist/lib/texts.d.ts +177 -91
  20. package/dist/lib/texts.js +174 -9
  21. package/dist/molecules/jl-alert.d.ts +1 -0
  22. package/dist/molecules/jl-alert.js +4 -2
  23. package/dist/molecules/jl-breadcrumb.d.ts +2 -0
  24. package/dist/molecules/jl-breadcrumb.js +12 -6
  25. package/dist/molecules/jl-calendar.d.ts +1 -0
  26. package/dist/molecules/jl-calendar.js +7 -4
  27. package/dist/molecules/jl-chip-group.d.ts +1 -0
  28. package/dist/molecules/jl-chip-group.js +4 -1
  29. package/dist/molecules/jl-code-block.js +1 -1
  30. package/dist/molecules/jl-combobox.d.ts +3 -1
  31. package/dist/molecules/jl-combobox.js +12 -7
  32. package/dist/molecules/jl-copy-button.d.ts +1 -0
  33. package/dist/molecules/jl-copy-button.js +7 -5
  34. package/dist/molecules/jl-date-picker.d.ts +1 -0
  35. package/dist/molecules/jl-date-picker.js +10 -7
  36. package/dist/molecules/jl-file-drop.d.ts +1 -0
  37. package/dist/molecules/jl-file-drop.js +15 -6
  38. package/dist/molecules/jl-input-list.d.ts +3 -2
  39. package/dist/molecules/jl-input-list.js +10 -7
  40. package/dist/molecules/jl-load-more.d.ts +4 -2
  41. package/dist/molecules/jl-load-more.js +15 -8
  42. package/dist/molecules/jl-load-state.d.ts +4 -0
  43. package/dist/molecules/jl-load-state.js +13 -9
  44. package/dist/molecules/jl-number-input.d.ts +1 -0
  45. package/dist/molecules/jl-number-input.js +6 -3
  46. package/dist/molecules/jl-pagination.d.ts +2 -0
  47. package/dist/molecules/jl-pagination.js +17 -9
  48. package/dist/molecules/jl-radio-group.d.ts +1 -0
  49. package/dist/molecules/jl-radio-group.js +4 -1
  50. package/dist/molecules/jl-search-button.d.ts +2 -1
  51. package/dist/molecules/jl-search-button.js +6 -4
  52. package/dist/molecules/jl-search.d.ts +2 -0
  53. package/dist/molecules/jl-search.js +9 -3
  54. package/dist/molecules/jl-steps.d.ts +2 -0
  55. package/dist/molecules/jl-steps.js +9 -4
  56. package/dist/molecules/jl-tag-input.d.ts +1 -0
  57. package/dist/molecules/jl-tag-input.js +8 -4
  58. package/dist/molecules/jl-toast.d.ts +1 -0
  59. package/dist/molecules/jl-toast.js +4 -2
  60. package/dist/organisms/jl-command-palette.d.ts +3 -1
  61. package/dist/organisms/jl-command-palette.js +13 -11
  62. package/dist/organisms/jl-confirm.d.ts +3 -0
  63. package/dist/organisms/jl-confirm.js +12 -11
  64. package/dist/organisms/jl-dialog.d.ts +1 -0
  65. package/dist/organisms/jl-dialog.js +4 -2
  66. package/dist/organisms/jl-drawer.d.ts +1 -0
  67. package/dist/organisms/jl-drawer.js +4 -2
  68. package/dist/organisms/jl-flow.d.ts +2 -0
  69. package/dist/organisms/jl-flow.js +25 -16
  70. package/dist/organisms/jl-navbar.d.ts +3 -0
  71. package/dist/organisms/jl-navbar.js +16 -7
  72. package/dist/organisms/jl-side-nav.d.ts +4 -2
  73. package/dist/organisms/jl-side-nav.js +17 -11
  74. package/dist/organisms/jl-tab-bar.d.ts +1 -0
  75. package/dist/organisms/jl-tab-bar.js +5 -2
  76. package/dist/organisms/jl-table.d.ts +2 -1
  77. package/dist/organisms/jl-table.js +9 -6
  78. package/dist/organisms/jl-toaster.d.ts +2 -1
  79. package/dist/organisms/jl-toaster.js +12 -9
  80. package/dist/organisms/jl-tree.d.ts +6 -4
  81. package/dist/organisms/jl-tree.js +21 -15
  82. package/dist/templates/jl-app-shell.d.ts +1 -0
  83. package/dist/templates/jl-app-shell.js +4 -2
  84. package/dist/templates/jl-auth-layout.d.ts +4 -3
  85. package/dist/templates/jl-auth-layout.js +13 -11
  86. package/dist/templates/jl-page.d.ts +1 -0
  87. package/dist/templates/jl-page.js +4 -1
  88. package/dist/templates/jl-split-view.d.ts +1 -0
  89. package/dist/templates/jl-split-view.js +5 -4
  90. package/dist/types/texts.types.d.ts +29 -4
  91. package/package.json +3 -3
@@ -1,12 +1,12 @@
1
+ import { pageLocale } from "../lib/locale.js";
2
+ import { jlTemplate, jlText } from "../lib/texts.js";
1
3
  import { BASE_STYLES } from "../styles/shared.js";
2
4
  import { JlElement } from "../base/jl-element.js";
3
5
  import { jsonOf } from "../lib/attributes.js";
4
6
  import { registerIcons } from "../lib/icons.js";
5
- import { jlText } from "../lib/texts.js";
6
7
  import { JlIcon } from "../atoms/jl-icon.js";
7
8
  import { isModifiedClick, setOrRemove, uniqueId } from "../lib/dom.js";
8
9
  import { JlSpinner } from "../atoms/jl-spinner.js";
9
- import { pageLocale } from "../lib/locale.js";
10
10
  import { allItems, childrenOf, isFolder, treeKeyAction, withExpanded, withExtraRows, withPage } from "../lib/tree.js";
11
11
  import jl_tree_default from "./jl-tree.css_raw.js";
12
12
  import { css } from "@jadis/core";
@@ -61,14 +61,14 @@ var JlTree = class extends JlElement {
61
61
  label = this.useChange("", (value) => setOrRemove(this._refs.tree, "aria-label", value), { attribute: "label" });
62
62
  /** What an empty tree says, such as "No object yet"; none by default. */
63
63
  emptyText = this.useChange("", () => this.renderItems(), { attribute: "empty-text" });
64
- /** Said while a page loads. */
65
- loadingText = this.useChange(jlText("loadingMore"), () => this.renderItems(), { attribute: "loading-text" });
66
- /** The button that loads a level's next page; `{count}` is how many items are left. */
67
- moreText = this.useChange(jlText("showMoreCount"), () => this.renderItems(), { attribute: "more-text" });
68
- /** Said where a page could not be loaded. */
69
- errorText = this.useChange(jlText("loadError"), () => this.renderItems(), { attribute: "error-text" });
70
- /** The action that loads it again. */
71
- retryLabel = this.useChange(jlText("retry"), () => this.renderItems(), { attribute: "retry-label" });
64
+ /** Said while a page loads; jlib's own text when empty. */
65
+ loadingText = this.useChange("", () => this.renderItems(), { attribute: "loading-text" });
66
+ /** The button that loads a level's next page, `{count}` being how many items are left; jlib's own when empty. */
67
+ moreText = this.useChange("", () => this.renderItems(), { attribute: "more-text" });
68
+ /** Said where a page could not be loaded; jlib's own text when empty. */
69
+ errorText = this.useChange("", () => this.renderItems(), { attribute: "error-text" });
70
+ /** The action that loads it again; jlib's own text when empty. */
71
+ retryLabel = this.useChange("", () => this.renderItems(), { attribute: "retry-label" });
72
72
  _source = { loader: null };
73
73
  _rows = /* @__PURE__ */ new Map();
74
74
  _focus = { id: "" };
@@ -245,7 +245,7 @@ var JlTree = class extends JlElement {
245
245
  if (generation !== this._loading.generation) return;
246
246
  const total = this._loading.levels.get(parent)?.total ?? 0;
247
247
  this._loading.levels.set(parent, {
248
- error: messageOf(error) || this.errorText.get(),
248
+ error: messageOf(error) || this.errorLabel(),
249
249
  pending: null,
250
250
  total
251
251
  });
@@ -277,6 +277,12 @@ var JlTree = class extends JlElement {
277
277
  const end = this.levelEnd(parent);
278
278
  return end !== "none" && end !== "empty";
279
279
  }
280
+ drawTexts() {
281
+ this.renderItems();
282
+ }
283
+ errorLabel() {
284
+ return this.errorText.get() || jlText("loadError");
285
+ }
280
286
  renderItems() {
281
287
  const hadFocus = this.hasFocusInside();
282
288
  this._rows.clear();
@@ -379,7 +385,7 @@ var JlTree = class extends JlElement {
379
385
  return node;
380
386
  }
381
387
  loadingNode(parent, level) {
382
- const text = this.loadingText.get();
388
+ const text = this.loadingText.get() || jlText("loadingMore");
383
389
  return this.levelEndRow(parent, level, [/* @__PURE__ */ jsx(JlSpinner, {
384
390
  class: "spinner",
385
391
  size: ICON_SIZE,
@@ -392,7 +398,7 @@ var JlTree = class extends JlElement {
392
398
  }
393
399
  moreNode(parent, level) {
394
400
  const left = (this._loading.levels.get(parent)?.total ?? 0) - childrenOf(this.items.get(), parent).length;
395
- const text = this.moreText.get().replace(COUNT_PLACEHOLDER, left.toLocaleString(pageLocale()));
401
+ const text = (this.moreText.get() || jlTemplate("showMoreCount")).replace(COUNT_PLACEHOLDER, left.toLocaleString(pageLocale()));
396
402
  return this.levelEndRow(parent, level, [/* @__PURE__ */ jsx("span", {
397
403
  class: "label more",
398
404
  children: text
@@ -407,11 +413,11 @@ var JlTree = class extends JlElement {
407
413
  }),
408
414
  /* @__PURE__ */ jsx("span", {
409
415
  class: "label",
410
- children: this.errorText.get()
416
+ children: this.errorLabel()
411
417
  }),
412
418
  /* @__PURE__ */ jsx("span", {
413
419
  class: "retry",
414
- children: this.retryLabel.get()
420
+ children: this.retryLabel.get() || jlText("retry")
415
421
  })
416
422
  ], false);
417
423
  setOrRemove(node, "title", this._loading.levels.get(parent)?.error ?? "");
@@ -33,6 +33,7 @@ export declare class JlAppShell extends JlElement {
33
33
  toggleNav(force?: boolean): void;
34
34
  templateHtml(): Node;
35
35
  templateCss(): string;
36
+ protected drawTexts(): void;
36
37
  onConnect(): void;
37
38
  onDisconnect(): void;
38
39
  /** Tells the page how much the tab bar covers at the bottom of the window, while it shows. */
@@ -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 { watchSizes } from "../lib/resize.js";
7
7
  import jl_app_shell_default from "./jl-app-shell.css_raw.js";
@@ -71,7 +71,6 @@ var JlAppShell = class extends JlElement {
71
71
  children: [/* @__PURE__ */ jsx("button", {
72
72
  class: "menu",
73
73
  type: "button",
74
- "aria-label": jlText("navigation"),
75
74
  "aria-expanded": "false",
76
75
  "aria-controls": "nav",
77
76
  children: /* @__PURE__ */ jsx(JlIcon, {
@@ -109,6 +108,9 @@ var JlAppShell = class extends JlElement {
109
108
  templateCss() {
110
109
  return css`${BASE_STYLES}${jl_app_shell_default}`;
111
110
  }
111
+ drawTexts() {
112
+ this._refs.menu.setAttribute("aria-label", jlText("navigation"));
113
+ }
112
114
  onConnect() {
113
115
  this._resize.observe(this);
114
116
  this._resize.observe(this._refs.tabs);
@@ -22,12 +22,13 @@ export declare class JlAuthLayout extends JlElement {
22
22
  get(): string[];
23
23
  set(setter: string[] | ((prevState: string[]) => string[])): void;
24
24
  }>>;
25
- /** Where the app comes from, at the foot of the panel. */
25
+ /** Where the app comes from, at the foot of the panel: jlib's own text when not set, nothing when empty. */
26
26
  readonly origin: Readonly<Readonly<{
27
- get(): string;
28
- set(setter: string | ((prevState: string) => string)): void;
27
+ get(): string | null;
28
+ set(setter: string | ((prevState: string | null) => string | null) | null): void;
29
29
  }>>;
30
30
  private readonly _refs;
31
+ protected drawTexts(): void;
31
32
  templateHtml(): Node;
32
33
  templateCss(): string;
33
34
  private renderPitch;
@@ -1,8 +1,9 @@
1
+ import { starredParts } from "../lib/text.js";
2
+ import { jlText } from "../lib/texts.js";
1
3
  import { BASE_STYLES, TOKEN_STYLES } from "../styles/shared.js";
2
4
  import { JlElement } from "../base/jl-element.js";
3
5
  import { jsonOf } from "../lib/attributes.js";
4
6
  import { registerIcons } from "../lib/icons.js";
5
- import { starredParts } from "../lib/text.js";
6
7
  import { JlIcon } from "../atoms/jl-icon.js";
7
8
  import jl_auth_layout_default from "./jl-auth-layout.css_raw.js";
8
9
  import { css } from "@jadis/core";
@@ -10,7 +11,6 @@ import { Check } from "lucide";
10
11
  import { jsx, jsxs } from "@jadis/core/jsx-runtime";
11
12
  // src/templates/jl-auth-layout.tsx
12
13
  registerIcons({ check: Check });
13
- var DEFAULT_ORIGIN = "Made in Switzerland by SyWare";
14
14
  var POINT_ICON_SIZE = 12;
15
15
  var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
16
16
  var MARK_VIEW_BOX = "429 1092 2155 2358";
@@ -62,17 +62,22 @@ var JlAuthLayout = class extends JlElement {
62
62
  attribute: "points",
63
63
  parse: jsonOf([])
64
64
  });
65
- /** Where the app comes from, at the foot of the panel. */
66
- origin = this.useChange(DEFAULT_ORIGIN, (value) => {
67
- this._refs.origin.textContent = value;
68
- this._refs.origin.hidden = value === "";
69
- }, { attribute: "origin" });
65
+ /** Where the app comes from, at the foot of the panel: jlib's own text when not set, nothing when empty. */
66
+ origin = this.useChange(null, () => this.drawTexts(), {
67
+ attribute: "origin",
68
+ parse: (value) => value
69
+ });
70
70
  _refs = this.useRefs((ref) => ({
71
71
  headline: ref(".headline"),
72
72
  origin: ref(".origin"),
73
73
  points: ref(".points"),
74
74
  text: ref(".text")
75
75
  }));
76
+ drawTexts() {
77
+ const origin = this.origin.get() ?? jlText("authOrigin");
78
+ this._refs.origin.textContent = origin;
79
+ this._refs.origin.hidden = origin === "";
80
+ }
76
81
  templateHtml() {
77
82
  return /* @__PURE__ */ jsxs("div", {
78
83
  class: "screen",
@@ -100,10 +105,7 @@ var JlAuthLayout = class extends JlElement {
100
105
  class: "points",
101
106
  hidden: true
102
107
  }),
103
- /* @__PURE__ */ jsx("p", {
104
- class: "origin",
105
- children: DEFAULT_ORIGIN
106
- }),
108
+ /* @__PURE__ */ jsx("p", { class: "origin" }),
107
109
  backdrop()
108
110
  ]
109
111
  }), /* @__PURE__ */ jsx("main", {
@@ -43,6 +43,7 @@ export declare class JlPage extends JlElement {
43
43
  templateHtml(): Node;
44
44
  templateCss(): string;
45
45
  onConnect(): void;
46
+ protected drawTexts(): void;
46
47
  /** The back link stays out of the header's breadcrumb slot without an address, so the header takes no room for it. */
47
48
  private renderBack;
48
49
  private renderTitle;
@@ -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 { define } from "../lib/define.js";
5
6
  import { registerIcons } from "../lib/icons.js";
6
- import { jlText } from "../lib/texts.js";
7
7
  import { setOrRemove } from "../lib/dom.js";
8
8
  import { JlButton } from "../atoms/jl-button.js";
9
9
  import { JlPageHeader } from "../organisms/jl-page-header.js";
@@ -83,6 +83,9 @@ var JlPage = class extends JlElement {
83
83
  this.renderTitle();
84
84
  this._refs.back.events.register("press", () => this.events.emit("back"));
85
85
  }
86
+ drawTexts() {
87
+ this.renderBack();
88
+ }
86
89
  /** The back link stays out of the header's breadcrumb slot without an address, so the header takes no room for it. */
87
90
  renderBack() {
88
91
  const back = this._refs.back;
@@ -55,6 +55,7 @@ export declare class JlSplitView extends JlElement {
55
55
  reset(): void;
56
56
  templateHtml(): Node;
57
57
  templateCss(): string;
58
+ protected drawTexts(): void;
58
59
  onConnect(): void;
59
60
  onDisconnect(): void;
60
61
  private renderStacked;
@@ -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 { clampedNumber, oneOf } from "../lib/attributes.js";
4
- import { jlText } from "../lib/texts.js";
5
5
  import { watchSizes } from "../lib/resize.js";
6
6
  import { clampMin, clampSplit, positionAfterKey, positionAt } from "../lib/split.js";
7
7
  import jl_split_view_default from "./jl-split-view.css_raw.js";
@@ -62,9 +62,7 @@ var JlSplitView = class extends JlElement {
62
62
  parse: oneOf(SPLIT_PANES, "start")
63
63
  });
64
64
  /** The divider's name for screen readers. */
65
- label = this.useChange(jlText("resizePanes"), (value) => {
66
- this._refs.divider.setAttribute("aria-label", value === "" ? jlText("resizePanes") : value);
67
- }, { attribute: "label" });
65
+ label = this.useChange("", () => this.drawTexts(), { attribute: "label" });
68
66
  _drag = { from: DEFAULT_POSITION };
69
67
  _resize = watchSizes(() => this.renderStacked());
70
68
  /** Whether it shows one pane at a time now. */
@@ -112,6 +110,9 @@ var JlSplitView = class extends JlElement {
112
110
  templateCss() {
113
111
  return css`${BASE_STYLES}${jl_split_view_default}`;
114
112
  }
113
+ drawTexts() {
114
+ this._refs.divider.setAttribute("aria-label", this.label.get() || jlText("resizePanes"));
115
+ }
115
116
  onConnect() {
116
117
  this._resize.observe(this);
117
118
  const divider = this._refs.divider;
@@ -1,5 +1,30 @@
1
- import type { DEFAULT_TEXTS } from '../lib/texts';
1
+ import type { Bus, TranslationLoader, Translations } from '@jadis/core';
2
+ import type { DEFAULT_TEXTS, JL_LANGUAGES } from '../lib/texts';
3
+ /** jlib's texts in English: the source every language translates. */
4
+ export type JlSourceTexts = typeof DEFAULT_TEXTS;
2
5
  /** The name of one of the texts jlib's components show on their own. */
3
- export type JlTextKey = keyof typeof DEFAULT_TEXTS;
4
- /** The texts in the page's language: some or all of them, the rest staying in English. */
5
- export type JlTexts = Partial<Record<JlTextKey, string>>;
6
+ export type JlTextKey = keyof JlSourceTexts;
7
+ /** A language jlib translates itself. */
8
+ export type JlLanguage = (typeof JL_LANGUAGES)[number];
9
+ /** All of jlib's texts in one language, each with the placeholders of its English text. */
10
+ export type JlLanguageTexts = Translations<JlSourceTexts>;
11
+ /** Some of jlib's texts in one language, each with the placeholders of its English text. */
12
+ export type JlFixes = Partial<JlLanguageTexts>;
13
+ /** What a language added to jlib shows: its texts, their loader, or one of jlib's own languages. */
14
+ export type JlLanguageEntry = JlLanguageTexts | TranslationLoader<JlLanguageTexts> | JlLanguage;
15
+ /** A translator jlib's texts can follow, such as a Jadis `Translator`. */
16
+ export interface FollowedTranslator<Locale extends string> {
17
+ readonly locale: Locale;
18
+ readonly locales: readonly Locale[];
19
+ readonly bus: Bus<{
20
+ change: Locale;
21
+ }>;
22
+ }
23
+ /** A locale a page can add: one jlib does not translate itself, whose texts are fixed instead. */
24
+ export type AddedLocale<Locale extends string> = Locale extends JlLanguage ? `jlib translates ${Locale} itself: fix its texts with jlTexts.fix` : Locale;
25
+ /** The texts shown, in the locale they are shown for, with that locale's number format. */
26
+ export interface ShownTexts {
27
+ locale: string;
28
+ numbers: Intl.NumberFormat;
29
+ texts: Readonly<Record<JlTextKey, string>>;
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syware/jlib",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "A tree-shakeable component library on Jadis and native Web Components, organised in atomic design",
5
5
  "keywords": [
6
6
  "web-components",
@@ -85,7 +85,7 @@
85
85
  "prepublishOnly": "npm run check"
86
86
  },
87
87
  "peerDependencies": {
88
- "@jadis/core": "^1.4.0"
88
+ "@jadis/core": "^1.5.1"
89
89
  },
90
90
  "dependencies": {
91
91
  "lucide": "^1.61.0"
@@ -94,7 +94,7 @@
94
94
  "@biomejs/biome": "^2.6.3",
95
95
  "@fontsource-variable/jetbrains-mono": "^5.3.0",
96
96
  "@fontsource-variable/manrope": "^5.3.0",
97
- "@jadis/core": "^1.4.2",
97
+ "@jadis/core": "^1.5.1",
98
98
  "@types/node": "^24.13.3",
99
99
  "playwright-core": "^1.64.1",
100
100
  "typescript": "^7.0.2",