@syware/jlib 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/all.js +10 -5
  2. package/dist/atoms/jl-app-icon.d.ts +5 -0
  3. package/dist/atoms/jl-app-icon.js +26 -4
  4. package/dist/atoms/jl-badge.js +1 -1
  5. package/dist/atoms/jl-button.d.ts +5 -0
  6. package/dist/atoms/jl-button.js +4 -1
  7. package/dist/atoms/jl-chip.js +3 -2
  8. package/dist/atoms/jl-input.js +4 -3
  9. package/dist/atoms/jl-link.js +1 -1
  10. package/dist/atoms/jl-rating.js +4 -5
  11. package/dist/atoms/jl-select.css_raw.js +1 -1
  12. package/dist/atoms/jl-select.d.ts +10 -8
  13. package/dist/atoms/jl-select.js +15 -9
  14. package/dist/atoms/jl-spinner.js +2 -2
  15. package/dist/base/jl-form-control.js +2 -1
  16. package/dist/index.d.ts +8 -0
  17. package/dist/index.js +9 -4
  18. package/dist/lib/app-icon.d.ts +8 -0
  19. package/dist/lib/app-icon.js +37 -0
  20. package/dist/lib/attributes.d.ts +9 -0
  21. package/dist/lib/attributes.js +10 -1
  22. package/dist/lib/dom.d.ts +2 -0
  23. package/dist/lib/dom.js +3 -1
  24. package/dist/lib/download.d.ts +10 -0
  25. package/dist/lib/download.js +62 -0
  26. package/dist/lib/icons.d.ts +4 -0
  27. package/dist/lib/icons.js +7 -4
  28. package/dist/lib/input-list.d.ts +12 -0
  29. package/dist/lib/input-list.js +14 -0
  30. package/dist/lib/internals.d.ts +5 -0
  31. package/dist/lib/internals.js +18 -0
  32. package/dist/lib/nav-tree.d.ts +2 -2
  33. package/dist/lib/palette.d.ts +2 -2
  34. package/dist/lib/palette.js +6 -0
  35. package/dist/lib/resize.d.ts +2 -0
  36. package/dist/lib/resize.js +10 -0
  37. package/dist/lib/table.d.ts +22 -4
  38. package/dist/lib/table.js +55 -5
  39. package/dist/lib/text.d.ts +2 -0
  40. package/dist/lib/text.js +4 -1
  41. package/dist/lib/texts.d.ts +99 -0
  42. package/dist/lib/texts.js +104 -0
  43. package/dist/lib/tree.d.ts +10 -1
  44. package/dist/lib/tree.js +37 -3
  45. package/dist/molecules/jl-account-button.js +1 -1
  46. package/dist/molecules/jl-alert.js +2 -1
  47. package/dist/molecules/jl-breadcrumb.js +3 -3
  48. package/dist/molecules/jl-calendar.js +4 -4
  49. package/dist/molecules/jl-chip-group.d.ts +7 -6
  50. package/dist/molecules/jl-chip-group.js +8 -6
  51. package/dist/molecules/jl-code-block.css_raw.js +1 -1
  52. package/dist/molecules/jl-code-block.d.ts +5 -0
  53. package/dist/molecules/jl-code-block.js +5 -2
  54. package/dist/molecules/jl-combobox.js +5 -6
  55. package/dist/molecules/jl-copy-button.js +5 -4
  56. package/dist/molecules/jl-date-picker.js +6 -7
  57. package/dist/molecules/jl-empty.js +1 -1
  58. package/dist/molecules/jl-facts.css_raw.js +3 -0
  59. package/dist/molecules/jl-facts.d.ts +35 -0
  60. package/dist/molecules/jl-facts.js +64 -0
  61. package/dist/molecules/jl-file-drop.d.ts +5 -0
  62. package/dist/molecules/jl-file-drop.js +17 -14
  63. package/dist/molecules/jl-input-list.css_raw.js +3 -0
  64. package/dist/molecules/jl-input-list.d.ts +79 -0
  65. package/dist/molecules/jl-input-list.js +177 -0
  66. package/dist/molecules/jl-load-more.css_raw.js +3 -0
  67. package/dist/molecules/jl-load-more.d.ts +41 -0
  68. package/dist/molecules/jl-load-more.js +62 -0
  69. package/dist/molecules/jl-load-state.js +6 -7
  70. package/dist/molecules/jl-menu.d.ts +8 -4
  71. package/dist/molecules/jl-menu.js +8 -1
  72. package/dist/molecules/jl-number-input.js +4 -4
  73. package/dist/molecules/jl-pagination.js +5 -5
  74. package/dist/molecules/jl-radio-group.d.ts +8 -7
  75. package/dist/molecules/jl-radio-group.js +12 -8
  76. package/dist/molecules/jl-search-button.js +4 -4
  77. package/dist/molecules/jl-search.js +4 -4
  78. package/dist/molecules/jl-segmented.d.ts +8 -7
  79. package/dist/molecules/jl-segmented.js +12 -6
  80. package/dist/molecules/jl-steps.css_raw.js +1 -1
  81. package/dist/molecules/jl-steps.d.ts +2 -0
  82. package/dist/molecules/jl-steps.js +30 -14
  83. package/dist/molecules/jl-tabs.js +2 -1
  84. package/dist/molecules/jl-tag-input.js +2 -2
  85. package/dist/molecules/jl-toast.css_raw.js +1 -1
  86. package/dist/molecules/jl-toast.d.ts +13 -1
  87. package/dist/molecules/jl-toast.js +23 -3
  88. package/dist/organisms/jl-command-palette.css_raw.js +1 -1
  89. package/dist/organisms/jl-command-palette.d.ts +20 -4
  90. package/dist/organisms/jl-command-palette.js +41 -9
  91. package/dist/organisms/jl-confirm.js +5 -7
  92. package/dist/organisms/jl-dialog.js +2 -1
  93. package/dist/organisms/jl-drawer.js +2 -1
  94. package/dist/organisms/jl-flow.js +12 -12
  95. package/dist/organisms/jl-navbar.js +6 -6
  96. package/dist/organisms/jl-side-nav.css_raw.js +1 -1
  97. package/dist/organisms/jl-side-nav.d.ts +40 -7
  98. package/dist/organisms/jl-side-nav.js +78 -16
  99. package/dist/organisms/jl-tab-bar.d.ts +8 -7
  100. package/dist/organisms/jl-tab-bar.js +12 -6
  101. package/dist/organisms/jl-table.css_raw.js +1 -1
  102. package/dist/organisms/jl-table.d.ts +62 -15
  103. package/dist/organisms/jl-table.js +246 -35
  104. package/dist/organisms/jl-toaster.d.ts +9 -1
  105. package/dist/organisms/jl-toaster.js +148 -7
  106. package/dist/organisms/jl-tree.css_raw.js +1 -1
  107. package/dist/organisms/jl-tree.d.ts +71 -4
  108. package/dist/organisms/jl-tree.js +303 -40
  109. package/dist/templates/jl-app-shell.css_raw.js +1 -1
  110. package/dist/templates/jl-app-shell.d.ts +10 -0
  111. package/dist/templates/jl-app-shell.js +16 -2
  112. package/dist/templates/jl-auth-layout.js +1 -1
  113. package/dist/templates/jl-page.js +3 -3
  114. package/dist/templates/jl-split-view.js +5 -4
  115. package/dist/types/jl-app-icon.types.d.ts +5 -0
  116. package/dist/types/jl-chip-group.types.d.ts +3 -3
  117. package/dist/types/jl-command-palette.types.d.ts +17 -6
  118. package/dist/types/jl-facts.types.d.ts +17 -0
  119. package/dist/types/jl-menu.types.d.ts +4 -4
  120. package/dist/types/jl-radio-group.types.d.ts +6 -3
  121. package/dist/types/jl-segmented.types.d.ts +6 -3
  122. package/dist/types/jl-select.types.d.ts +6 -3
  123. package/dist/types/jl-side-nav.types.d.ts +11 -6
  124. package/dist/types/jl-steps.types.d.ts +2 -0
  125. package/dist/types/jl-tab-bar.types.d.ts +6 -3
  126. package/dist/types/jl-table.types.d.ts +42 -9
  127. package/dist/types/jl-toaster.types.d.ts +42 -1
  128. package/dist/types/jl-tree.types.d.ts +26 -0
  129. package/dist/types/texts.types.d.ts +5 -0
  130. package/package.json +3 -3
