@syware/jlib 0.12.1 → 0.13.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 (141) hide show
  1. package/dist/atoms/jl-avatar.css.js +1 -1
  2. package/dist/atoms/jl-avatar.js +1 -8
  3. package/dist/atoms/jl-button.css.js +1 -1
  4. package/dist/atoms/jl-button.js +4 -6
  5. package/dist/atoms/jl-checkbox.css.js +1 -1
  6. package/dist/atoms/jl-checkbox.js +8 -10
  7. package/dist/atoms/jl-chip.css.js +1 -1
  8. package/dist/atoms/jl-chip.js +3 -11
  9. package/dist/atoms/jl-divider.css.js +1 -1
  10. package/dist/atoms/jl-divider.js +1 -5
  11. package/dist/atoms/jl-icon.css.js +1 -1
  12. package/dist/atoms/jl-icon.d.ts +2 -0
  13. package/dist/atoms/jl-icon.js +5 -1
  14. package/dist/atoms/jl-input.d.ts +7 -2
  15. package/dist/atoms/jl-input.js +36 -31
  16. package/dist/atoms/jl-link.css.js +1 -1
  17. package/dist/atoms/jl-link.js +3 -6
  18. package/dist/atoms/jl-rating.css.js +1 -1
  19. package/dist/atoms/jl-rating.d.ts +2 -2
  20. package/dist/atoms/jl-rating.js +17 -35
  21. package/dist/atoms/jl-select.d.ts +8 -3
  22. package/dist/atoms/jl-select.js +26 -13
  23. package/dist/atoms/jl-skeleton.d.ts +1 -0
  24. package/dist/atoms/jl-skeleton.js +4 -1
  25. package/dist/atoms/jl-slider.d.ts +4 -0
  26. package/dist/atoms/jl-slider.js +29 -15
  27. package/dist/atoms/jl-switch.css.js +1 -1
  28. package/dist/atoms/jl-switch.js +2 -8
  29. package/dist/atoms/jl-textarea.css.js +1 -1
  30. package/dist/atoms/jl-textarea.d.ts +4 -5
  31. package/dist/atoms/jl-textarea.js +15 -30
  32. package/dist/lib/calendar.js +3 -2
  33. package/dist/lib/floating.d.ts +10 -0
  34. package/dist/lib/floating.js +27 -8
  35. package/dist/lib/flow.d.ts +7 -3
  36. package/dist/lib/flow.js +19 -8
  37. package/dist/lib/indicator.d.ts +16 -0
  38. package/dist/lib/indicator.js +32 -6
  39. package/dist/lib/intl.d.ts +6 -0
  40. package/dist/lib/intl.js +19 -0
  41. package/dist/lib/palette.js +1 -6
  42. package/dist/lib/table.d.ts +14 -2
  43. package/dist/lib/table.js +50 -39
  44. package/dist/molecules/jl-accordion-item.css.js +1 -1
  45. package/dist/molecules/jl-accordion-item.js +1 -5
  46. package/dist/molecules/jl-account-button.css.js +1 -1
  47. package/dist/molecules/jl-account-button.js +1 -5
  48. package/dist/molecules/jl-alert.css.js +1 -1
  49. package/dist/molecules/jl-alert.d.ts +5 -5
  50. package/dist/molecules/jl-alert.js +4 -13
  51. package/dist/molecules/jl-avatar-group.d.ts +7 -5
  52. package/dist/molecules/jl-avatar-group.js +15 -5
  53. package/dist/molecules/jl-breadcrumb.d.ts +7 -4
  54. package/dist/molecules/jl-breadcrumb.js +32 -8
  55. package/dist/molecules/jl-calendar.d.ts +12 -3
  56. package/dist/molecules/jl-calendar.js +79 -48
  57. package/dist/molecules/jl-card.css.js +1 -1
  58. package/dist/molecules/jl-card.js +2 -8
  59. package/dist/molecules/jl-chip-group.css.js +1 -1
  60. package/dist/molecules/jl-chip-group.d.ts +6 -2
  61. package/dist/molecules/jl-chip-group.js +13 -18
  62. package/dist/molecules/jl-code-block.css.js +1 -1
  63. package/dist/molecules/jl-code-block.d.ts +7 -5
  64. package/dist/molecules/jl-code-block.js +19 -22
  65. package/dist/molecules/jl-combobox.css.js +1 -1
  66. package/dist/molecules/jl-combobox.d.ts +4 -0
  67. package/dist/molecules/jl-combobox.js +33 -19
  68. package/dist/molecules/jl-date-picker.d.ts +6 -0
  69. package/dist/molecules/jl-date-picker.js +29 -9
  70. package/dist/molecules/jl-empty.css.js +1 -1
  71. package/dist/molecules/jl-empty.js +4 -19
  72. package/dist/molecules/jl-field.css.js +1 -1
  73. package/dist/molecules/jl-field.d.ts +7 -1
  74. package/dist/molecules/jl-field.js +35 -23
  75. package/dist/molecules/jl-file-drop.css.js +1 -1
  76. package/dist/molecules/jl-file-drop.js +1 -3
  77. package/dist/molecules/jl-input-list.css.js +1 -1
  78. package/dist/molecules/jl-input-list.d.ts +12 -1
  79. package/dist/molecules/jl-input-list.js +81 -51
  80. package/dist/molecules/jl-list-item.css.js +1 -1
  81. package/dist/molecules/jl-list-item.d.ts +3 -1
  82. package/dist/molecules/jl-list-item.js +26 -27
  83. package/dist/molecules/jl-load-state.css.js +1 -1
  84. package/dist/molecules/jl-load-state.d.ts +6 -1
  85. package/dist/molecules/jl-load-state.js +15 -18
  86. package/dist/molecules/jl-menu.d.ts +1 -0
  87. package/dist/molecules/jl-menu.js +9 -2
  88. package/dist/molecules/jl-pagination.css.js +1 -1
  89. package/dist/molecules/jl-pagination.d.ts +7 -1
  90. package/dist/molecules/jl-pagination.js +43 -35
  91. package/dist/molecules/jl-search.css.js +1 -1
  92. package/dist/molecules/jl-search.js +4 -12
  93. package/dist/molecules/jl-segmented.css.js +1 -1
  94. package/dist/molecules/jl-segmented.d.ts +4 -2
  95. package/dist/molecules/jl-segmented.js +19 -26
  96. package/dist/molecules/jl-stat.css.js +1 -1
  97. package/dist/molecules/jl-stat.js +2 -8
  98. package/dist/molecules/jl-steps.d.ts +10 -3
  99. package/dist/molecules/jl-steps.js +82 -49
  100. package/dist/molecules/jl-tabs.d.ts +5 -2
  101. package/dist/molecules/jl-tabs.js +31 -25
  102. package/dist/molecules/jl-tag-input.css.js +1 -1
  103. package/dist/molecules/jl-tag-input.d.ts +13 -1
  104. package/dist/molecules/jl-tag-input.js +57 -30
  105. package/dist/molecules/jl-timeline.css.js +1 -1
  106. package/dist/molecules/jl-timeline.d.ts +3 -1
  107. package/dist/molecules/jl-timeline.js +9 -14
  108. package/dist/molecules/jl-toast.css.js +1 -1
  109. package/dist/molecules/jl-toast.js +2 -10
  110. package/dist/molecules/jl-tooltip.d.ts +2 -1
  111. package/dist/molecules/jl-tooltip.js +11 -15
  112. package/dist/organisms/jl-command-palette.css.js +1 -1
  113. package/dist/organisms/jl-command-palette.d.ts +8 -1
  114. package/dist/organisms/jl-command-palette.js +73 -42
  115. package/dist/organisms/jl-confirm.css.js +1 -1
  116. package/dist/organisms/jl-confirm.js +1 -5
  117. package/dist/organisms/jl-dialog.css.js +1 -1
  118. package/dist/organisms/jl-dialog.js +1 -5
  119. package/dist/organisms/jl-drawer.css.js +1 -1
  120. package/dist/organisms/jl-drawer.js +1 -3
  121. package/dist/organisms/jl-flow.d.ts +18 -2
  122. package/dist/organisms/jl-flow.js +128 -44
  123. package/dist/organisms/jl-navbar.css.js +1 -1
  124. package/dist/organisms/jl-navbar.d.ts +1 -1
  125. package/dist/organisms/jl-navbar.js +3 -5
  126. package/dist/organisms/jl-page-header.css.js +1 -1
  127. package/dist/organisms/jl-page-header.js +1 -5
  128. package/dist/organisms/jl-page-outlet.d.ts +4 -3
  129. package/dist/organisms/jl-page-outlet.js +7 -8
  130. package/dist/organisms/jl-side-nav.css.js +1 -1
  131. package/dist/organisms/jl-side-nav.d.ts +9 -2
  132. package/dist/organisms/jl-side-nav.js +44 -16
  133. package/dist/organisms/jl-tab-bar.css.js +1 -1
  134. package/dist/organisms/jl-tab-bar.js +0 -2
  135. package/dist/organisms/jl-table.css.js +1 -1
  136. package/dist/organisms/jl-table.d.ts +18 -6
  137. package/dist/organisms/jl-table.js +91 -57
  138. package/dist/organisms/jl-tree.css.js +1 -1
  139. package/dist/organisms/jl-tree.d.ts +16 -13
  140. package/dist/organisms/jl-tree.js +72 -70
  141. package/package.json +1 -1
