@syware/jlib 0.18.1 → 0.19.1
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.
- package/dist/atoms/jl-checkbox.js +1 -0
- package/dist/atoms/jl-select.js +1 -0
- package/dist/atoms/jl-switch.js +1 -0
- package/dist/lib/slots.d.ts +4 -0
- package/dist/lib/slots.js +11 -2
- package/dist/lib/trigger.d.ts +4 -1
- package/dist/lib/trigger.js +12 -2
- package/dist/molecules/jl-file-drop.js +1 -0
- package/dist/molecules/jl-load-state.js +2 -4
- package/dist/organisms/jl-side-nav.js +2 -1
- package/dist/organisms/jl-table.d.ts +5 -1
- package/dist/organisms/jl-table.js +18 -4
- package/package.json +3 -3
|
@@ -103,6 +103,7 @@ var JlCheckbox = class extends JlFormControl {
|
|
|
103
103
|
}
|
|
104
104
|
onConnect() {
|
|
105
105
|
const native = this._refs.native;
|
|
106
|
+
this.on(native, "input", (event) => event.stopPropagation());
|
|
106
107
|
this.on(native, "change", () => this.commit(native.checked));
|
|
107
108
|
this.renderText();
|
|
108
109
|
this.on(this._refs.slot, "slotchange", () => this.renderText());
|
package/dist/atoms/jl-select.js
CHANGED
|
@@ -97,6 +97,7 @@ var JlSelect = class extends JlFormControl {
|
|
|
97
97
|
}
|
|
98
98
|
onConnect() {
|
|
99
99
|
const native = this._refs.native;
|
|
100
|
+
this.on(native, "input", (event) => event.stopPropagation());
|
|
100
101
|
this.on(native, "change", () => {
|
|
101
102
|
const value = asValue(native.value);
|
|
102
103
|
this.value.set(value);
|
package/dist/atoms/jl-switch.js
CHANGED
|
@@ -88,6 +88,7 @@ var JlSwitch = class extends JlFormControl {
|
|
|
88
88
|
}
|
|
89
89
|
onConnect() {
|
|
90
90
|
const native = this._refs.native;
|
|
91
|
+
this.on(native, "input", (event) => event.stopPropagation());
|
|
91
92
|
this.on(native, "change", () => this.commit(native.checked));
|
|
92
93
|
this.renderText();
|
|
93
94
|
this.on(this._refs.slot, "slotchange", () => this.renderText());
|
package/dist/lib/slots.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
/** Whether a slot holds something to show: an element, or text that is not only white space. */
|
|
2
2
|
export declare function hasSlotted(slot: HTMLSlotElement): boolean;
|
|
3
|
+
/** The elements a slot holds that the page shows: those it keeps `hidden` are left out. */
|
|
4
|
+
export declare function shownSlotted(slot: HTMLSlotElement): Element[];
|
|
5
|
+
/** Whether a slot holds something that shows: an element that is not `hidden`, or text that is not only white space. */
|
|
6
|
+
export declare function showsSlotted(slot: HTMLSlotElement): boolean;
|
package/dist/lib/slots.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
// src/lib/slots.ts
|
|
2
|
+
var holdsText = (node) => !(node instanceof Element) && (node.textContent ?? "").trim() !== "";
|
|
2
3
|
/** Whether a slot holds something to show: an element, or text that is not only white space. */
|
|
3
4
|
function hasSlotted(slot) {
|
|
4
|
-
return slot.assignedNodes({ flatten: true }).some((node) => node instanceof Element || (node
|
|
5
|
+
return slot.assignedNodes({ flatten: true }).some((node) => node instanceof Element || holdsText(node));
|
|
5
6
|
}
|
|
6
|
-
|
|
7
|
+
/** The elements a slot holds that the page shows: those it keeps `hidden` are left out. */
|
|
8
|
+
function shownSlotted(slot) {
|
|
9
|
+
return slot.assignedElements({ flatten: true }).filter((element) => !element.hasAttribute("hidden"));
|
|
10
|
+
}
|
|
11
|
+
/** Whether a slot holds something that shows: an element that is not `hidden`, or text that is not only white space. */
|
|
12
|
+
function showsSlotted(slot) {
|
|
13
|
+
return shownSlotted(slot).length > 0 || slot.assignedNodes({ flatten: true }).some(holdsText);
|
|
14
|
+
}
|
|
15
|
+
export { hasSlotted, shownSlotted, showsSlotted };
|
package/dist/lib/trigger.d.ts
CHANGED
|
@@ -7,5 +7,8 @@ export declare function accessibleTarget(element: Element): Element;
|
|
|
7
7
|
export declare function setTriggerAria(element: Element, name: string, value: string | null): void;
|
|
8
8
|
/** The element that has the focus within a document or a shadow root, looking inside nested shadow roots. */
|
|
9
9
|
export declare function deepActiveElement(root: DocumentOrShadowRoot): Element | null;
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* The first control people can focus among some elements and everything inside them, in the page's order: a
|
|
12
|
+
* component of the page whose fields are in its shadow root gives its first one.
|
|
13
|
+
*/
|
|
11
14
|
export declare function firstFocusable(elements: readonly Element[]): HTMLElement | null;
|
package/dist/lib/trigger.js
CHANGED
|
@@ -27,8 +27,18 @@ function deepActiveElement(root) {
|
|
|
27
27
|
/** A form-associated custom element (jl-input, jl-button…) is a control: its own `focus()` reaches its inside. */
|
|
28
28
|
var isFormComponent = (element) => element.constructor.formAssociated === true;
|
|
29
29
|
var canFocus = (element) => element instanceof HTMLElement && (element.matches(NATIVE_FOCUSABLE) || isFormComponent(element)) && !element.matches(":disabled") && element.checkVisibility();
|
|
30
|
-
/**
|
|
30
|
+
/** What stands under an element in the page: a slot's assigned elements, a shadow root's, or else its children. */
|
|
31
|
+
function shownChildren(element) {
|
|
32
|
+
if (element instanceof HTMLSlotElement && element.assignedElements().length > 0) return element.assignedElements();
|
|
33
|
+
return [...(element.shadowRoot ?? element).children];
|
|
34
|
+
}
|
|
35
|
+
/** An element and everything under it as the page shows them, open shadow roots included, in the page's order. */
|
|
36
|
+
var shownTree = (element) => [element, ...shownChildren(element).flatMap(shownTree)];
|
|
37
|
+
/**
|
|
38
|
+
* The first control people can focus among some elements and everything inside them, in the page's order: a
|
|
39
|
+
* component of the page whose fields are in its shadow root gives its first one.
|
|
40
|
+
*/
|
|
31
41
|
function firstFocusable(elements) {
|
|
32
|
-
return elements.flatMap(
|
|
42
|
+
return elements.flatMap(shownTree).find(canFocus) ?? null;
|
|
33
43
|
}
|
|
34
44
|
export { accessibleTarget, deepActiveElement, firstFocusable, setTriggerAria };
|
|
@@ -188,6 +188,7 @@ var JlFileDrop = class extends JlFormControl {
|
|
|
188
188
|
this.on(zone, "dragover", (event) => this.onDragOver(event));
|
|
189
189
|
this.on(zone, "dragleave", () => this.onDragLeave());
|
|
190
190
|
this.on(zone, "drop", (event) => this.onDrop(event));
|
|
191
|
+
this.on(this._refs.picker, "input", (event) => event.stopPropagation());
|
|
191
192
|
this.on(this._refs.picker, "change", () => this.onPicked());
|
|
192
193
|
this.on(this._refs.files, "click", (event) => this.onFilesClick(event));
|
|
193
194
|
}
|
|
@@ -8,7 +8,7 @@ import { JlButton } from "../atoms/jl-button.js";
|
|
|
8
8
|
import { JlSkeleton } from "../atoms/jl-skeleton.js";
|
|
9
9
|
import { JlEmpty } from "./jl-empty.js";
|
|
10
10
|
import jl_load_state_default from "./jl-load-state.css.js";
|
|
11
|
-
import { css } from "@jadis/core";
|
|
11
|
+
import { Jadis, css } from "@jadis/core";
|
|
12
12
|
import { CircleAlert, RefreshCw } from "lucide";
|
|
13
13
|
import { jsx, jsxs } from "@jadis/core/jsx-runtime";
|
|
14
14
|
// src/molecules/jl-load-state.tsx
|
|
@@ -89,8 +89,6 @@ function leftLoading(state, signal) {
|
|
|
89
89
|
}, { signal: listening.signal });
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
-
/** Waits for the components connected meanwhile to run their `onConnect`, a task after connecting. */
|
|
93
|
-
var nextTask = () => new Promise((resolve) => setTimeout(resolve));
|
|
94
92
|
/** Runs a load's fetch. Only its failure is a load that failed: what `draw` throws afterwards is not caught here. */
|
|
95
93
|
async function fetchOf(task) {
|
|
96
94
|
try {
|
|
@@ -116,7 +114,7 @@ var JlLoadState = class JlLoadState extends JlElement {
|
|
|
116
114
|
* it has its data waits for it (see `jl-page-outlet`).
|
|
117
115
|
*/
|
|
118
116
|
static async whenSettled(root, signal = new AbortController().signal) {
|
|
119
|
-
await
|
|
117
|
+
await Jadis.settled();
|
|
120
118
|
const waiting = loadStatesIn(root).filter(isWaiting);
|
|
121
119
|
if (waiting.length === 0 || signal.aborted) return;
|
|
122
120
|
await Promise.all(waiting.map((state) => leftLoading(state, signal)));
|
|
@@ -493,9 +493,10 @@ var JlSideNav = class extends JlElement {
|
|
|
493
493
|
const opened = path.slice(0, -1).filter((id) => !this._state.open.has(id));
|
|
494
494
|
for (const id of opened) this._state.open.add(id);
|
|
495
495
|
if (opened.length > 0) this.renderOpen();
|
|
496
|
+
const current = this.isRail() ? path[0] : value;
|
|
496
497
|
for (const row of this._refs.sections.querySelectorAll(ROW_SELECTOR)) {
|
|
497
498
|
const id = row.dataset.id ?? "";
|
|
498
|
-
const active = id ===
|
|
499
|
+
const active = id === current;
|
|
499
500
|
setOrRemove(row, "aria-current", active ? "page" : "");
|
|
500
501
|
row.classList.toggle("holds-active", !active && path.includes(id));
|
|
501
502
|
}
|
|
@@ -142,6 +142,7 @@ export declare class JlTable<Row extends object = TableRow, Extra extends string
|
|
|
142
142
|
}>>;
|
|
143
143
|
private readonly _source;
|
|
144
144
|
private readonly _pending;
|
|
145
|
+
private readonly _footWatch;
|
|
145
146
|
private readonly _frozen;
|
|
146
147
|
/**
|
|
147
148
|
* The column chooser once drawn, its boxes by column key, changed in place so the focus stays on the box pressed,
|
|
@@ -170,7 +171,10 @@ export declare class JlTable<Row extends object = TableRow, Extra extends string
|
|
|
170
171
|
private watchScrollbar;
|
|
171
172
|
/** The scroller's width counts its scrollbar and its client width does not: the chooser moves left by the bar. */
|
|
172
173
|
private placeChooser;
|
|
173
|
-
/**
|
|
174
|
+
/**
|
|
175
|
+
* The bar under the rows shows when the page put something in it that shows; what stands there alone goes to its
|
|
176
|
+
* end. What the page keeps `hidden` (pages until there are several) is not there.
|
|
177
|
+
*/
|
|
174
178
|
private drawFoot;
|
|
175
179
|
/** Draws on the next microtask: the inputs set while connecting give one drawing, not one each. */
|
|
176
180
|
protected drawTexts(): void;
|
|
@@ -7,7 +7,7 @@ import { registerIcons } from "../lib/icons.js";
|
|
|
7
7
|
import { columnAlign, columnChoices, columnWidth, fieldOf, formatCell, frozenCells, frozenCss, nextSortDirection, openRows, rowKeyOf, rowToggles, selectionState, shownColumns, sortBy, stickyOffsets, toggleAll, toggleKey, withRowOpen } from "../lib/table.js";
|
|
8
8
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
9
9
|
import { setOrRemove } from "../lib/dom.js";
|
|
10
|
-
import {
|
|
10
|
+
import { shownSlotted, showsSlotted } from "../lib/slots.js";
|
|
11
11
|
import { JlBadge } from "../atoms/jl-badge.js";
|
|
12
12
|
import { JlButton } from "../atoms/jl-button.js";
|
|
13
13
|
import { JlCheckbox } from "../atoms/jl-checkbox.js";
|
|
@@ -228,6 +228,9 @@ var JlTable = class extends JlElement {
|
|
|
228
228
|
order: false,
|
|
229
229
|
queued: false
|
|
230
230
|
};
|
|
231
|
+
_footWatch = new MutationObserver((records) => {
|
|
232
|
+
if (records.some((record) => record.target.parentNode === this)) this.drawFoot();
|
|
233
|
+
});
|
|
231
234
|
_frozen = { sizes: watchSizes(() => this.measureFrozen()) };
|
|
232
235
|
/**
|
|
233
236
|
* The column chooser once drawn, its boxes by column key, changed in place so the focus stays on the box pressed,
|
|
@@ -304,10 +307,17 @@ var JlTable = class extends JlElement {
|
|
|
304
307
|
onConnect() {
|
|
305
308
|
this.drawFoot();
|
|
306
309
|
this.on(this._refs.footSlot, "slotchange", () => this.drawFoot());
|
|
310
|
+
this._footWatch.observe(this, {
|
|
311
|
+
attributeFilter: ["hidden"],
|
|
312
|
+
subtree: true
|
|
313
|
+
});
|
|
307
314
|
this.on(this._refs.head, "click", (event) => {
|
|
308
315
|
const key = event.target.closest("button.sort")?.dataset.key;
|
|
309
316
|
if (key !== void 0) this.sortBy(key);
|
|
310
317
|
});
|
|
318
|
+
this.on(this._refs.table, "input", (event) => {
|
|
319
|
+
if (isTableCheckbox(event.target)) event.stopPropagation();
|
|
320
|
+
});
|
|
311
321
|
this.on(this._refs.table, "change", (event) => {
|
|
312
322
|
if (isTableCheckbox(event.target)) this.changeSelection(event.target);
|
|
313
323
|
});
|
|
@@ -316,6 +326,7 @@ var JlTable = class extends JlElement {
|
|
|
316
326
|
this.watchFrozen();
|
|
317
327
|
}
|
|
318
328
|
onDisconnect() {
|
|
329
|
+
this._footWatch.disconnect();
|
|
319
330
|
this._chooser.sizes.disconnect();
|
|
320
331
|
this._frozen.sizes.disconnect();
|
|
321
332
|
}
|
|
@@ -357,11 +368,14 @@ var JlTable = class extends JlElement {
|
|
|
357
368
|
const scroll = this._refs.scroll;
|
|
358
369
|
this.style.setProperty("--scrollbar", `${scroll.offsetWidth - scroll.clientWidth}px`);
|
|
359
370
|
}
|
|
360
|
-
/**
|
|
371
|
+
/**
|
|
372
|
+
* The bar under the rows shows when the page put something in it that shows; what stands there alone goes to its
|
|
373
|
+
* end. What the page keeps `hidden` (pages until there are several) is not there.
|
|
374
|
+
*/
|
|
361
375
|
drawFoot() {
|
|
362
376
|
const foot = this._refs.foot;
|
|
363
|
-
foot.hidden = !
|
|
364
|
-
foot.classList.toggle("alone", this._refs.footSlot
|
|
377
|
+
foot.hidden = !showsSlotted(this._refs.footSlot);
|
|
378
|
+
foot.classList.toggle("alone", shownSlotted(this._refs.footSlot).length === 1);
|
|
365
379
|
}
|
|
366
380
|
/** Draws on the next microtask: the inputs set while connecting give one drawing, not one each. */
|
|
367
381
|
drawTexts() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syware/jlib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.1",
|
|
4
4
|
"description": "A tree-shakeable component library on Jadis and native Web Components, organised in atomic design",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"version": "node scripts/plugin-version.mjs"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
|
-
"@jadis/core": "^1.
|
|
91
|
+
"@jadis/core": "^1.10.0"
|
|
92
92
|
},
|
|
93
93
|
"dependencies": {
|
|
94
94
|
"lucide": "^1.61.0"
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"@biomejs/biome": "^2.6.3",
|
|
98
98
|
"@fontsource-variable/jetbrains-mono": "^5.3.0",
|
|
99
99
|
"@fontsource-variable/manrope": "^5.3.0",
|
|
100
|
-
"@jadis/core": "^1.
|
|
100
|
+
"@jadis/core": "^1.10.0",
|
|
101
101
|
"@types/node": "^24.13.3",
|
|
102
102
|
"axe-core": "^4.14.0",
|
|
103
103
|
"happy-dom": "^21.0.4",
|