package/dist/lib/tree.js CHANGED
@@ -1,6 +1,40 @@
1
1
  // src/lib/tree.ts
2
- /** An item with `children`, even empty, is a folder. */
3
- var isFolder = (item) => Array.isArray(item.children);
2
+ /** An item with `children`, even empty, is a folder; so is a `lazy` one, whose children are not loaded yet. */
3
+ var isFolder = (item) => Array.isArray(item.children) || item.lazy === true;
4
+ /** The items of a level: the roots when `parent` is null, otherwise that folder's children (none when unknown). */
5
+ function childrenOf(items, parent) {
6
+ if (parent === null) return items;
7
+ return allItems(items).find((entry) => entry.item.id === parent)?.item.children ?? [];
8
+ }
9
+ /** The tree with a page of items added at the end of a level: the roots when `parent` is null. */
10
+ function withPage(items, parent, page) {
11
+ if (parent === null) return [...items, ...page];
12
+ return items.map((item) => {
13
+ if (item.id === parent) return {
14
+ ...item,
15
+ children: [...item.children ?? [], ...page]
16
+ };
17
+ return item.children === void 0 ? item : {
18
+ ...item,
19
+ children: withPage(item.children, parent, page)
20
+ };
21
+ });
22
+ }
23
+ /**
24
+ * The tree with one more row at the end of the levels that have one (`extraRow` gives its id, or null): the row
25
+ * that loads a level's next page, or loads it again after an error. The keyboard then reaches it as an item.
26
+ */
27
+ function withExtraRows(items, extraRow, parent = null) {
28
+ const own = items.map((item) => isFolder(item) ? {
29
+ ...item,
30
+ children: withExtraRows(item.children ?? [], extraRow, item.id)
31
+ } : item);
32
+ const extra = extraRow(parent);
33
+ return extra === null ? own : [...own, {
34
+ id: extra,
35
+ label: ""
36
+ }];
37
+ }
4
38
  /** The items a person sees, in order: the roots, and the children of every open folder, with their depth. */
