@syware/jlib 0.13.0 → 0.15.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 (115) hide show
  1. package/README.md +12 -8
  2. package/dist/atoms/jl-avatar.d.ts +2 -0
  3. package/dist/atoms/jl-avatar.js +11 -6
  4. package/dist/atoms/jl-button.d.ts +6 -0
  5. package/dist/atoms/jl-button.js +22 -8
  6. package/dist/atoms/jl-chip.js +2 -1
  7. package/dist/atoms/jl-input.js +3 -3
  8. package/dist/atoms/jl-link.d.ts +1 -0
  9. package/dist/atoms/jl-link.js +5 -2
  10. package/dist/atoms/jl-progress-ring.d.ts +2 -0
  11. package/dist/atoms/jl-progress-ring.js +9 -4
  12. package/dist/atoms/jl-progress.d.ts +1 -0
  13. package/dist/atoms/jl-progress.js +8 -4
  14. package/dist/atoms/jl-rating.d.ts +2 -0
  15. package/dist/atoms/jl-rating.js +11 -6
  16. package/dist/atoms/jl-select.css.js +1 -1
  17. package/dist/atoms/jl-select.d.ts +4 -0
  18. package/dist/atoms/jl-select.js +18 -2
  19. package/dist/atoms/jl-switch.css.js +1 -1
  20. package/dist/atoms/jl-textarea.js +2 -2
  21. package/dist/base/jl-form-control.d.ts +3 -2
  22. package/dist/base/jl-form-control.js +14 -4
  23. package/dist/index.d.ts +2 -1
  24. package/dist/lib/dom.d.ts +5 -0
  25. package/dist/lib/dom.js +9 -1
  26. package/dist/lib/download.js +10 -2
  27. package/dist/lib/floating.d.ts +5 -0
  28. package/dist/lib/floating.js +21 -2
  29. package/dist/lib/fuzzy.d.ts +3 -2
  30. package/dist/lib/fuzzy.js +15 -4
  31. package/dist/lib/hotkey.d.ts +13 -0
  32. package/dist/lib/hotkey.js +2 -1
  33. package/dist/lib/key-shortcut.js +11 -29
  34. package/dist/lib/modal.d.ts +24 -0
  35. package/dist/lib/modal.js +52 -0
  36. package/dist/lib/numeric.d.ts +5 -0
  37. package/dist/lib/numeric.js +11 -1
  38. package/dist/lib/option-filter.d.ts +2 -0
  39. package/dist/lib/option-filter.js +1 -1
  40. package/dist/lib/press.d.ts +11 -0
  41. package/dist/lib/press.js +31 -0
  42. package/dist/lib/progress.d.ts +0 -5
  43. package/dist/lib/progress.js +1 -9
  44. package/dist/lib/roving.d.ts +6 -0
  45. package/dist/lib/roving.js +14 -1
  46. package/dist/lib/table.js +12 -4
  47. package/dist/lib/texts-de.d.ts +12 -0
  48. package/dist/lib/texts-de.js +12 -0
  49. package/dist/lib/texts-fr.d.ts +12 -0
  50. package/dist/lib/texts-fr.js +12 -0
  51. package/dist/lib/texts.d.ts +12 -0
  52. package/dist/lib/texts.js +12 -0
  53. package/dist/molecules/jl-accordion-item.js +2 -1
  54. package/dist/molecules/jl-calendar.d.ts +4 -0
  55. package/dist/molecules/jl-calendar.js +16 -5
  56. package/dist/molecules/jl-chip-group.css.js +1 -1
  57. package/dist/molecules/jl-chip-group.js +4 -4
  58. package/dist/molecules/jl-code-block.css.js +1 -1
  59. package/dist/molecules/jl-combobox.d.ts +4 -0
  60. package/dist/molecules/jl-combobox.js +23 -11
  61. package/dist/molecules/jl-copy-button.css.js +1 -1
  62. package/dist/molecules/jl-copy-button.d.ts +11 -4
  63. package/dist/molecules/jl-copy-button.js +48 -22
  64. package/dist/molecules/jl-date-picker.d.ts +4 -0
  65. package/dist/molecules/jl-date-picker.js +18 -12
  66. package/dist/molecules/jl-field.d.ts +5 -1
  67. package/dist/molecules/jl-field.js +24 -5
  68. package/dist/molecules/jl-file-drop.css.js +1 -1
  69. package/dist/molecules/jl-file-drop.d.ts +4 -0
  70. package/dist/molecules/jl-file-drop.js +16 -8
  71. package/dist/molecules/jl-input-list.js +13 -6
  72. package/dist/molecules/jl-load-state.d.ts +8 -0
  73. package/dist/molecules/jl-load-state.js +33 -7
  74. package/dist/molecules/jl-menu.d.ts +21 -1
  75. package/dist/molecules/jl-menu.js +58 -6
  76. package/dist/molecules/jl-number-input.d.ts +2 -0
  77. package/dist/molecules/jl-number-input.js +12 -8
  78. package/dist/molecules/jl-radio-group.js +4 -3
  79. package/dist/molecules/jl-search.js +2 -2
  80. package/dist/molecules/jl-segmented.js +2 -2
  81. package/dist/molecules/jl-tabs.js +2 -2
  82. package/dist/molecules/jl-tag-input.css.js +1 -1
  83. package/dist/molecules/jl-tag-input.d.ts +4 -0
  84. package/dist/molecules/jl-tag-input.js +17 -9
  85. package/dist/molecules/jl-toast.js +10 -6
  86. package/dist/molecules/jl-tooltip.js +8 -2
  87. package/dist/organisms/jl-command-palette.css.js +1 -1
  88. package/dist/organisms/jl-command-palette.d.ts +2 -0
  89. package/dist/organisms/jl-command-palette.js +10 -4
  90. package/dist/organisms/jl-dialog.d.ts +3 -0
  91. package/dist/organisms/jl-dialog.js +13 -3
  92. package/dist/organisms/jl-drawer.d.ts +3 -0
  93. package/dist/organisms/jl-drawer.js +13 -3
  94. package/dist/organisms/jl-flow.d.ts +2 -0
  95. package/dist/organisms/jl-flow.js +29 -9
  96. package/dist/organisms/jl-table.css.js +1 -1
  97. package/dist/organisms/jl-table.d.ts +15 -4
  98. package/dist/organisms/jl-table.js +40 -17
  99. package/dist/organisms/jl-toaster.d.ts +13 -2
  100. package/dist/organisms/jl-toaster.js +47 -4
  101. package/dist/organisms/jl-tree.css.js +1 -1
  102. package/dist/organisms/jl-tree.d.ts +23 -4
  103. package/dist/organisms/jl-tree.js +74 -18
  104. package/dist/styles/base.css.js +1 -1
  105. package/dist/styles/control.css.js +1 -1
  106. package/dist/styles/tokens.css.js +1 -1
  107. package/dist/tokens.css +4 -3
  108. package/dist/types/jl-load-state.types.d.ts +7 -0
  109. package/dist/types/jl-table.types.d.ts +12 -0
  110. package/dist/types/jl-tree.types.d.ts +17 -0
  111. package/dist/types/press.types.d.ts +6 -0
  112. package/package.json +7 -3
  113. package/dist/lib/roving-index.d.ts +0 -10
  114. package/dist/lib/roving-index.js +0 -32
  115. /package/dist/types/{roving-index.types.d.ts → roving.types.d.ts} +0 -0