@@ -11,14 +11,10 @@ import { Star } from "lucide";
11
11
  import { jsx } from "@jadis/core/jsx-runtime";
12
12
  // src/atoms/jl-rating.tsx
13
13
  registerIcons({ star: Star });
14
- var ICON_SIZES = {
15
- lg: 26,
16
- md: 20,
17
- sm: 16
18
- };
14
+ var ICON_SIZE = 20;
15
+ var DEFAULT_ICON = "star";
19
16
  var DEFAULT_MAX = 5;
20
17
  var MAX_LIMIT = 10;
21
- var NO_PREVIEW = 0;
22
18
  /**
23
19
  * A row of stars (or hearts, or any icon) to give a score: a click, the arrows or a digit set it, and choosing the
24
20
  * score already given clears it. Hovering previews the score a click would give.
@@ -40,11 +36,8 @@ var JlRating = class extends JlFormControl {
40
36
  this.reflect("readonly", value);
41
37
  this._refs.slider.toggleAttribute("aria-readonly", value);
42
38
  }, { attribute: "readonly" });
43
- icon = this.useChange("star", () => this.renderIcons(), { attribute: "icon" });
44
- size = this.useChange("md", (value) => {
45
- this.reflect("size", value);
46
- this.renderIcons();
47
- }, {
39
+ icon = this.useChange(DEFAULT_ICON, () => this.renderIcons(), { attribute: "icon" });
40
+ size = this.useChange("md", (value) => this.reflect("size", value), {
48
41
  attribute: "size",
49
42
  parse: oneOf(CONTROL_SIZES, "md")
50
43
  });
@@ -61,8 +54,8 @@ var JlRating = class extends JlFormControl {
61
54
  this._refs.slider.toggleAttribute("aria-invalid", value);
62
55
  }, { attribute: "invalid" });
63
56
  _state = {
64
- formDisabled: false,
65
- preview: NO_PREVIEW
57
+ drawnIcon: "",
58
+ formDisabled: false
66
59
  };
67
60
  _refs = this.useRefs((ref) => ({
68
61
  icons: ref(".icons"),
@@ -89,8 +82,6 @@ var JlRating = class extends JlFormControl {
89
82
  const slider = this._refs.slider;
90
83
  this.on(slider, "keydown", (event) => this.onKey(event));
91
84
  this.on(slider, "click", (event) => this.onChoose(event));
92
- this.on(slider, "pointermove", (event) => this.onHover(event));
93
- this.on(slider, "pointerleave", () => this.setPreview(NO_PREVIEW));
94
85
  }
95
86
  resetValue() {
96
87
  this.value.set(clampedNumber(0, 0, MAX_LIMIT)(this.getAttribute("value")));
@@ -112,22 +103,12 @@ var JlRating = class extends JlFormControl {
112
103
  onChoose(event) {
113
104
  const chosen = this.iconValueAt(event);
114
105
  if (chosen === null || !this.canChange()) return;
115
- this.setPreview(NO_PREVIEW);
116
106
  this.commit(ratingAfterChoice(this.current(), chosen));
117
107
  }
118
- onHover(event) {
119
- if (!this.canChange()) return;
120
- this.setPreview(this.iconValueAt(event) ?? NO_PREVIEW);
121
- }
122
108
  iconValueAt(event) {
123
109
  const icon = event.target.closest("[data-value]");
124
110
  return icon === null ? null : Number(icon.dataset.value);
125
111
  }
126
- setPreview(preview) {
127
- if (preview === this._state.preview) return;
128
- this._state.preview = preview;
129
- this.renderValue();
130
- }
131
112
  /** The value as the scale shows it: never past its end. */