5
39
  function visibleItems(items, expanded, level = 1, parent = null) {
6
40
  return items.flatMap((item) => {
@@ -86,4 +120,4 @@ function treeKeyAction(items, expanded, focused, key) {
86
120
  const index = visible.findIndex((entry) => entry.item.id === focused);
87
121
  return handler(visible, Math.max(0, index), expanded);
88
122
  }
89
- export { allItems, isFolder, treeKeyAction, visibleItems, withExpanded };
123
+ export { allItems, childrenOf, isFolder, treeKeyAction, visibleItems, withExpanded, withExtraRows, withPage };
@@ -35,7 +35,7 @@ var JlAccountButton = class extends JlElement {
35
35
  /** Their account page is the one shown: marked as the side nav marks its current place. */
36
36
  current = this.useChange(false, (value) => this.renderCurrent(value), { attribute: "current" });
37
37
  _refs = this.useRefs((ref) => ({
38
- avatar: ref("jl-avatar"),
38
+ avatar: ref(JlAvatar),
39
39
  button: ref("button"),
40
40
  content: ref(".content"),
41
41
  description: ref(".description"),
@@ -3,6 +3,7 @@ import { JlElement } from "../base/jl-element.js";
3
3
  import { oneOf } from "../lib/attributes.js";
4
4
  import { registerIcons } from "../lib/icons.js";
5
5
  import { TONES, TONE_ICONS, TONE_ICON_FILLED } from "../lib/options.js";
6
+ import { jlText } from "../lib/texts.js";
6
7
  import { JlIcon } from "../atoms/jl-icon.js";
7
8
  import { hasSlotted } from "../lib/slots.js";
8
9
  import { JlButton } from "../atoms/jl-button.js";
@@ -115,7 +116,7 @@ var JlAlert = class extends JlElement {
115
116
  class: "close",
116
117
  variant: "ghost",
117
118
  icon: "x",
118
- hint: "Dismiss",
119
+ hint: jlText("dismiss"),
119
120
  size: "sm",
120
121
  hidden: true
121
122
  })
@@ -2,6 +2,7 @@ import { BASE_STYLES } from "../styles/shared.js";
2
2
  import { JlElement } from "../base/jl-element.js";
3
3
  import { jsonOf } from "../lib/attributes.js";
4
4
  import { registerIcons } from "../lib/icons.js";
5
+ import { jlText } from "../lib/texts.js";
5
6
  import { JlIcon } from "../atoms/jl-icon.js";
6
7
  import jl_breadcrumb_default from "./jl-breadcrumb.css_raw.js";
7
8
  import { css } from "@jadis/core";
@@ -14,7 +15,6 @@ registerIcons({
14
15
  });
15
16
  var ICON_SIZE = 15;
16
17
  var SEPARATOR_SIZE = 14;
17
- var DEFAULT_LABEL = "Breadcrumb";
18
18
  var MIN_MAX = 2;
19
19
  /** The crumbs shown: all of them, or the first, a gap for the middle, and the last `max - 1`. */
20
20
  function visibleCrumbs(items, max, expanded) {
@@ -43,8 +43,8 @@ var JlBreadcrumb = class extends JlElement {
43
43
  /** The most items shown before the middle folds; 0 never folds. */
44
44
  max = this.useChange(0, () => this.render(), { attribute: "max" });
45
45
  /** The trail's name for screen readers. */
46
- label = this.useChange(DEFAULT_LABEL, (value) => {
47
- this._refs.nav.setAttribute("aria-label", value || DEFAULT_LABEL);
46
+ label = this.useChange(jlText("breadcrumb"), (value) => {
47
+ this._refs.nav.setAttribute("aria-label", value || jlText("breadcrumb"));
48
48
  }, { attribute: "label" });
49
49
  _state = { expanded: false };
50
50
  _refs = this.useRefs((ref) => ({
@@ -3,6 +3,7 @@ import { JlFormControl } from "../base/jl-form-control.js";
3
3
  import { clampedNumber, oneOf } from "../lib/attributes.js";
4
4
  import { registerIcons } from "../lib/icons.js";
5
5
  import { CONTROL_SIZES } from "../lib/options.js";
6
+ import { jlText } from "../lib/texts.js";
6
7
  import { JlIcon } from "../atoms/jl-icon.js";
7
8
  import { setOrRemove, uniqueId } from "../lib/dom.js";
8
9
  import { addMonths, calendarDateOf, clampDate, dateAfterKey, dateFormatter, formatMonthTitle, isSameDate, isSameMonth, isWithin, monthGrid, monthHasDaysWithin, parseIsoDate, toIsoDate, weekdayNames } from "../lib/calendar.js";
@@ -21,7 +22,6 @@ var MONDAY = 1;
21
22
  var SUNDAY = 0;
22
23
  var SATURDAY = 6;
23
24
  var SELECT_KEYS = ["Enter", " "];
24
- var VALUE_MISSING = "Choose a date.";
25
25
  var FULL_DATE = { dateStyle: "full" };
26
26
  /** The first day of the week from its attribute: 0 (Sunday) to 6 (Saturday), Monday when absent. */
27
27
  var parseWeekday = (value) => Math.round(clampedNumber(MONDAY, SUNDAY, SATURDAY)(value));
@@ -95,7 +95,7 @@ var JlCalendar = class extends JlFormControl {
95
95
  /* @__PURE__ */ jsx("button", {
96
96
  class: "nav previous",
97
97
  type: "button",
98
- "aria-label": "Previous month",
98
+ "aria-label": jlText("previousMonth"),
99
99
  children: /* @__PURE__ */ jsx(JlIcon, {
100
100
  name: "chevron-left",
101
101
  size: NAV_ICON_SIZE
@@ -109,7 +109,7 @@ var JlCalendar = class extends JlFormControl {
109
109
  /* @__PURE__ */ jsx("button", {
110
110
  class: "nav next",
111
111
  type: "button",
112
- "aria-label": "Next month",
112
+ "aria-label": jlText("nextMonth"),
113
113
  children: /* @__PURE__ */ jsx(JlIcon, {
114
114
  name: "chevron-right",
115
115
  size: NAV_ICON_SIZE
@@ -299,7 +299,7 @@ var JlCalendar = class extends JlFormControl {
299
299
  }
300
300
  renderValidity() {
301
301
  if (this.required.get() && parseIsoDate(this.value.get()) === null) {
302
- this.internals.setValidity({ valueMissing: true }, VALUE_MISSING);
302
+ this.internals.setValidity({ valueMissing: true }, jlText("chooseDateMissing"));
303
303
  return;
304
304
  }
305
305
  this.internals.setValidity({});
@@ -5,20 +5,21 @@ import type { ControlSize } from '../types/options.types';
5
5
  * A row of chips to choose from: a status to filter by, a category, a reason. One choice by default, as radios
6
6
  * (choosing the chosen chip again keeps it); `multiple` lets people turn each chip on and off. On a narrow screen
7
7
  * the row scrolls sideways; `wrap` lets it go to the next line instead. `change` fires with the chosen values.
8
+ * Typed by its values, `JlChipGroup<'open' | 'done'>` takes options of those values and gives them back.
8
9
  */
9
- export declare class JlChipGroup extends JlFormControl {
10
+ export declare class JlChipGroup<Value extends string = string> extends JlFormControl {
10
11
  static readonly selector = "jl-chip-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(): ChipGroupOption[];
16
- set(setter: ChipGroupOption[] | ((prevState: ChipGroupOption[]) => ChipGroupOption[])): void;
16
+ get(): ChipGroupOption<Value>[];
17
+ set(setter: ChipGroupOption<Value>[] | ((prevState: ChipGroupOption<Value>[]) => ChipGroupOption<Value>[])): void;
17
18
  }>>;
18
19
  /** The chosen values, in the options' order; with one choice, a list of at most one. */
19
20
  readonly value: Readonly<Readonly<{
20
- get(): string[];
21
- set(setter: string[] | ((prevState: string[]) => string[])): void;
21
+ get(): Value[];
22
+ set(setter: Value[] | ((prevState: Value[]) => Value[])): void;
22
23
  }>>;
23
24
  /** Several chips can be chosen, each turned on and off on its own. */
24
25
  readonly multiple: Readonly<Readonly<{
@@ -1,8 +1,9 @@
1
1
  import { BASE_STYLES } from "../styles/shared.js";
2
2
  import { JlFormControl } from "../base/jl-form-control.js";
3
- import { jsonOf, oneOf, stringList } from "../lib/attributes.js";
3
+ import { jsonOf, oneOf, textListOf } from "../lib/attributes.js";
4
4
  import { registerIcons } from "../lib/icons.js";
5
5
  import { CONTROL_SIZES } from "../lib/options.js";
6
+ import { jlText } from "../lib/texts.js";
6
7
  import { JlIcon } from "../atoms/jl-icon.js";
7
8
  import { setOrRemove } from "../lib/dom.js";
8
9
  import { rovingIndex } from "../lib/roving-index.js";
@@ -19,7 +20,6 @@ var ICON_SIZES = {
19
20
  };
20
21
  var SELECTED_ICON = "check";
21
22
  var CHIP_SELECTOR = ".chip";
22
- var VALUE_MISSING = "Please select one of these options.";
23
23
  /** The keys that move between the chips; with one choice, the choice moves too, as with native radios. */
24
24
  var MOVES = /* @__PURE__ */ new Map([
25
25
  ["ArrowDown", "next"],
@@ -38,6 +38,7 @@ var parseOptions = (value) => {
38
38
  * A row of chips to choose from: a status to filter by, a category, a reason. One choice by default, as radios
39
39
  * (choosing the chosen chip again keeps it); `multiple` lets people turn each chip on and off. On a narrow screen
40
40
  * the row scrolls sideways; `wrap` lets it go to the next line instead. `change` fires with the chosen values.
41
+ * Typed by its values, `JlChipGroup<'open' | 'done'>` takes options of those values and gives them back.
41
42
  */
42
43
  var JlChipGroup = class extends JlFormControl {
43
44
  static selector = "jl-chip-group";
@@ -49,7 +50,7 @@ var JlChipGroup = class extends JlFormControl {
49
50
  /** The chosen values, in the options' order; with one choice, a list of at most one. */
50
51
  value = this.useChange([], () => this.renderValue(), {
51
52
  attribute: "value",
52
- parse: stringList
53
+ parse: textListOf
53
54
  });
54
55
  /** Several chips can be chosen, each turned on and off on its own. */
55
56
  multiple = this.useChange(false, (value) => {
@@ -114,7 +115,7 @@ var JlChipGroup = class extends JlFormControl {
114
115
  this._nameWatch.disconnect();
115
116
  }
116
117
  resetValue() {
117
- this.value.set(stringList(this.getAttribute("value")));
118
+ this.value.set(textListOf(this.getAttribute("value")));
118
119
  }
119
120
  /** The browser calls it for a disabled fieldset and for the element's own `disabled`, even before it renders. */
120
121
  setDisabledByForm(disabled) {
@@ -134,7 +135,8 @@ var JlChipGroup = class extends JlFormControl {
134
135
  }
135
136
  /** One choice: the chip becomes it. Several: the chip turns on or off, the values keeping the options' order. */
136
137
  press(chip) {
137
- const value = chip.dataset.value ?? "";
138
+ const value = this.options.get().find((option) => option.value === chip.dataset.value)?.value;
139
+ if (value === void 0) return;
138
140
  this._state.stop = value;
139
141
  const chosen = this.chosen();
140
142
  if (!this.multiple.get()) {
@@ -252,7 +254,7 @@ var JlChipGroup = class extends JlFormControl {
252
254
  this.internals.setValidity({});
253
255
  return;
254
256
  }
255
- this.internals.setValidity({ valueMissing: true }, VALUE_MISSING, this.chips()[0] ?? this._refs.group);
257
+ this.internals.setValidity({ valueMissing: true }, jlText("selectOption"), this.chips()[0] ?? this._refs.group);
256
258
  }
257
259
  };
258
260
  JlChipGroup.register();
@@ -1,3 +1,3 @@
1
1
  // src/molecules/jl-code-block.css?raw
2
- var jl_code_block_default = ":host {\n display: block;\n min-width: 0;\n}\n\nfigure {\n position: relative;\n border: 1px solid var(--jl-line);\n border-radius: var(--jl-radius);\n background: var(--jl-surface-2);\n overflow: hidden;\n}\n\nheader {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n height: 38px;\n padding: 0 52px 0 14px;\n border-bottom: 1px solid var(--jl-line);\n color: var(--jl-muted);\n font-size: var(--jl-font-xs);\n}\n\n.heading {\n overflow: hidden;\n color: var(--jl-text-2);\n font-family: var(--jl-font-mono);\n font-weight: 500;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.language {\n font-weight: 600;\n letter-spacing: 0.06em;\n text-transform: uppercase;\n}\n\n.body {\n display: flex;\n min-width: 0;\n}\n\n.gutter,\npre {\n padding: 14px 16px;\n font-family: var(--jl-font-mono);\n font-size: 12.5px;\n line-height: 1.7;\n font-variant-ligatures: no-contextual;\n}\n\n.gutter {\n flex: none;\n padding-right: 4px;\n color: var(--jl-faint);\n text-align: right;\n white-space: pre;\n user-select: none;\n}\n\npre {\n flex: 1;\n min-width: 0;\n margin: 0;\n padding-right: 48px;\n overflow-x: auto;\n color: var(--jl-text);\n tab-size: 2;\n}\n\n:host([wrap]) pre {\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n\n.copy {\n position: absolute;\n top: 6px;\n right: 6px;\n background: var(--jl-surface-2);\n border-radius: var(--jl-radius-sm);\n}\n\n:host(:not([has-header])) .copy {\n opacity: 0.6;\n transition: opacity var(--jl-fast) var(--jl-ease);\n}\n\n:host(:not([has-header])) figure:hover .copy,\n.copy:focus-within {\n opacity: 1;\n}\n\n.tok-comment {\n color: var(--jl-code-comment);\n font-style: italic;\n}\n\n.tok-string {\n color: var(--jl-code-string);\n}\n\n.tok-number {\n color: var(--jl-code-number);\n}\n\n.tok-keyword {\n color: var(--jl-code-keyword);\n}\n\n.tok-tag {\n color: var(--jl-code-tag);\n}\n\n.tok-attribute {\n color: var(--jl-code-attribute);\n}\n\n.tok-property {\n color: var(--jl-code-property);\n}\n\n.tok-function {\n color: var(--jl-code-function);\n}\n\n.tok-punctuation {\n color: var(--jl-muted);\n}\n";
2
+ var jl_code_block_default = ":host {\n display: block;\n min-width: 0;\n --max-height: none;\n}\n\nfigure {\n position: relative;\n border: 1px solid var(--jl-line);\n border-radius: var(--jl-radius);\n background: var(--jl-surface-2);\n overflow: hidden;\n}\n\nheader {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n height: 38px;\n padding: 0 52px 0 14px;\n border-bottom: 1px solid var(--jl-line);\n color: var(--jl-muted);\n font-size: var(--jl-font-xs);\n}\n\n.heading {\n overflow: hidden;\n color: var(--jl-text-2);\n font-family: var(--jl-font-mono);\n font-weight: 500;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.language {\n font-weight: 600;\n letter-spacing: 0.06em;\n text-transform: uppercase;\n}\n\n.body {\n display: flex;\n min-width: 0;\n max-height: var(--max-height);\n overflow-y: auto;\n}\n\n.gutter,\npre {\n padding: 14px 16px;\n font-family: var(--jl-font-mono);\n font-size: 12.5px;\n line-height: 1.7;\n font-variant-ligatures: no-contextual;\n}\n\n.gutter {\n flex: none;\n padding-right: 4px;\n color: var(--jl-faint);\n text-align: right;\n white-space: pre;\n user-select: none;\n}\n\npre {\n flex: 1;\n min-width: 0;\n margin: 0;\n padding-right: 48px;\n overflow-x: auto;\n color: var(--jl-text);\n tab-size: 2;\n}\n\n:host([wrap]) pre {\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n\n.copy {\n position: absolute;\n top: 6px;\n right: 6px;\n background: var(--jl-surface-2);\n border-radius: var(--jl-radius-sm);\n}\n\n:host(:not([has-header])) .copy {\n opacity: 0.6;\n transition: opacity var(--jl-fast) var(--jl-ease);\n}\n\n:host(:not([has-header])) figure:hover .copy,\n.copy:focus-within {\n opacity: 1;\n}\n\n.tok-comment {\n color: var(--jl-code-comment);\n font-style: italic;\n}\n\n.tok-string {\n color: var(--jl-code-string);\n}\n\n.tok-number {\n color: var(--jl-code-number);\n}\n\n.tok-keyword {\n color: var(--jl-code-keyword);\n}\n\n.tok-tag {\n color: var(--jl-code-tag);\n}\n\n.tok-attribute {\n color: var(--jl-code-attribute);\n}\n\n.tok-property {\n color: var(--jl-code-property);\n}\n\n.tok-function {\n color: var(--jl-code-function);\n}\n\n.tok-punctuation {\n color: var(--jl-muted);\n}\n";
3
3
  export { jl_code_block_default as default };
@@ -33,6 +33,11 @@ export declare class JlCodeBlock extends JlElement {
33
33
  get(): boolean;
34
34
  set(setter: boolean | ((prevState: boolean) => boolean)): void;
35
35
  }>>;
36
+ /** A CSS height past which the code scrolls under its header: `320px`, `50vh`; a number is pixels. */
37
+ readonly maxHeight: Readonly<Readonly<{
38
+ get(): string;
39
+ set(setter: string | ((prevState: string) => string)): void;
40
+ }>>;
36
41
  private readonly _refs;
37
42
  templateHtml(): Node;
38
43
  templateCss(): string;
@@ -1,8 +1,9 @@
1
1
  import { BASE_STYLES } from "../styles/shared.js";
2
2
  import { JlElement } from "../base/jl-element.js";
3
3
  import { oneOf } from "../lib/attributes.js";
4
- import { highlightedNodes } from "../lib/highlight.js";
5
4
  import { dedent } from "../lib/text.js";
5
+ import { cssLength } from "../lib/css-length.js";
6
+ import { highlightedNodes } from "../lib/highlight.js";
6
7
  import jl_code_block_default from "./jl-code-block.css_raw.js";
7
8
  import { JlCopyButton } from "./jl-copy-button.js";
8
9
  import { css } from "@jadis/core";
@@ -41,9 +42,11 @@ var JlCodeBlock = class extends JlElement {
41
42
  }, { attribute: "hide-copy" });
42
43
  /** Wraps long lines instead of scrolling sideways. */
43
44
  wrap = this.useChange(false, (value) => this.reflect("wrap", value), { attribute: "wrap" });
45
+ /** A CSS height past which the code scrolls under its header: `320px`, `50vh`; a number is pixels. */
46
+ maxHeight = this.useChange("", (value) => this.style.setProperty("--max-height", value.trim() === "" ? "none" : cssLength(value)), { attribute: "max-height" });
44
47
  _refs = this.useRefs((ref) => ({
45
48
  code: ref("code"),
46
- copy: ref("jl-copy-button"),
49
+ copy: ref(JlCopyButton),
47
50
  gutter: ref(".gutter"),
48
51
  header: ref("header"),
49
52
  heading: ref(".heading"),
@@ -4,6 +4,7 @@ import { jsonOf, oneOf } from "../lib/attributes.js";
4
4
  import { followAnchor } from "../lib/floating.js";
5
5
  import { registerIcons } from "../lib/icons.js";
6
6
  import { CONTROL_SIZES } from "../lib/options.js";
7
+ import { jlText } from "../lib/texts.js";
7
8
  import { JlIcon } from "../atoms/jl-icon.js";
8
9
  import { setOrRemove, uniqueId } from "../lib/dom.js";
9
10
  import { keepInView } from "../lib/keep-in-view.js";
@@ -23,8 +24,6 @@ var ACTION_ICON_SIZE = 14;
23
24
  var CHECK_SIZE = 14;
24
25
  var NONE = -1;
25
26
  var PLACEMENT = "bottom-start";
26
- var VALUE_MISSING = "Choose an option.";
27
- var DEFAULT_EMPTY_TEXT = "No results";
28
27
  /** A JSON attribute that should hold a list of options; anything else gives none. */
29
28
  var parseOptions = (value) => {
30
29
  const parsed = jsonOf([])(value);
@@ -57,7 +56,7 @@ var JlCombobox = class extends JlFormControl {
57
56
  /** Shows a button that empties the field while it holds text. */
58
57
  clearable = this.useChange(false, () => this.renderClear(), { attribute: "clearable" });
59
58
  /** What the list says when no option matches. */
60
- emptyText = this.useChange(DEFAULT_EMPTY_TEXT, (value) => {
59
+ emptyText = this.useChange(jlText("noResults"), (value) => {
61
60
  this._refs.empty.textContent = value;
62
61
  }, { attribute: "empty-text" });
63
62
  required = this.useChange(false, (value) => {
@@ -112,7 +111,7 @@ var JlCombobox = class extends JlFormControl {
112
111
  /* @__PURE__ */ jsx("button", {
113
112
  class: "action clear",
114
113
  type: "button",
115
- "aria-label": "Clear",
114
+ "aria-label": jlText("clear"),
116
115
  tabIndex: -1,
117
116
  hidden: true,
118
117
  children: /* @__PURE__ */ jsx(JlIcon, {
@@ -123,7 +122,7 @@ var JlCombobox = class extends JlFormControl {
123
122
  /* @__PURE__ */ jsx("button", {
124
123
  class: "action toggle",
125
124
  type: "button",
126
- "aria-label": "Show the options",
125
+ "aria-label": jlText("showOptions"),
127
126
  tabIndex: -1,
128
127
  children: /* @__PURE__ */ jsx(JlIcon, {
129
128
  name: "chevron-down",
@@ -429,7 +428,7 @@ var JlCombobox = class extends JlFormControl {
429
428
  }
430
429
  renderValidity() {
431
430
  if (this.required.get() && this.value.get() === "") {
432
- this.internals.setValidity({ valueMissing: true }, VALUE_MISSING, this._refs.native);
431
+ this.internals.setValidity({ valueMissing: true }, jlText("chooseOption"), this._refs.native);
433
432
  return;
434
433
  }
435
434
  this.internals.setValidity({});
@@ -3,6 +3,7 @@ import { JlElement } from "../base/jl-element.js";
3
3
  import { oneOf } from "../lib/attributes.js";
4
4
  import { registerIcons } from "../lib/icons.js";
5
5
  import { CONTROL_SIZES } from "../lib/options.js";
6
+ import { jlText } from "../lib/texts.js";
6
7
  import { JlButton } from "../atoms/jl-button.js";
7
8
  import jl_copy_button_default from "./jl-copy-button.css_raw.js";
8
9
  import { css } from "@jadis/core";
@@ -28,12 +29,12 @@ var JlCopyButton = class extends JlElement {
28
29
  parse: oneOf(CONTROL_SIZES, "sm")
29
30
  });
30
31
  _timer = { id: 0 };
31
- _refs = this.useRefs((ref) => ({ button: ref("jl-button") }));
32
+ _refs = this.useRefs((ref) => ({ button: ref(JlButton) }));
32
33
  templateHtml() {
33
34
  return /* @__PURE__ */ jsx(JlButton, {
34
35
  variant: "ghost",
35
36
  icon: COPY_ICON,
36
- hint: "Copy"
37
+ hint: jlText("copy")
37
38
  });
38
39
  }
39
40
  templateCss() {
@@ -55,12 +56,12 @@ var JlCopyButton = class extends JlElement {
55
56
  confirm() {
56
57
  const button = this._refs.button;
57
58
  button.icon.set(DONE_ICON);
58
- button.hint.set("Copied");
59
+ button.hint.set(jlText("copied"));
59
60
  this.reflect("copied", true);
60
61
  window.clearTimeout(this._timer.id);
61
62
  this._timer.id = window.setTimeout(() => {
62
63
  button.icon.set(COPY_ICON);
63
- button.hint.set("Copy");
64
+ button.hint.set(jlText("copy"));
64
65
  this.reflect("copied", false);
65
66
  }, CONFIRM_MS);
66
67
  }
@@ -4,6 +4,7 @@ import { clampedNumber, oneOf } from "../lib/attributes.js";
4
4
  import { followAnchor } from "../lib/floating.js";
5
5
  import { registerIcons } from "../lib/icons.js";
6
6
  import { CONTROL_SIZES } from "../lib/options.js";
7
+ import { jlText } from "../lib/texts.js";
7
8
  import { JlIcon } from "../atoms/jl-icon.js";
8
9
  import { setOrRemove, uniqueId } from "../lib/dom.js";
9
10
  import { NUMERIC_DATE, compareDates, dateOrder, datePattern, formatDate, isDateText, parseIsoDate, parseTypedDate, toIsoDate } from "../lib/calendar.js";
@@ -24,8 +25,6 @@ var PLACEMENT = "bottom-start";
24
25
  var MONDAY = 1;
25
26
  var SUNDAY = 0;
26
27
  var SATURDAY = 6;
27
- var VALUE_MISSING = "Choose a date.";
28
- var DIALOG_LABEL = "Choose a date";
29
28
  var parseWeekday = (value) => Math.round(clampedNumber(MONDAY, SUNDAY, SATURDAY)(value));
30
29
  /**
31
30
  * A field for a date: it shows the date in digits, in the `locale`'s order (`25.10.2026`, `10/25/2026`), and opens a
@@ -81,7 +80,7 @@ var JlDatePicker = class extends JlFormControl {
81
80
  openOnPress: null
82
81
  };
83
82
  _refs = this.useRefs((ref) => ({
84
- calendar: ref("jl-calendar"),
83
+ calendar: ref(JlCalendar),
85
84
  clear: ref(".clear"),
86
85
  control: ref(".control"),
87
86
  native: ref("input"),
@@ -117,7 +116,7 @@ var JlDatePicker = class extends JlFormControl {
117
116
  /* @__PURE__ */ jsx("button", {
118
117
  class: "action clear",
119
118
  type: "button",
120
- "aria-label": "Clear",
119
+ "aria-label": jlText("clear"),
121
120
  tabIndex: -1,
122
121
  hidden: true,
123
122
  children: /* @__PURE__ */ jsx(JlIcon, {
@@ -128,7 +127,7 @@ var JlDatePicker = class extends JlFormControl {
128
127
  /* @__PURE__ */ jsx("button", {
129
128
  class: "action open",
130
129
  type: "button",
131
- "aria-label": DIALOG_LABEL,
130
+ "aria-label": jlText("chooseDate"),
132
131
  "aria-haspopup": "dialog",
133
132
  "aria-expanded": "false",
134
133
  "aria-controls": this._popupId,
@@ -143,7 +142,7 @@ var JlDatePicker = class extends JlFormControl {
143
142
  id: this._popupId,
144
143
  popover: "auto",
145
144
  role: "dialog",
146
- "aria-label": DIALOG_LABEL,
145
+ "aria-label": jlText("chooseDate"),
147
146
  attrs: { part: "popup" },
148
147
  children: /* @__PURE__ */ jsx(JlCalendar, { class: "calendar" })
149
148
  })] });
@@ -314,7 +313,7 @@ var JlDatePicker = class extends JlFormControl {
314
313
  }
315
314
  renderMissing(anchor) {
316
315
  if (this.required.get()) {
317
- this.internals.setValidity({ valueMissing: true }, VALUE_MISSING, anchor);
316
+ this.internals.setValidity({ valueMissing: true }, jlText("chooseDateMissing"), anchor);
318
317
  return;
319
318
  }
320
319
  this.internals.setValidity({});
@@ -43,7 +43,7 @@ var JlEmpty = class extends JlElement {
43
43
  actions: ref(".actions"),
44
44
  description: ref(".description"),
45
45
  heading: ref(".heading"),
46
- icon: ref("jl-icon"),
46
+ icon: ref(JlIcon),
47
47
  medallion: ref(".medallion"),
48
48
  slot: ref("slot")
49
49
  }));
@@ -0,0 +1,3 @@
1
+ // src/molecules/jl-facts.css?raw
2
+ var jl_facts_default = ":host {\n display: block;\n container-type: inline-size;\n}\n\n:host([empty]) {\n display: none;\n}\n\n.facts {\n display: grid;\n grid-template-columns: max-content minmax(0, 1fr);\n gap: 6px 24px;\n margin: 0;\n font-size: var(--jl-font-md);\n}\n\n/* Each pair is a row of the grid: the labels line up in one column, the values in the other. */\n.fact {\n display: contents;\n}\n\ndt {\n color: var(--jl-muted);\n}\n\ndd {\n min-width: 0;\n margin: 0;\n color: var(--jl-text);\n overflow-wrap: anywhere;\n}\n\ncode {\n font-family: var(--jl-font-mono);\n font-size: var(--jl-font-sm);\n word-break: break-all;\n}\n\na {\n color: var(--jl-accent);\n text-decoration: none;\n}\n\na:hover {\n color: var(--jl-accent-strong);\n text-decoration: underline;\n}\n\n:host([orientation=\"vertical\"]) .facts {\n grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr));\n gap: 16px 24px;\n}\n\n:host([orientation=\"vertical\"]) .fact {\n display: grid;\n gap: 2px;\n align-content: start;\n}\n\n@container (width < 420px) {\n .facts {\n grid-template-columns: minmax(0, 1fr);\n gap: 12px;\n }\n\n .fact {\n display: grid;\n gap: 2px;\n }\n}\n";
3
+ export { jl_facts_default as default };
@@ -0,0 +1,35 @@
1
+ import { JlElement } from '../base/jl-element';
2
+ import type { Fact, FactRenderer, FactsOrientation } from '../types/jl-facts.types';
3
+ export declare const FACTS_ORIENTATIONS: readonly FactsOrientation[];
4
+ /**
5
+ * The facts about one thing, label and value: an object's size and digest, an order's customer and date. Facts
6
+ * without a value are left out, and an element with none takes no room. Values can be code (monospace, broken
7
+ * anywhere), links, or drawn by code (`renderers`, by a fact's `key`). Narrower than 420 pixels, labels go over
8
+ * their values.
9
+ */
10
+ export declare class JlFacts extends JlElement {
11
+ static readonly selector = "jl-facts";
12
+ readonly items: Readonly<Readonly<{
13
+ get(): Fact[];
14
+ set(setter: Fact[] | ((prevState: Fact[]) => Fact[])): void;
15
+ }>>;
16
+ readonly orientation: Readonly<Readonly<{
17
+ get(): FactsOrientation;
18
+ set(setter: ((prevState: FactsOrientation) => FactsOrientation) | FactsOrientation): void;
19
+ }>>;
20
+ /** Draws the values of some facts by code, by their `key`: `{ type: (fact) => <JlBadge label={…} /> }`. */
21
+ readonly renderers: Readonly<Readonly<{
22
+ get(): Record<string, FactRenderer>;
23
+ set(setter: Record<string, FactRenderer> | ((prevState: Record<string, FactRenderer>) => Record<string, FactRenderer>)): void;
24
+ }>>;
25
+ /** The list's name for screen readers. */
26
+ readonly label: Readonly<Readonly<{
27
+ get(): string;
28
+ set(setter: string | ((prevState: string) => string)): void;
29
+ }>>;
30
+ private readonly _refs;
31
+ templateHtml(): Node;
32
+ templateCss(): string;
33
+ private render;
34
+ private valueNode;
35
+ }
@@ -0,0 +1,64 @@
1
+ import { BASE_STYLES } from "../styles/shared.js";
2
+ import { JlElement } from "../base/jl-element.js";
3
+ import { jsonOf, oneOf } from "../lib/attributes.js";
4
+ import { setOrRemove } from "../lib/dom.js";
5
+ import jl_facts_default from "./jl-facts.css_raw.js";
6
+ import { css } from "@jadis/core";
7
+ import { jsx, jsxs } from "@jadis/core/jsx-runtime";
8
+ // src/molecules/jl-facts.tsx
9
+ var FACTS_ORIENTATIONS = ["horizontal", "vertical"];
10
+ var hasValue = (fact) => fact.value !== null && fact.value !== void 0 && fact.value !== "";
11
+ /**
12
+ * The facts about one thing, label and value: an object's size and digest, an order's customer and date. Facts
13
+ * without a value are left out, and an element with none takes no room. Values can be code (monospace, broken
14
+ * anywhere), links, or drawn by code (`renderers`, by a fact's `key`). Narrower than 420 pixels, labels go over
15
+ * their values.
16
+ */
17
+ var JlFacts = class extends JlElement {
18
+ static selector = "jl-facts";
19
+ items = this.useChange([], () => this.render(), {
20
+ attribute: "items",
21
+ parse: jsonOf([])
22
+ });
23
+ orientation = this.useChange("horizontal", (value) => this.reflect("orientation", value), {
24
+ attribute: "orientation",
25
+ parse: oneOf(FACTS_ORIENTATIONS, "horizontal")
26
+ });
27
+ /** Draws the values of some facts by code, by their `key`: `{ type: (fact) => <JlBadge label={…} /> }`. */
28
+ renderers = this.useChange({}, () => this.render());
29
+ /** The list's name for screen readers. */
30
+ label = this.useChange("", (value) => setOrRemove(this._refs.list, "aria-label", value), { attribute: "label" });
31
+ _refs = this.useRefs((ref) => ({ list: ref("dl") }));
32
+ templateHtml() {
33
+ return /* @__PURE__ */ jsx("dl", {
34
+ class: "facts",
35
+ attrs: { part: "base" }
36
+ });
37
+ }
38
+ templateCss() {
39
+ return css`${BASE_STYLES}${jl_facts_default}`;
40
+ }
41
+ render() {
42
+ const shown = this.items.get().filter(hasValue);
43
+ this._refs.list.replaceChildren(...shown.map((fact) => /* @__PURE__ */ jsxs("div", {
44
+ class: "fact",
45
+ children: [/* @__PURE__ */ jsx("dt", { children: fact.label }), /* @__PURE__ */ jsx("dd", {
46
+ title: fact.hint,
47
+ children: this.valueNode(fact)
48
+ })]
49
+ })));
50
+ this.reflect("empty", shown.length === 0);
51
+ }
52
+ valueNode(fact) {
53
+ const renderer = fact.key === void 0 ? void 0 : this.renderers.get()[fact.key];
54
+ if (renderer !== void 0) return renderer(fact);
55
+ const text = String(fact.value);
56
+ const content = fact.code ? /* @__PURE__ */ jsx("code", { children: text }) : document.createTextNode(text);
57
+ return fact.href === void 0 ? content : /* @__PURE__ */ jsx("a", {
58
+ href: fact.href,
59
+ children: content
60
+ });
61
+ }
62
+ };
63
+ JlFacts.register();
64
+ export { FACTS_ORIENTATIONS, JlFacts };
@@ -61,6 +61,11 @@ export declare class JlFileDrop extends JlFormControl {
61
61
  focus(options?: FocusOptions): void;
62
62
  /** Opens the file chooser. */
63
63
  browse(): void;
64
+ /**
65
+ * Takes files as a drop would, such as files dropped elsewhere on the page: the ones it accepts join the list (or
66
+ * replace the file there) and fire `change`, the others say why not.
67
+ */
68
+ add(files: readonly File[]): void;
64
69
  /** Takes every file back, and empties the list of refused ones. */
65
70
  clear(): void;
66
71
  templateHtml(): Node;