package/dist/lib/dom.js CHANGED
@@ -7,6 +7,14 @@ function setOrRemove(element, name, value) {
7
7
  }
8
8
  element.setAttribute(name, value);
9
9
  }
10
+ var ARIA_TRUE = "true";
11
+ /**
12
+ * Says an ARIA state is on, or removes it: `aria-invalid`, `aria-required`, `aria-disabled`, `aria-busy`. A bare
13
+ * attribute, as `toggleAttribute` writes it (`aria-invalid=""`), is one browsers read as false.
14
+ */
15
+ function setAriaFlag(element, name, on) {
16
+ setOrRemove(element, name, on ? ARIA_TRUE : "");
17
+ }
10
18
  var sequence = { next: 0 };
11
19
  /** A unique id within the page, for wiring `aria-controls`, `aria-labelledby` and the like inside a shadow root. */
12
20
  function uniqueId(prefix) {
@@ -22,4 +30,4 @@ function svgElement(tag, attributes) {
22
30
  }
23
31
  /** Whether a click asks the browser for something of its own: a new tab or window, a download. */
24
32
  var isModifiedClick = (event) => event.ctrlKey || event.metaKey || event.shiftKey || event.altKey || event.button !== 0;
25
- export { isModifiedClick, setOrRemove, svgElement, uniqueId };
33
+ export { isModifiedClick, setAriaFlag, setOrRemove, svgElement, uniqueId };
@@ -3,16 +3,24 @@ var FILE_NAME_UTF8 = /filename\*\s*=\s*(?:UTF-8|utf-8)''([^;]+)/;
3
3
  var FILE_NAME = /filename\s*=\s*"?([^";]+)"?/;
4
4
  var REVOKE_DELAY_MS = 1e3;
5
5
  var ADDRESS_BASE = "http://localhost/";
6
+ /** A percent-encoded name, decoded; one that is not well formed (a lone `%`) is the name as it is written. */
7
+ function decodedName(name) {
8
+ try {
9
+ return decodeURIComponent(name);
10
+ } catch {
11
+ return name;
12
+ }
13
+ }
6
14
  /** The file name a Content-Disposition header gives (its UTF-8 form first), or none. */
7
15
  function dispositionFileName(header) {
8
16
  const utf8 = FILE_NAME_UTF8.exec(header ?? "")?.[1];
9
- if (utf8 !== void 0) return decodeURIComponent(utf8.trim());
17
+ if (utf8 !== void 0) return decodedName(utf8.trim());
10
18
  return FILE_NAME.exec(header ?? "")?.[1]?.trim() || void 0;
11
19
  }
12
20
  /** A file name for an address: its last path segment, or the fallback when it has none. */
13
21
  function urlFileName(url, fallback) {
14
22
  const segment = new URL(url, ADDRESS_BASE).pathname.split("/").at(-1) ?? "";
15
- return segment === "" ? fallback : decodeURIComponent(segment);
23
+ return segment === "" ? fallback : decodedName(segment);
16
24
  }
17
25
  /** What a failed answer's body says: `{ error: { message } }`, `{ error: "…" }`, `{ message }`, or its status. */