132
113
  current() {
133
114
  return Math.min(this.value.get(), this.max.get());
@@ -144,24 +125,26 @@ var JlRating = class extends JlFormControl {
144
125
  renderLabel() {
145
126
  this._refs.slider.setAttribute("aria-label", this.label.get() || jlText("rating"));
146
127
  }
128
+ /** Draws the row of icons again only for another icon or another count. */
147
129
  renderIcons() {
148
- const name = this.icon.get() === "" ? "star" : this.icon.get();
149
- const size = ICON_SIZES[this.size.get()];
150
- const icons = Array.from({ length: this.max.get() }, (_, index) => /* @__PURE__ */ jsx("span", {
130
+ const name = this.icon.get() || DEFAULT_ICON;
131
+ const max = this.max.get();
132
+ const row = this._refs.icons;
133
+ if (name === this._state.drawnIcon && row.childElementCount === max) return;
134
+ this._state.drawnIcon = name;
135
+ const icons = Array.from({ length: max }, (_, index) => /* @__PURE__ */ jsx("span", {
151
136
  class: "icon",
152
137
  "data-value": String(index + 1),
153
- children: iconElement(name, size)
138
+ children: iconElement(name, ICON_SIZE)
154
139
  }));
155
- this._refs.icons.replaceChildren(...icons);
140
+ row.replaceChildren(...icons);
156
141
  this.renderValue();
157
142
  }
143
+ /** The score, in the icons and for screen readers; the score a pointer would give is the CSS's. */
158
144
  renderValue() {
159
145
  const value = this.current();
160
146
  const max = this.max.get();
161
- const preview = this._state.preview;
162
- const shown = preview === NO_PREVIEW ? value : preview;
163
- for (const icon of this._refs.icons.querySelectorAll("[data-value]")) icon.classList.toggle("on", Number(icon.dataset.value) <= shown);
164
- this.reflect("previewing", preview !== NO_PREVIEW);
147
+ for (const icon of this._refs.icons.querySelectorAll("[data-value]")) icon.classList.toggle("on", Number(icon.dataset.value) <= value);
165
148
  const slider = this._refs.slider;
166
149
  slider.setAttribute("aria-valuenow", String(value));
167
150
  slider.setAttribute("aria-valuemax", String(max));
@@ -184,7 +167,6 @@ var JlRating = class extends JlFormControl {
184
167
  this.reflect("disabled", disabled);
185
168
  this._refs.slider.tabIndex = off ? -1 : 0;
186
169
  this._refs.slider.toggleAttribute("aria-disabled", off);
187
- this.setPreview(NO_PREVIEW);
188
170
  }
189
171
  };
190
172
  JlRating.register();
@@ -51,6 +51,7 @@ export declare class JlSelect<Value extends string = string> extends JlFormContr
51
51
  }>>;
52
52
  private readonly _form;
53
53
  private _kept;
54
+ private readonly _drawn;
54
55
  private readonly _refs;
55
56
  focus(options?: FocusOptions): void;
56
57
  templateHtml(): Node;
@@ -60,7 +61,9 @@ export declare class JlSelect<Value extends string = string> extends JlFormContr
60
61
  /** The browser calls it for a disabled fieldset and for the element's own disabled attribute, even before render. */
61
62
  protected setDisabledByForm(disabled: boolean): void;
62
63
  private renderDisabled;
63
- /** The options from `options`, or else copies of the `<option>` and `<optgroup>` the page wrote inside. */
64
+ /** The `<option>` and `<optgroup>` the page wrote inside, used when `options` is empty. */
65
+ private lightOptions;
66
+ /** The options from `options`, or else copies of the page's own. */
64
67
  private optionNodes;
65
68
  private placeholderNodes;
66
69
  /**
@@ -70,9 +73,11 @@ export declare class JlSelect<Value extends string = string> extends JlFormContr
70
73
  private renderOptions;
71
74
  /** Another value among the options drawn: only the option kept for an unknown value comes or goes. */
72
75
  private renderChosen;
73
- /** Another placeholder: its own option is written, added or removed, the others left as they are. */
76
+ /**
77
+ * Another placeholder: its own option is written, added or removed, the others left as they are. Only one that
78
+ * comes or goes can change the option shown.
79
+ */
74
80
  private renderPlaceholder;
75
- private writePlaceholder;
76
81
  /** The option kept for a value no option has goes once another value is chosen. */
77
82
  private dropKept;
78
83
  /**
@@ -21,6 +21,7 @@ var optionElement = (option) => /* @__PURE__ */ jsx("option", {
21
21
  disabled: option.disabled === true,
22
22
  children: option.label
23
23
  });
24
+ var sameNodes = (nodes, others) => nodes.length === others.length && nodes.every((node, index) => node === others[index]);
24
25
  var groupNodes = (group) => {
25
26
  const options = group.options.map(optionElement);
26
27
  return group.label === null ? options : [/* @__PURE__ */ jsx("optgroup", {
@@ -58,7 +59,7 @@ var JlSelect = class extends JlFormControl {
58
59
  required = this.useChange(false, (value) => {
59
60
  this._refs.native.required = value;
60
61
  this.reflect("required", value);
61
- this.renderValue();
62
+ this.mirrorValidity(this._refs.native);
62
63
  }, { attribute: "required" });
63
64
  disabled = this.useChange(false, (value) => {
64
65
  this.reflect("disabled", value);
@@ -71,6 +72,7 @@ var JlSelect = class extends JlFormControl {
71
72
  }, { attribute: "invalid" });
72
73
  _form = { disabled: false };
73
74
  _kept;
75
+ _drawn = { light: [] };
74
76
  _refs = this.useRefs((ref) => ({ native: ref("select") }));
75
77
  focus(options) {
76
78
  this._refs.native.focus(options);
@@ -99,7 +101,6 @@ var JlSelect = class extends JlFormControl {
99
101
  this.value.set(value);
100
102
  this.events.emit("change", value);
101
103
  });
102
- if (this.options.get().length > 0) return;
103
104
  this.renderOptions();
104
105
  }
105
106
  resetValue() {
@@ -113,11 +114,15 @@ var JlSelect = class extends JlFormControl {
113
114
  renderDisabled() {
114
115
  this._refs.native.disabled = this.disabled.get() || this._form.disabled;
115
116
  }
116
- /** The options from `options`, or else copies of the `<option>` and `<optgroup>` the page wrote inside. */
117
- optionNodes() {
117
+ /** The `<option>` and `<optgroup>` the page wrote inside, used when `options` is empty. */
118
+ lightOptions() {
119
+ return this.options.get().length > 0 ? [] : [...this.querySelectorAll(LIGHT_OPTIONS)];
120
+ }
121
+ /** The options from `options`, or else copies of the page's own. */
122
+ optionNodes(light) {
118
123
  const options = this.options.get();
119
124
  if (options.length > 0) return groupOptions(options).flatMap(groupNodes);
120
- return [...this.querySelectorAll(LIGHT_OPTIONS)].map((node) => node.cloneNode(true));
125
+ return light.map((node) => node.cloneNode(true));
121
126
  }
122
127
  placeholderNodes() {
123
128
  const placeholder = this.placeholder.get();
@@ -135,36 +140,43 @@ var JlSelect = class extends JlFormControl {
135
140
  * inside an option, an option the page added and removed before its check ran.
136
141
  */
137
142
  renderOptions() {
138
- this._refs.native.replaceChildren(...this.placeholderNodes(), ...this.optionNodes());
143
+ const options = this.options.get();
144
+ const light = this.lightOptions();
145
+ if (options === this._drawn.options && sameNodes(light, this._drawn.light)) return;
146
+ this._drawn.options = options;
147
+ this._drawn.light = light;
148
+ this._refs.native.replaceChildren(...this.placeholderNodes(), ...this.optionNodes(light));
139
149
  this._kept = void 0;
140
150
  this.keepUnknownValue();
141
151
  this.renderValue();
142
152
  }
143
153
  /** Another value among the options drawn: only the option kept for an unknown value comes or goes. */
144
154
  renderChosen() {
155
+ if (this._drawn.options === void 0 || this.value.get() === this._drawn.value) return;
145
156
  this.dropKept();
146
157
  this.keepUnknownValue();
147
158
  this.renderValue();
148
159
  }
149
- /** Another placeholder: its own option is written, added or removed, the others left as they are. */
160
+ /**
161
+ * Another placeholder: its own option is written, added or removed, the others left as they are. Only one that
162
+ * comes or goes can change the option shown.
163
+ */
150
164
  renderPlaceholder() {
151
- this.writePlaceholder();
152
- this.renderValue();
153
- }
154
- writePlaceholder() {
155
165
  const native = this._refs.native;
156
166
  const shown = native.querySelector(`:scope > option.${PLACEHOLDER_CLASS}`);
157
167
  const placeholder = this.placeholder.get();
168
+ if (this._drawn.options === void 0 || shown === null && placeholder === "") return;
158
169
  if (shown === null) {
159
170
  native.prepend(...this.placeholderNodes());
171
+ this.renderValue();
160
172
  return;
161
173
  }
162
174
  if (placeholder === "") {
163
175
  shown.remove();
176
+ this.renderValue();
164
177
  return;
165
178
  }
166
- if (shown.text === placeholder) return;
167
- shown.text = placeholder;
179
+ if (shown.text !== placeholder) shown.text = placeholder;
168
180
  }
169
181
  /** The option kept for a value no option has goes once another value is chosen. */
170
182
  dropKept() {
@@ -194,6 +206,7 @@ var JlSelect = class extends JlFormControl {
194
206
  renderValue() {
195
207
  const native = this._refs.native;
196
208
  native.selectedIndex = this.shownIndex();
209
+ this._drawn.value = this.value.get();
197
210
  this.reflect("placeholder-shown", native.selectedOptions[0]?.classList.contains(PLACEHOLDER_CLASS) === true);
198
211
  this.internals.setFormValue(native.value);
199
212
  this.mirrorValidity(native);
@@ -29,6 +29,7 @@ export declare class JlSkeleton extends JlElement {
29
29
  private readonly _refs;
30
30
  templateHtml(): Node;
31
31
  templateCss(): string;
32
+ /** As many bones as lines (one for a block or a circle): only those missing are added, those too many removed. */
32
33
  private renderBones;
33
34
  private setLength;
34
35
  }
@@ -46,9 +46,12 @@ var JlSkeleton = class extends JlElement {
46
46
  templateCss() {
47
47
  return css`${BASE_STYLES}${jl_skeleton_default}`;
48
48
  }
49
+ /** As many bones as lines (one for a block or a circle): only those missing are added, those too many removed. */
49
50
  renderBones() {
50
51
  const count = this.shape.get() === "text" ? Math.round(this.lines.get()) : 1;
51
- this._refs.bones.replaceChildren(...Array.from({ length: count }, () => /* @__PURE__ */ jsx("span", { class: "bone" })));
52
+ const bones = this._refs.bones;
53
+ for (const bone of [...bones.children].slice(count)) bone.remove();
54
+ bones.append(...Array.from({ length: count - bones.childElementCount }, () => /* @__PURE__ */ jsx("span", { class: "bone" })));
52
55
  }
53
56
  setLength(property, value) {
54
57
  const length = cssLength(value);
@@ -47,6 +47,7 @@ export declare class JlSlider extends JlFormControl {
47
47
  set(setter: boolean | ((prevState: boolean) => boolean)): void;
48
48
  }>>;
49
49
  private readonly _form;
50
+ private readonly _ticks;
50
51
  private readonly _refs;
51
52
  focus(options?: FocusOptions): void;
52
53
  templateHtml(): Node;
@@ -61,5 +62,8 @@ export declare class JlSlider extends JlFormControl {
61
62
  private renderRange;
62
63
  /** The fill, the shown number and the form's value, from the value the native input kept. */
63
64
  private renderPosition;
65
+ /** Makes the ticks once per list of marks, every readable one, then places them. */
64
66
  private renderMarks;
67
+ /** Puts each tick where its value sits between the bounds; one outside them is hidden. */
68
+ private placeMarks;
65
69
  }
@@ -12,6 +12,13 @@ var DEFAULT_MAX = 100;
12
12
  var DEFAULT_STEP = 1;
13
13
  var DEFAULT_VALUE = 0;
14
14
  var EDGES = /* @__PURE__ */ new Map([[0, "start"], [1, "end"]]);
15
+ var tickElement = (mark) => /* @__PURE__ */ jsxs("span", {
16
+ class: "mark",
17
+ children: [/* @__PURE__ */ jsx("span", { class: "tick" }), mark.label === void 0 ? null : /* @__PURE__ */ jsx("span", {
18
+ class: "mark-label",
19
+ children: mark.label
20
+ })]
21
+ });
15
22
  /**
16
23
  * A number picked by dragging along a track, on the browser's own range input: the arrow keys, Page Up/Down,
17
24
  * Home and End move it. The track fills in the accent colour up to the thumb.
@@ -40,6 +47,7 @@ var JlSlider = class extends JlFormControl {
40
47
  this.renderDisabled();
41
48
  }, { attribute: "disabled" });
42
49
  _form = { disabled: false };
50
+ _ticks = { ticks: [] };
43
51
  _refs = this.useRefs((ref) => ({
44
52
  marks: ref(".marks"),
45
53
  native: ref("input"),
@@ -108,7 +116,7 @@ var JlSlider = class extends JlFormControl {
108
116
  /** New bounds move the thumb and the marks. */
109
117
  renderRange() {
110
118
  this.render();
111
- this.renderMarks();
119
+ this.placeMarks();
112
120
  }
113
121
  /** The fill, the shown number and the form's value, from the value the native input kept. */
114
122
  renderPosition() {
@@ -118,26 +126,32 @@ var JlSlider = class extends JlFormControl {
118
126
  this._refs.output.textContent = native.value;
119
127
  this.internals.setFormValue(native.value);
120
128
  }
129
+ /** Makes the ticks once per list of marks, every readable one, then places them. */
121
130
  renderMarks() {
131
+ const from = this.marks.get();
132
+ if (from === this._ticks.from) return;
133
+ const marks = marksOf(from, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY);
134
+ this._ticks.from = from;
135
+ this._ticks.ticks = marks.map((mark) => ({
136
+ element: tickElement(mark),
137
+ mark
138
+ }));
139
+ this._refs.marks.replaceChildren(...this._ticks.ticks.map((tick) => tick.element));
140
+ this.placeMarks();
141
+ }
142
+ /** Puts each tick where its value sits between the bounds; one outside them is hidden. */
143
+ placeMarks() {
122
144
  const min = this.min.get();
123
145
  const max = this.max.get();
124
- const marks = marksOf(this.marks.get(), min, max);
125
- const container = this._refs.marks;
126
- container.hidden = marks.length === 0;
127
- this.reflect("has-labels", marks.some((mark) => mark.label !== void 0));
128
- container.replaceChildren(...marks.map((mark) => {
129
- const element = /* @__PURE__ */ jsxs("span", {
130
- class: "mark",
131
- children: [/* @__PURE__ */ jsx("span", { class: "tick" }), mark.label === void 0 ? null : /* @__PURE__ */ jsx("span", {
132
- class: "mark-label",
133
- children: mark.label
134
- })]
135
- });
146
+ for (const { element, mark } of this._ticks.ticks) {
136
147
  const fraction = fractionOf(mark.value, min, max);
148
+ element.hidden = mark.value < min || mark.value > max;
137
149
  element.style.setProperty("--at", String(fraction));
138
150
  setOrRemove(element, "data-edge", EDGES.get(fraction) ?? "");
139
- return element;
140
- }));
151
+ }
152
+ const shown = this._ticks.ticks.filter((tick) => !tick.element.hidden);
153
+ this._refs.marks.hidden = shown.length === 0;
154
+ this.reflect("has-labels", shown.some((tick) => tick.mark.label !== void 0));
141
155
  }
142
156
  };
143
157
  JlSlider.register();
@@ -1,3 +1,3 @@
1
1
  // src/atoms/jl-switch.css?inline
2
- var jl_switch_default = ":host{vertical-align:middle;--track-width:36px;--track-height:20px;--thumb:14px;display:inline-flex}:host([size=sm]){--track-width:28px;--track-height:16px;--thumb:10px}.wrap{color:var(--jl-text);font-size:var(--jl-font-md);cursor:pointer;align-items:flex-start;gap:10px;line-height:20px;display:inline-flex}:host([size=sm]) .wrap{font-size:var(--jl-font-sm)}.track{width:var(--track-width);height:var(--track-height);margin-top:calc((20px - var(--track-height)) / 2);flex:none;display:inline-flex;position:relative}.native{border:1px solid var(--jl-line-strong);border-radius:var(--jl-radius-pill);background:var(--jl-surface-3);width:100%;height:100%;cursor:inherit;appearance:none;transition:background var(--jl-fast) var(--jl-ease), border-color var(--jl-fast) var(--jl-ease), box-shadow var(--jl-fast) var(--jl-ease);margin:0;position:absolute;inset:0}.wrap:hover .native:not(:disabled){border-color:color-mix(in srgb, var(--jl-line-strong) 60%, var(--jl-text) 18%)}.native:checked{border-color:var(--jl-accent);background:var(--jl-accent)}.wrap:hover .native:checked:not(:disabled){border-color:var(--jl-accent-strong);background:var(--jl-accent-strong)}.thumb{top:calc((var(--track-height) - var(--thumb)) / 2);left:calc((var(--track-height) - var(--thumb)) / 2);width:var(--thumb);height:var(--thumb);background:var(--jl-muted);pointer-events:none;transition:transform var(--jl-fast) var(--jl-ease), background var(--jl-fast) var(--jl-ease);border-radius:50%;position:absolute}.native:checked+.thumb{background:var(--jl-on-accent);transform:translateX(calc(var(--track-width) - var(--track-height)))}.text{align-self:baseline;gap:2px;display:grid}.description{color:var(--jl-muted);font-size:var(--jl-font-sm);line-height:18px}:host([disabled]) .wrap,:host(:disabled) .wrap{cursor:not-allowed;opacity:.5}";
2
+ var jl_switch_default = ":host{vertical-align:middle;--track-width:36px;--track-height:20px;--thumb:14px;display:inline-flex}:host([size=sm]){--track-width:28px;--track-height:16px;--thumb:10px}.wrap{color:var(--jl-text);font-size:var(--jl-font-md);cursor:pointer;align-items:flex-start;gap:10px;line-height:20px;display:inline-flex}:host([size=sm]) .wrap{font-size:var(--jl-font-sm)}.track{width:var(--track-width);height:var(--track-height);margin-top:calc((20px - var(--track-height)) / 2);flex:none;display:inline-flex;position:relative}.native{border:1px solid var(--jl-line-strong);border-radius:var(--jl-radius-pill);background:var(--jl-surface-3);width:100%;height:100%;cursor:inherit;appearance:none;transition:background var(--jl-fast) var(--jl-ease), border-color var(--jl-fast) var(--jl-ease), box-shadow var(--jl-fast) var(--jl-ease);margin:0;position:absolute;inset:0}.wrap:hover .native:not(:disabled){border-color:color-mix(in srgb, var(--jl-line-strong) 60%, var(--jl-text) 18%)}.native:checked{border-color:var(--jl-accent);background:var(--jl-accent)}.wrap:hover .native:checked:not(:disabled){border-color:var(--jl-accent-strong);background:var(--jl-accent-strong)}.thumb{top:calc((var(--track-height) - var(--thumb)) / 2);left:calc((var(--track-height) - var(--thumb)) / 2);width:var(--thumb);height:var(--thumb);background:var(--jl-muted);pointer-events:none;transition:transform var(--jl-fast) var(--jl-ease), background var(--jl-fast) var(--jl-ease);border-radius:50%;position:absolute}.native:checked+.thumb{background:var(--jl-on-accent);transform:translateX(calc(var(--track-width) - var(--track-height)))}.text{align-self:baseline;gap:2px;display:grid}.label:empty,.description:empty{display:none}.description{color:var(--jl-muted);font-size:var(--jl-font-sm);line-height:18px}:host([disabled]) .wrap,:host(:disabled) .wrap{cursor:not-allowed;opacity:.5}";
3
3
  export { jl_switch_default as default };
@@ -19,13 +19,11 @@ var JlSwitch = class extends JlFormControl {
19
19
  /** The text beside the switch. */
20
20
  label = this.useChange("", (value) => {
21
21
  this._refs.label.textContent = value;
22
- this._refs.label.hidden = value === "";
23
22
  this.renderText();
24
23
  }, { attribute: "label" });
25
24
  /** A smaller line under the label. */
26
25
  description = this.useChange("", (value) => {
27
26
  this._refs.description.textContent = value;
28
- this._refs.description.hidden = value === "";
29
27
  this.renderText();
30
28
  }, { attribute: "description" });
31
29
  /**
@@ -77,14 +75,10 @@ var JlSwitch = class extends JlFormControl {
77
75
  hidden: true,
78
76
  children: [/* @__PURE__ */ jsxs("span", {
79
77
  class: "title",
80
- children: [/* @__PURE__ */ jsx("span", {
81
- class: "label",
82
- hidden: true
83
- }), /* @__PURE__ */ jsx("slot", {})]
78
+ children: [/* @__PURE__ */ jsx("span", { class: "label" }), /* @__PURE__ */ jsx("slot", {})]
84
79
  }), /* @__PURE__ */ jsx("span", {
85
80
  id: "description",
86
- class: "description",
87
- hidden: true
81
+ class: "description"
88
82
  })]
89
83
  })]
90
84
  });
@@ -1,3 +1,3 @@
1
1
  // src/atoms/jl-textarea.css?inline
2
- var jl_textarea_default = ":host{display:block}.field{gap:6px;display:grid}.control{align-items:stretch;padding:0}.native{height:auto;min-height:calc(var(--jl-control-md) - 2px);border-radius:inherit;resize:vertical;padding:8px 12px;display:block}:host([autosize]) .native{resize:none;overflow-y:hidden}:host([readonly]) .control{background:var(--jl-surface-2)}.counter{color:var(--jl-muted);font-family:var(--jl-font-mono);font-size:var(--jl-font-xs);font-variant-numeric:tabular-nums;justify-self:end;line-height:16px}.counter[data-full]{color:var(--jl-warn)}";
2
+ var jl_textarea_default = ":host{display:block}.field{gap:6px;display:grid}.control{align-items:stretch;padding:0}.native{--padding-y:8px;height:auto;min-height:calc(var(--jl-control-md) - 2px);padding:var(--padding-y) 12px;border-radius:inherit;resize:vertical;display:block}:host([autosize]) .native{field-sizing:content;min-height:max(calc(var(--jl-control-md) - 2px), calc(var(--rows,1) * 1lh + 2 * var(--padding-y)));max-height:calc(var(--max-rows) * 1lh + 2 * var(--padding-y));resize:none}:host([readonly]) .control{background:var(--jl-surface-2)}.counter{color:var(--jl-muted);font-family:var(--jl-font-mono);font-size:var(--jl-font-xs);font-variant-numeric:tabular-nums;justify-self:end;line-height:16px}.counter[data-full]{color:var(--jl-warn)}";
3
3
  export { jl_textarea_default as default };
@@ -1,7 +1,8 @@
1
1
  import { JlFormControl } from '../base/jl-form-control';
2
2
  /**
3
3
  * A text field of several lines that takes part in forms. `rows` sets its height; with `autosize` it grows with
4
- * its text up to `max-rows`. A `maxlength` shows a counter under the field.
4
+ * its text up to `max-rows`, sized by the browser (CSS `field-sizing`): nothing is measured. A `maxlength` shows a
5
+ * counter under the field.
5
6
  */
6
7
  export declare class JlTextarea extends JlFormControl {
7
8
  static readonly selector = "jl-textarea";
@@ -74,8 +75,6 @@ export declare class JlTextarea extends JlFormControl {
74
75
  private renderMaxlength;
75
76
  private renderCounter;
76
77
  private setFlag;
77
- /** Fits the height to the text when autosized, between `rows` and `max-rows` lines. */
78
- private fit;
79
- /** The height of `max-rows` lines (never fewer than `rows`), or no limit without it. */
80
- private heightLimit;
78
+ /** The lines an autosized area grows to, for its CSS; left out without a limit, which leaves its max-height none. */
79
+ private renderMaxRows;
81
80
  }
@@ -7,10 +7,10 @@ import { jsx, jsxs } from "@jadis/core/jsx-runtime";
7
7
  // src/atoms/jl-textarea.tsx
8
8
  var DEFAULT_ROWS = 3;
9
9
  var UNLIMITED_ROWS = 0;
10
- var FALLBACK_LINE_HEIGHT = 20;
11
10
  /**
12
11
  * A text field of several lines that takes part in forms. `rows` sets its height; with `autosize` it grows with
13
- * its text up to `max-rows`. A `maxlength` shows a counter under the field.
12
+ * its text up to `max-rows`, sized by the browser (CSS `field-sizing`): nothing is measured. A `maxlength` shows a
13
+ * counter under the field.
14
14
  */
15
15
  var JlTextarea = class extends JlFormControl {
16
16
  static selector = "jl-textarea";
@@ -18,16 +18,14 @@ var JlTextarea = class extends JlFormControl {
18
18
  value = this.useChange("", (value) => this.renderValue(value), { attribute: "value" });
19
19
  placeholder = this.useChange("", (value) => setOrRemove(this._refs.native, "placeholder", value), { attribute: "placeholder" });
20
20
  rows = this.useChange(DEFAULT_ROWS, (value) => {
21
- this._refs.native.rows = Math.max(1, value);
22
- this.fit();
21
+ const native = this._refs.native;
22
+ native.rows = Math.max(1, value);
23
+ native.style.setProperty("--rows", String(native.rows));
23
24
  }, { attribute: "rows" });
24
25
  /** Grows with the text, from `rows` up to `max-rows`. */
25
- autosize = this.useChange(false, (value) => {
26
- this.reflect("autosize", value);
27
- this.fit();
28
- }, { attribute: "autosize" });
26
+ autosize = this.useChange(false, (value) => this.reflect("autosize", value), { attribute: "autosize" });
29
27
  /** The most lines an autosized area grows to before it scrolls; 0 for no limit. */
30
- maxRows = this.useChange(UNLIMITED_ROWS, () => this.fit(), { attribute: "max-rows" });
28
+ maxRows = this.useChange(UNLIMITED_ROWS, (value) => this.renderMaxRows(value), { attribute: "max-rows" });
31
29
  /** The most characters it takes; shows a counter under the field. */
32
30
  maxlength = this.useChange("", (value) => this.renderMaxlength(value), { attribute: "maxlength" });
33
31
  /** The field's name for screen readers, when no visible label names it. */
@@ -84,7 +82,6 @@ var JlTextarea = class extends JlFormControl {
84
82
  this.events.emit("input", native.value);
85
83
  });
86
84
  this.on(native, "change", () => this.events.emit("change", native.value));
87
- this.fit();
88
85
  }
89
86
  resetValue() {
90
87
  this.value.set(this.getAttribute("value") ?? "");
@@ -103,7 +100,6 @@ var JlTextarea = class extends JlFormControl {
103
100
  this.internals.setFormValue(value);
104
101
  this.mirrorValidity(native);
105
102
  this.renderCounter();
106
- this.fit();
107
103
  }
108
104
  renderMaxlength(maxlength) {
109
105
  setOrRemove(this._refs.native, "maxlength", maxlength);
@@ -124,25 +120,14 @@ var JlTextarea = class extends JlFormControl {
124
120
  this.reflect(name, value);
125
121
  this.mirrorValidity(this._refs.native);
126
122
  }
127
- /** Fits the height to the text when autosized, between `rows` and `max-rows` lines. */
128
- fit() {
129
- const native = this._refs.native;
130
- native.style.removeProperty("height");
131
- native.style.removeProperty("overflow-y");
132
- if (!this.autosize.get() || native.scrollHeight === 0) return;
133
- const limit = this.heightLimit(native);
134
- const height = Math.min(native.scrollHeight, limit);
135
- native.style.height = `${height}px`;
136
- native.style.overflowY = native.scrollHeight > limit ? "auto" : "hidden";
137
- }
138
- /** The height of `max-rows` lines (never fewer than `rows`), or no limit without it. */
139
- heightLimit(native) {
140
- const maxRows = this.maxRows.get();
141
- if (maxRows <= UNLIMITED_ROWS) return Number.POSITIVE_INFINITY;
142
- const style = getComputedStyle(native);
143
- const padding = Number.parseFloat(style.paddingTop) + Number.parseFloat(style.paddingBottom);
144
- const lineHeight = Number.parseFloat(style.lineHeight) || FALLBACK_LINE_HEIGHT;
145
- return Math.max(maxRows, this.rows.get()) * lineHeight + padding;
123
+ /** The lines an autosized area grows to, for its CSS; left out without a limit, which leaves its max-height none. */
124
+ renderMaxRows(maxRows) {
125
+ const style = this._refs.native.style;
126
+ if (maxRows <= UNLIMITED_ROWS) {
127
+ style.removeProperty("--max-rows");
128
+ return;
129
+ }
130
+ style.setProperty("--max-rows", String(maxRows));
146
131
  }
147
132
  };
148
133
  JlTextarea.register();
@@ -1,3 +1,4 @@
1
+ import { dateTimeFormat } from "./intl.js";
1
2
  // src/lib/calendar.ts
2
3
  var ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
3
4
  var MS_PER_DAY = 864e5;
@@ -144,7 +145,7 @@ function dateAfterKey(date, key, firstDay, shift = false) {
144
145
  * `options`. Made once and used for many dates, as a calendar page does.
145
146
  */
146
147
  function dateFormatter(locale, options = { dateStyle: "medium" }) {
147
- const format = new Intl.DateTimeFormat(locale, {
148
+ const format = dateTimeFormat(locale, {
148
149
  ...options,
149
150
  timeZone: UTC
150
151
  });
@@ -194,7 +195,7 @@ var DATE_TEXT = /^[\d\s./,-]*$/;
194
195
  var NOT_DIGITS = /\D+/;
195
196
  var isDatePart = (type) => DATE_PARTS.some((part) => part === type);
196
197
  /** A date written in digits in a locale, cut in its parts: `25`, `.`, `10`, `.`, `2026`. */
197
- var numericParts = (locale) => new Intl.DateTimeFormat(locale, {
198
+ var numericParts = (locale) => dateTimeFormat(locale, {
198
199
  ...NUMERIC_DATE,
199
200
  timeZone: UTC
200
201
  }).formatToParts(new Date(utcTime(A_SUNDAY)));
@@ -7,6 +7,16 @@ export declare const PLACEMENTS: readonly Placement[];
7
7
  export declare function computePosition(anchor: Rect, floating: Size, viewport: Size, placement: Placement, gap?: number): Point & {
8
8
  placement: Placement;
9
9
  };
10
+ /**
11
+ * Puts a fixed-position element next to its anchor, and gives what it measured: the anchor's rect, the element's
12
+ * rect where it went, and the placement it got after flipping. Something drawn from them (an arrow) needs no reading
13
+ * after the writes, which would lay the page out again.
14
+ */
15
+ export declare function positionFloating(anchor: Element, floating: HTMLElement, placement: Placement, gap?: number): {
16
+ anchor: Rect;
17
+ floating: Rect;
18
+ placement: Placement;
19
+ };
10
20
  /** Puts a fixed-position element next to its anchor; returns the placement it got after flipping. */
11
21
  export declare function placeFloating(anchor: Element, floating: HTMLElement, placement: Placement, gap?: number): Placement;
12
22
  /** Keeps a floating element by its anchor while the page scrolls or resizes, until the signal aborts. */
@@ -92,21 +92,40 @@ function computePosition(anchor, floating, viewport, placement, gap = DEFAULT_GA
92
92
  top: isVertical(finalSide) ? point.top : clamp(point.top, VIEWPORT_MARGIN, maxTop)
93
93
  };
94
94
  }
95
- /** Puts a fixed-position element next to its anchor; returns the placement it got after flipping. */
96
- function placeFloating(anchor, floating, placement, gap) {
95
+ /**
96
+ * Puts a fixed-position element next to its anchor, and gives what it measured: the anchor's rect, the element's
97
+ * rect where it went, and the placement it got after flipping. Something drawn from them (an arrow) needs no reading
98
+ * after the writes, which would lay the page out again.
99
+ */
100
+ function positionFloating(anchor, floating, placement, gap) {
97
101
  const rect = anchor.getBoundingClientRect();
98
102
  const viewport = {
99
103
  height: window.innerHeight,
100
104
  width: document.documentElement.clientWidth
101
105
  };
102
- const result = computePosition(rect, {
106
+ const size = {
103
107
  height: floating.offsetHeight,
104
108
  width: floating.offsetWidth
105
- }, viewport, placement, gap);
106
- floating.style.left = `${Math.round(result.left)}px`;
107
- floating.style.top = `${Math.round(result.top)}px`;
109
+ };
110
+ const result = computePosition(rect, size, viewport, placement, gap);
111
+ const left = Math.round(result.left);
112
+ const top = Math.round(result.top);
113
+ floating.style.left = `${left}px`;
114
+ floating.style.top = `${top}px`;
108
115
  floating.dataset.placement = result.placement;
109
- return result.placement;
116
+ return {
117
+ anchor: rect,
118
+ floating: {
119
+ ...size,
120
+ left,
121
+ top
122
+ },
123
+ placement: result.placement
124
+ };
125
+ }
126
+ /** Puts a fixed-position element next to its anchor; returns the placement it got after flipping. */
127
+ function placeFloating(anchor, floating, placement, gap) {
128
+ return positionFloating(anchor, floating, placement, gap).placement;
110
129
  }
111
130
  /** Keeps a floating element by its anchor while the page scrolls or resizes, until the signal aborts. */
112
131
  function followAnchor(anchor, floating, placement, signal, gap) {
@@ -124,4 +143,4 @@ function followAnchor(anchor, floating, placement, signal, gap) {
124
143
  });
125
144
  update();
126
145
  }
127
- export { PLACEMENTS, computePosition, followAnchor, placeFloating };
146
+ export { PLACEMENTS, computePosition, followAnchor, placeFloating, positionFloating };