18
26
  function answerError(body, status) {
@@ -17,6 +17,11 @@ export declare function positionFloating(anchor: Element, floating: HTMLElement,
17
17
  floating: Rect;
18
18
  placement: Placement;
19
19
  };
20
+ /**
21
+ * Puts a fixed-position element at a point of the window, as a menu opens where the pointer asked for it: its top
22
+ * left corner there, above the point when there is no room under it, and kept inside the window.
23
+ */
24
+ export declare function placeAtPoint(point: Point, floating: HTMLElement): void;
20
25
  /** Puts a fixed-position element next to its anchor; returns the placement it got after flipping. */
21
26
  export declare function placeFloating(anchor: Element, floating: HTMLElement, placement: Placement, gap?: number): Placement;
22
27
  /** Keeps a floating element by its anchor while the page scrolls or resizes, until the signal aborts. */
@@ -99,6 +99,13 @@ function computePosition(anchor, floating, viewport, placement, gap = DEFAULT_GA
99
99
  */
100
100
  function positionFloating(anchor, floating, placement, gap) {
101
101
  const rect = anchor.getBoundingClientRect();
102
+ return {
103
+ anchor: rect,
104
+ ...positionBy(rect, floating, placement, gap)
105
+ };
106
+ }
107
+ /** Puts a fixed-position element next to a rectangle of the window, and gives where it went. */
108
+ function positionBy(rect, floating, placement, gap) {
102
109
  const viewport = {
103
110
  height: window.innerHeight,
104
111
  width: document.documentElement.clientWidth
@@ -114,7 +121,6 @@ function positionFloating(anchor, floating, placement, gap) {
114
121
  floating.style.top = `${top}px`;
115
122
  floating.dataset.placement = result.placement;
116
123
  return {
117
- anchor: rect,
118
124
  floating: {
119
125
  ...size,
120
126
  left,
@@ -123,6 +129,19 @@ function positionFloating(anchor, floating, placement, gap) {
123
129
  placement: result.placement
124
130
  };
125
131
  }
132
+ var AT_POINT = "bottom-start";
133
+ var NO_GAP = 0;
134
+ /**
135
+ * Puts a fixed-position element at a point of the window, as a menu opens where the pointer asked for it: its top
136
+ * left corner there, above the point when there is no room under it, and kept inside the window.
137
+ */
138
+ function placeAtPoint(point, floating) {
139
+ positionBy({
140
+ ...point,
141
+ height: 0,
142
+ width: 0
143
+ }, floating, AT_POINT, NO_GAP);
144
+ }
126
145
  /** Puts a fixed-position element next to its anchor; returns the placement it got after flipping. */
127
146
  function placeFloating(anchor, floating, placement, gap) {
128
147
  return positionFloating(anchor, floating, placement, gap).placement;
@@ -143,4 +162,4 @@ function followAnchor(anchor, floating, placement, signal, gap) {
143
162
  });
144
163
  update();
145
164
  }
146
- export { PLACEMENTS, computePosition, followAnchor, placeFloating, positionFloating };
165
+ export { PLACEMENTS, computePosition, followAnchor, placeAtPoint, placeFloating, positionFloating };
@@ -18,8 +18,9 @@ export declare const FUZZY_SCORE: {
18
18
  /** Whether the letter at `index` starts a word of the text. */
19
19
  export declare function isWordStart(text: string, index: number): boolean;
20
20
  /**
21
- * Whether the letters of the query appear in the text in order (spaces ignored, any case), and how well: the
22
- * best placement by contiguity and word starts. `null` when they do not; an empty query matches with 0.
21
+ * Whether the letters of the query appear in the text in order (spaces ignored, any case, with or without their
22
+ * accents), and how well: the best placement by contiguity and word starts. `null` when they do not; an empty query
23
+ * matches with 0.
23
24
  */
24
25
  export declare function fuzzyMatch(query: string, text: string): FuzzyMatch | null;
25
26
  /** The text cut into runs of matched and unmatched letters, for drawing the matches in `<mark>`. */
package/dist/lib/fuzzy.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { foldCharacter } from "./option-filter.js";
1
2
  // src/lib/fuzzy.ts
2
3
  /**
3
4
  * What a matched letter is worth. Letters next to each other and letters that start a word count most, so "ofi"
@@ -18,6 +19,15 @@ var FUZZY_SCORE = {
18
19
  var NO_MATCH = Number.NEGATIVE_INFINITY;
19
20
  var NO_INDEX = -1;
20
21
  var WHITESPACE = /\s+/g;
22
+ /**
23
+ * A character as the search compares it: without its accent and in lower case, as the options' filter folds it, so
24
+ * "parametres" finds "Paramètres". Kept as it is when folding it gives more or fewer characters: a match's
25
+ * positions are those of the text.
26
+ */
27
+ function comparable(character) {
28
+ const folded = foldCharacter(character);
29
+ return folded.length === 1 ? folded : character.toLowerCase();
30
+ }
21
31
  var SEPARATORS = /* @__PURE__ */ new Set([
22
32
  " ",
23
33
  "-",
@@ -103,12 +113,13 @@ function backtrack(rows, end) {
103
113
  return positions;
104
114
  }
105
115
  /**
106
- * Whether the letters of the query appear in the text in order (spaces ignored, any case), and how well: the
107
- * best placement by contiguity and word starts. `null` when they do not; an empty query matches with 0.
116
+ * Whether the letters of the query appear in the text in order (spaces ignored, any case, with or without their
117
+ * accents), and how well: the best placement by contiguity and word starts. `null` when they do not; an empty query
118
+ * matches with 0.
108
119
  */
109
120
  function fuzzyMatch(query, text) {
110
- const needle = query.replace(WHITESPACE, "").toLowerCase().split("");
111
- const haystack = text.split("").map((char) => char.toLowerCase());
121
+ const needle = query.replace(WHITESPACE, "").split("").map(comparable);
122
+ const haystack = text.split("").map(comparable);
112
123
  const [first, ...rest] = needle;
113
124
  if (first === void 0) return {
114
125
  positions: [],
@@ -1,4 +1,17 @@
1
1
  import type { Hotkey, KeyPress } from '../types/hotkey.types';
2
+ export type Modifier = 'mod' | 'ctrl' | 'meta' | 'shift' | 'alt';
3
+ /** The words a key combination may use for each modifier: "mod+k", "cmd+shift+p", "ctrl+/". */
4
+ export declare const MODIFIER_NAMES: Record<string, Modifier>;
5
+ /** How each modifier reads on a keycap, on Apple keyboards and elsewhere. */
6
+ export declare const MODIFIER_LABELS: Record<Modifier, {
7
+ apple: string;
8
+ other: string;
9
+ }>;
10
+ /** The order keycaps are written in: ⌃⌥⇧⌘ on Apple, Ctrl+Alt+Shift elsewhere. */
11
+ export declare const MODIFIER_ORDER: {
12
+ apple: readonly Modifier[];
13
+ other: readonly Modifier[];
14
+ };
2
15
  /** Reads a combination such as `mod+k` or `ctrl+shift+p`: `mod` is ⌘ on Apple and Ctrl elsewhere. */
3
16
  export declare function parseHotkey(text: string): Hotkey;
4
17
  /** Whether a key press is the combination; extra modifiers make it another one. */
@@ -1,5 +1,6 @@
1
1
  // src/lib/hotkey.ts
2
2
  var SEPARATOR = "+";
3
+ /** The words a key combination may use for each modifier: "mod+k", "cmd+shift+p", "ctrl+/". */
3
4
  var MODIFIER_NAMES = {
4
5
  alt: "alt",
5
6
  cmd: "meta",
@@ -98,4 +99,4 @@ function hotkeyLabels(text, apple) {
98
99
  function isApplePlatform(platform) {
99
100
  return /mac|iphone|ipad|ipod/i.test(platform);
100
101
  }
101
- export { hotkeyLabels, isApplePlatform, matchesHotkey, parseHotkey };
102
+ export { MODIFIER_LABELS, MODIFIER_NAMES, MODIFIER_ORDER, hotkeyLabels, isApplePlatform, matchesHotkey, parseHotkey };
@@ -1,25 +1,7 @@
1
+ import { MODIFIER_LABELS, MODIFIER_NAMES, MODIFIER_ORDER } from "./hotkey.js";
1
2
  // src/lib/key-shortcut.ts
2
- /** The words a shortcut may use for each modifier: "mod+k", "cmd+shift+p", "ctrl+/". */
3
- var MODIFIER_WORDS = {
4
- alt: "alt",
5
- cmd: "meta",
6
- command: "meta",
7
- control: "ctrl",
8
- ctrl: "ctrl",
9
- meta: "meta",
10
- mod: "mod",
11
- option: "alt",
12
- shift: "shift"
13
- };
14
3
  var SEPARATOR = "+";
15
- var isModifierWord = (word) => Object.hasOwn(MODIFIER_WORDS, word);
16
- var MAC_SYMBOLS = {
17
- alt: "⌥",
18
- ctrl: "⌃",
19
- meta: "⌘",
20
- mod: "⌘",
21
- shift: "⇧"
22
- };
4
+ var isModifierWord = (word) => Object.hasOwn(MODIFIER_NAMES, word);
23
5
  var PC_NAMES = {
24
6
  alt: "Alt",
25
7
  ctrl: "Ctrl",
@@ -27,6 +9,13 @@ var PC_NAMES = {
27
9
  mod: "Ctrl",
28
10
  shift: "Shift"
29
11
  };
12
+ var MAC_SYMBOLS = {
13
+ alt: MODIFIER_LABELS.alt.apple,
14
+ ctrl: MODIFIER_LABELS.ctrl.apple,
15
+ meta: MODIFIER_LABELS.meta.apple,
16
+ mod: MODIFIER_LABELS.mod.apple,
17
+ shift: MODIFIER_LABELS.shift.apple
18
+ };
30
19
  var ARIA_NAMES = {
31
20
  alt: "Alt",
32
21
  ctrl: "Control",
@@ -34,13 +23,6 @@ var ARIA_NAMES = {
34
23
  mod: "Control",
35
24
  shift: "Shift"
36
25
  };
37
- var MODIFIER_ORDER = [
38
- "ctrl",
39
- "alt",
40
- "shift",
41
- "mod",
42
- "meta"
43
- ];
44
26
  /** Names of keys that read better than their `KeyboardEvent.key`. */
45
27
  var KEY_LABELS = {
46
28
  " ": "Space",
@@ -59,7 +41,7 @@ function parseShortcut(text) {
59
41
  const parts = text.trim().toLowerCase().split(SEPARATOR).map((part) => part.trim());
60
42
  const key = parts.at(-1) ?? "";
61
43
  if (key === "" || isModifierWord(key)) return null;
62
- const modifiers = new Set(parts.slice(0, -1).filter(isModifierWord).map((part) => MODIFIER_WORDS[part]));
44
+ const modifiers = new Set(parts.slice(0, -1).filter(isModifierWord).map((part) => MODIFIER_NAMES[part]));
63
45
  return {
64
46
  alt: modifiers.has("alt"),
65
47
  ctrl: modifiers.has("ctrl"),
@@ -81,7 +63,7 @@ function matchesShortcut(event, shortcut, mac) {
81
63
  const shiftMatters = shortcut.shift || hasCommandModifier(shortcut);
82
64
  return event.key.toLowerCase() === shortcut.key && event.ctrlKey === wantsCtrl && event.metaKey === wantsMeta && event.altKey === shortcut.alt && (!shiftMatters || event.shiftKey === shortcut.shift);
83
65
  }
84
- var activeModifiers = (shortcut) => MODIFIER_ORDER.filter((modifier) => shortcut[modifier]);
66
+ var activeModifiers = (shortcut) => MODIFIER_ORDER.apple.filter((modifier) => shortcut[modifier]);
85
67
  var keyLabel = (key) => KEY_LABELS[key] ?? (key.length === 1 ? key.toUpperCase() : key);
86
68
  /** The keys to draw for a shortcut, one label per key: ["⌘", "K"] on a Mac, ["Ctrl", "K"] elsewhere. */
87
69
  function shortcutLabels(shortcut, mac) {
@@ -0,0 +1,24 @@
1
+ import { Bus } from '@jadis/core';
2
+ /** Emits `change` when one of jlib's modals opens or closes. */
3
+ export declare const modalBus: Bus<{
4
+ change: undefined;
5
+ }>;
6
+ /**
7
+ * The modal on top, when one is open. A modal makes everything outside it inert, the top layer included: what must
8
+ * stay usable over it, as the toaster's notifications must, sits inside this element meanwhile.
9
+ */
10
+ export declare const topModal: () => HTMLDialogElement | undefined;
11
+ /** Says a modal shows, on top of the others: called after its `showModal()`. */
12
+ export declare function modalOpened(dialog: HTMLDialogElement): void;
13
+ /** Says a modal shows no more: it closed, or left the page. Nothing for one that was not showing. */
14
+ export declare function modalClosed(dialog: HTMLDialogElement): void;
15
+ /**
16
+ * Calls back for a press on a modal's backdrop: a click that started and ended on the dialog element itself, around
17
+ * its content. A selection dragged out of a field ends its click on the dialog too, and is not a press outside.
18
+ */
19
+ export declare function onBackdropPress(dialog: HTMLDialogElement, pressed: () => void, signal: AbortSignal): void;
20
+ /**
21
+ * Keeps a persistent modal open on Escape. Refusing its `cancel` event is not enough: a browser lets a page refuse
22
+ * a close request only a few times in a row, then closes the dialog. `closedby="none"` asks for no request at all.
23
+ */
24
+ export declare function setPersistent(dialog: HTMLDialogElement, persistent: boolean): void;
@@ -0,0 +1,52 @@
1
+ import { setOrRemove } from "./dom.js";
2
+ import { Bus } from "@jadis/core";
3
+ // src/lib/modal.ts
4
+ var shown = [];
5
+ /** Emits `change` when one of jlib's modals opens or closes. */
6
+ var modalBus = new Bus();
7
+ /**
8
+ * The modal on top, when one is open. A modal makes everything outside it inert, the top layer included: what must
9
+ * stay usable over it, as the toaster's notifications must, sits inside this element meanwhile.
10
+ */
11
+ var topModal = () => shown.at(-1);
12
+ function forget(dialog) {
13
+ const index = shown.indexOf(dialog);
14
+ if (index !== -1) shown.splice(index, 1);
15
+ }
16
+ /** Says a modal shows, on top of the others: called after its `showModal()`. */
17
+ function modalOpened(dialog) {
18
+ forget(dialog);
19
+ shown.push(dialog);
20
+ modalBus.emit("change");
21
+ }
22
+ /** Says a modal shows no more: it closed, or left the page. Nothing for one that was not showing. */
23
+ function modalClosed(dialog) {
24
+ if (!shown.includes(dialog)) return;
25
+ forget(dialog);
26
+ modalBus.emit("change");
27
+ }
28
+ /**
29
+ * Calls back for a press on a modal's backdrop: a click that started and ended on the dialog element itself, around
30
+ * its content. A selection dragged out of a field ends its click on the dialog too, and is not a press outside.
31
+ */
32
+ function onBackdropPress(dialog, pressed, signal) {
33
+ const press = { startedOutside: false };
34
+ dialog.addEventListener("pointerdown", (event) => {
35
+ press.startedOutside = event.target === dialog;
36
+ }, { signal });
37
+ dialog.addEventListener("click", (event) => {
38
+ const outside = press.startedOutside && event.target === dialog;
39
+ press.startedOutside = false;
40
+ if (outside) pressed();
41
+ }, { signal });
42
+ }
43
+ var CLOSED_BY = "closedby";
44
+ var CLOSED_BY_NOTHING = "none";
45
+ /**
46
+ * Keeps a persistent modal open on Escape. Refusing its `cancel` event is not enough: a browser lets a page refuse
47
+ * a close request only a few times in a row, then closes the dialog. `closedby="none"` asks for no request at all.
48
+ */
49
+ function setPersistent(dialog, persistent) {
50
+ setOrRemove(dialog, CLOSED_BY, persistent ? CLOSED_BY_NOTHING : "");
51
+ }
52
+ export { modalBus, modalClosed, modalOpened, onBackdropPress, setPersistent, topModal };
@@ -1,6 +1,11 @@
1
1
  import type { SliderMark } from '../types/jl-slider.types';
2
2
  /** A number written in a field or an attribute; empty or unreadable text gives null. */
3
3
  export declare function parseNumber(text: string | null): number | null;
4
+ /**
5
+ * A number as people type it: with a point, or with the decimal comma of French and German keyboards ("1,5"). Several
6
+ * commas, or a comma beside a point, would be a grouping this cannot tell from decimals: unreadable, so null.
7
+ */
8
+ export declare function parseTypedNumber(text: string): number | null;
4
9
  /** A number kept within bounds; a null bound does not limit that side. */
5
10
  export declare function clamp(value: number, min: number | null, max: number | null): number;
6
11
  /** How many decimals a number has as written: 0.25 has 2, so sums of steps print without float noise. */
@@ -6,6 +6,16 @@ function parseNumber(text) {
6
6
  const parsed = Number(text.trim());
7
7
  return Number.isFinite(parsed) ? parsed : null;
8
8
  }
9
+ var DECIMAL_COMMA = ",";
10
+ var DECIMAL_POINT = ".";
11
+ /**
12
+ * A number as people type it: with a point, or with the decimal comma of French and German keyboards ("1,5"). Several
13
+ * commas, or a comma beside a point, would be a grouping this cannot tell from decimals: unreadable, so null.
14
+ */
15
+ function parseTypedNumber(text) {
16
+ if (text.split(DECIMAL_COMMA).length - 1 !== 1 || text.includes(DECIMAL_POINT)) return parseNumber(text);
17
+ return parseNumber(text.replace(DECIMAL_COMMA, DECIMAL_POINT));
18
+ }
9
19
  /** A number kept within bounds; a null bound does not limit that side. */
10
20
  function clamp(value, min, max) {
11
21
  const floored = min === null ? value : Math.max(min, value);
@@ -47,4 +57,4 @@ function marksOf(raw, min, max) {
47
57
  return isMarkObject(mark) ? mark : null;
48
58
  }).filter((mark) => mark !== null && mark.value >= min && mark.value <= max);
49
59
  }
50
- export { clamp, decimalsOf, fractionOf, marksOf, parseNumber, roundTo, stepValue };
60
+ export { clamp, decimalsOf, fractionOf, marksOf, parseNumber, parseTypedNumber, roundTo, stepValue };
@@ -1,4 +1,6 @@
1
1
  import type { TextMatch, TextMatchPart } from '../types/option-filter.types';
2
+ /** One character as matching sees it: lower case, without its accents ("É" gives "e"). */
3
+ export declare const foldCharacter: (character: string) => string;
2
4
  /** A text as matching sees it: "Crème Brûlée" gives "creme brulee". */
3
5
  export declare const foldText: (text: string) => string;
4
6
  /**
@@ -105,4 +105,4 @@ function nextEnabledIndex(options, current, direction) {
105
105
  }
106
106
  /** The first (1) or last (-1) option that can be chosen; -1 when none can. */
107
107
  var edgeEnabledIndex = (options, from) => nextEnabledIndex(options, -1, from);
108
- export { edgeEnabledIndex, filterOptions, findMatch, foldText, matchParts, nextEnabledIndex };
108
+ export { edgeEnabledIndex, filterOptions, findMatch, foldCharacter, foldText, matchParts, nextEnabledIndex };
@@ -0,0 +1,11 @@
1
+ import type { PressButton } from '../types/press.types';
2
+ /** The button of the press an event of the browser is; null for an event that is no press. */
3
+ export declare const pressButtonOf: (event: Pick<MouseEvent, 'button' | 'type'>) => PressButton | null;
4
+ /** The browser's events a press on a row or an item comes as: the main button, the middle one, the request for a menu. */
5
+ export declare const PRESS_EVENTS: readonly ['click', 'auxclick', 'contextmenu'];
6
+ /**
7
+ * Tells a press to the page.
8
+ * @returns Whether the page refused it: a listener cancelled the browser's event (`event.preventDefault()`), which
9
+ * keeps the browser's own menu away too. An event cancelled before it was told is not a refusal.
10
+ */
11
+ export declare function tellPress(event: Event, tell: () => void): boolean;
@@ -0,0 +1,31 @@
1
+ // src/lib/press.ts
2
+ var MIDDLE_BUTTON = 1;
3
+ /**
4
+ * The button each of the browser's events stands for. The secondary one is its `contextmenu`, which the keyboard's
5
+ * menu key and a long press fire too, with no button of their own; an `auxclick` is told for the middle button
6
+ * only, the right one having said its press already.
7
+ */
8
+ var PRESS_BUTTONS = {
9
+ auxclick: (event) => event.button === MIDDLE_BUTTON ? "auxiliary" : null,
10
+ click: () => "main",
11
+ contextmenu: () => "secondary"
12
+ };
13
+ /** The button of the press an event of the browser is; null for an event that is no press. */
14
+ var pressButtonOf = (event) => PRESS_BUTTONS[event.type]?.(event) ?? null;
15
+ /** The browser's events a press on a row or an item comes as: the main button, the middle one, the request for a menu. */
16
+ var PRESS_EVENTS = [
17
+ "click",
18
+ "auxclick",
19
+ "contextmenu"
20
+ ];
21
+ /**
22
+ * Tells a press to the page.
23
+ * @returns Whether the page refused it: a listener cancelled the browser's event (`event.preventDefault()`), which
24
+ * keeps the browser's own menu away too. An event cancelled before it was told is not a refusal.
25
+ */
26
+ function tellPress(event, tell) {
27
+ const cancelledBefore = event.defaultPrevented;
28
+ tell();
29
+ return !cancelledBefore && event.defaultPrevented;
30
+ }
31
+ export { PRESS_EVENTS, pressButtonOf, tellPress };
@@ -1,8 +1,3 @@
1
- /**
2
- * A number attribute that may be absent: `null` when it is missing or unreadable. A progress without a value is
3
- * indeterminate.
4
- */
5
- export declare const optionalNumber: (value: string | null) => number | null;
6
1
  /** How far along a value is, from 0 to 1; a maximum of 0 or less counts as no progress. */
7
2
  export declare function progressRatio(value: number, max: number): number;
8
3
  /** A ratio as the percentage people read: 0.456 gives "46%". */
@@ -1,13 +1,5 @@
1
1
  // src/lib/progress.ts
2
2
  var PERCENT = 100;
3
- /**
4
- * A number attribute that may be absent: `null` when it is missing or unreadable. A progress without a value is
5
- * indeterminate.
6
- */
7
- var optionalNumber = (value) => {
8
- const parsed = value === null || value.trim() === "" ? NaN : Number(value);
9
- return Number.isFinite(parsed) ? parsed : null;
10
- };
11
3
  /** How far along a value is, from 0 to 1; a maximum of 0 or less counts as no progress. */
12
4
  function progressRatio(value, max) {
13
5
  if (!(max > 0) || !Number.isFinite(value)) return 0;
@@ -30,4 +22,4 @@ function ringGeometry(size, thickness) {
30
22
  stroke
31
23
  };
32
24
  }
33
- export { optionalNumber, percentLabel, percentOf, progressRatio, ringGeometry };
25
+ export { percentLabel, percentOf, progressRatio, ringGeometry };
@@ -1,3 +1,4 @@
1
+ import type { RovingMove } from '../types/roving.types';
1
2
  /** The first entry that can be chosen. */
2
3
  export declare const firstIndex: (enabled: readonly boolean[]) => number;
3
4
  /** The last entry that can be chosen. */
@@ -9,3 +10,8 @@ export declare function stepIndex(enabled: readonly boolean[], from: number, ste
9
10
  * ignores case and the spaces before the label.
10
11
  */
11
12
  export declare function letterIndex(labels: readonly string[], enabled: readonly boolean[], from: number, letter: string): number;
13
+ /**
14
+ * Where the arrow keys of a list or a radio group move the focus, skipping the disabled items as native radios do.
15
+ * The list says which items are disabled; from nowhere (-1), next starts at the first item and previous at the last.
16
+ */
17
+ export declare function rovingIndex(disabled: readonly boolean[], from: number, move: RovingMove): number;
@@ -18,4 +18,17 @@ function letterIndex(labels, enabled, from, letter) {
18
18
  const wanted = letter.toLocaleLowerCase();
19
19
  return stepIndex(labels.map((label, index) => enabled[index] === true && label.trim().toLocaleLowerCase().startsWith(wanted)), from, 1);
20
20
  }
21
- export { firstIndex, lastIndex, letterIndex, stepIndex };
21
+ /**
22
+ * Where the arrow keys of a list or a radio group move the focus, skipping the disabled items as native radios do.
23
+ * The list says which items are disabled; from nowhere (-1), next starts at the first item and previous at the last.
24
+ */
25
+ function rovingIndex(disabled, from, move) {
26
+ const enabled = disabled.map((isDisabled) => !isDisabled);
27
+ return {
28
+ first: () => firstIndex(enabled),
29
+ last: () => lastIndex(enabled),
30
+ next: () => stepIndex(enabled, from, 1),
31
+ previous: () => stepIndex(enabled, from === NONE ? disabled.length : from, -1)
32
+ }[move]();
33
+ }
34
+ export { firstIndex, lastIndex, letterIndex, rovingIndex, stepIndex };
package/dist/lib/table.js CHANGED
@@ -32,14 +32,22 @@ function toTime(value) {
32
32
  if (typeof value === "string" && value.trim() !== "") return Date.parse(value);
33
33
  return NaN;
34
34
  }
35
- /** What a column orders its values by: numbers for numbers and dates, text for the rest. */
35
+ /**
36
+ * A value of a column that names no number or date format: a number keeps its value and a `Date` its time, so a
37
+ * column of numbers left as `text` does not order 10 before 2; anything else is ordered as text.
38
+ */
39
+ function ownOrder(value) {
40
+ if (typeof value === "number") return value;
41
+ return value instanceof Date ? value.getTime() : String(value);
42
+ }
43
+ /** What a column orders its values by: numbers for numbers and dates, the value's own order for the rest. */
36
44
  var SORT_VALUES = {
37
- badge: String,
38
- code: String,
45
+ badge: ownOrder,
46
+ code: ownOrder,
39
47
  date: toTime,
40
48
  datetime: toTime,
41
49
  number: toNumber,
42
- text: String
50
+ text: ownOrder
43
51
  };
44
52
  var TEXT_ORDERS = {
45
53
  badge: void 0,
@@ -1,5 +1,7 @@
1
1
  /** jlib's texts in German. */
2
2
  declare const _default: {
3
+ readonly addAfter: "Nach {name} hinzufügen";
4
+ readonly addAfterPort: "Nach {name}, {port} hinzufügen";
3
5
  readonly addedNamed: "Hinzugefügt: {names}";
4
6
  readonly addTag: "Fügen Sie mindestens ein Schlagwort hinzu.";
5
7
  readonly addValue: "Wert hinzufügen";
@@ -30,6 +32,7 @@ declare const _default: {
30
32
  readonly confirm: "Bestätigen";
31
33
  readonly copied: "Kopiert";
32
34
  readonly copy: "Kopieren";
35
+ readonly copyFailed: "Kopieren nicht möglich";
33
36
  readonly decrease: "Verringern";
34
37
  readonly details: "Details";
35
38
  readonly detailsOf: "Details zu {name}";
@@ -52,7 +55,11 @@ declare const _default: {
52
55
  readonly fillField: "Bitte füllen Sie dieses Feld aus.";
53
56
  readonly fitView: "Alle Knoten anzeigen";
54
57
  readonly flow: "Ablauf";
58
+ readonly flowDone: "Erledigt";
55
59
  readonly flowEmpty: "Noch nichts hier.";
60
+ readonly flowFailed: "Fehlgeschlagen";
61
+ readonly flowRunning: "Läuft";
62
+ readonly flowWaiting: "Wartet";
56
63
  readonly hidePassword: "Passwort verbergen";
57
64
  readonly increase: "Erhöhen";
58
65
  readonly leave: "Verlassen";
@@ -74,6 +81,7 @@ declare const _default: {
74
81
  readonly noRating: "Keine Bewertung";
75
82
  readonly noResults: "Keine Ergebnisse";
76
83
  readonly notifications: "Benachrichtigungen";
84
+ readonly opensInNewTab: "(öffnet in neuem Tab)";
77
85
  readonly page: "Seite";
78
86
  readonly pageNumber: "Seite {page}";
79
87
  readonly pageOfTotal: "{page} von {total}";
@@ -101,6 +109,10 @@ declare const _default: {
101
109
  readonly showOptions: "Optionen anzeigen";
102
110
  readonly showPagesOf: "Seiten von {name} anzeigen";
103
111
  readonly showPassword: "Passwort anzeigen";
112
+ readonly statusAway: "abwesend";
113
+ readonly statusBusy: "beschäftigt";
114
+ readonly statusOffline: "offline";
115
+ readonly statusOnline: "online";
104
116
  readonly stay: "Weiter bearbeiten";
105
117
  readonly stepCurrent: ", aktueller Schritt";
106
118
  readonly stepDone: ", abgeschlossen";
@@ -3,6 +3,8 @@ import { defineTranslations } from "@jadis/core";
3
3
  // src/lib/texts-de.ts
4
4
  /** jlib's texts in German. */
5
5
  var texts_de_default = defineTranslations(DEFAULT_TEXTS, {
6
+ addAfter: "Nach {name} hinzufügen",
7
+ addAfterPort: "Nach {name}, {port} hinzufügen",
6
8
  addedNamed: "Hinzugefügt: {names}",
7
9
  addTag: "Fügen Sie mindestens ein Schlagwort hinzu.",
8
10
  addValue: "Wert hinzufügen",
@@ -33,6 +35,7 @@ var texts_de_default = defineTranslations(DEFAULT_TEXTS, {
33
35
  confirm: "Bestätigen",
34
36
  copied: "Kopiert",
35
37
  copy: "Kopieren",
38
+ copyFailed: "Kopieren nicht möglich",
36
39
  decrease: "Verringern",
37
40
  details: "Details",
38
41
  detailsOf: "Details zu {name}",
@@ -55,7 +58,11 @@ var texts_de_default = defineTranslations(DEFAULT_TEXTS, {
55
58
  fillField: "Bitte füllen Sie dieses Feld aus.",
56
59
  fitView: "Alle Knoten anzeigen",
57
60
  flow: "Ablauf",
61
+ flowDone: "Erledigt",
58
62
  flowEmpty: "Noch nichts hier.",
63
+ flowFailed: "Fehlgeschlagen",
64
+ flowRunning: "Läuft",
65
+ flowWaiting: "Wartet",
59
66
  hidePassword: "Passwort verbergen",
60
67
  increase: "Erhöhen",
61
68
  leave: "Verlassen",
@@ -77,6 +84,7 @@ var texts_de_default = defineTranslations(DEFAULT_TEXTS, {
77
84
  noRating: "Keine Bewertung",
78
85
  noResults: "Keine Ergebnisse",
79
86
  notifications: "Benachrichtigungen",
87
+ opensInNewTab: "(öffnet in neuem Tab)",
80
88
  page: "Seite",
81
89
  pageNumber: "Seite {page}",
82
90
  pageOfTotal: "{page} von {total}",
@@ -104,6 +112,10 @@ var texts_de_default = defineTranslations(DEFAULT_TEXTS, {
104
112
  showOptions: "Optionen anzeigen",
105
113
  showPagesOf: "Seiten von {name} anzeigen",
106
114
  showPassword: "Passwort anzeigen",
115
+ statusAway: "abwesend",
116
+ statusBusy: "beschäftigt",
117
+ statusOffline: "offline",
118
+ statusOnline: "online",
107
119
  stay: "Weiter bearbeiten",
108
120
  stepCurrent: ", aktueller Schritt",
109
121
  stepDone: ", abgeschlossen",