@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.
- package/dist/atoms/jl-avatar.css.js +1 -1
- package/dist/atoms/jl-avatar.js +1 -8
- package/dist/atoms/jl-button.css.js +1 -1
- package/dist/atoms/jl-button.js +4 -6
- package/dist/atoms/jl-checkbox.css.js +1 -1
- package/dist/atoms/jl-checkbox.js +8 -10
- package/dist/atoms/jl-chip.css.js +1 -1
- package/dist/atoms/jl-chip.js +3 -11
- package/dist/atoms/jl-divider.css.js +1 -1
- package/dist/atoms/jl-divider.js +1 -5
- package/dist/atoms/jl-icon.css.js +1 -1
- package/dist/atoms/jl-icon.d.ts +2 -0
- package/dist/atoms/jl-icon.js +5 -1
- package/dist/atoms/jl-input.d.ts +7 -2
- package/dist/atoms/jl-input.js +36 -31
- package/dist/atoms/jl-link.css.js +1 -1
- package/dist/atoms/jl-link.js +3 -6
- package/dist/atoms/jl-rating.css.js +1 -1
- package/dist/atoms/jl-rating.d.ts +2 -2
- package/dist/atoms/jl-rating.js +17 -35
- package/dist/atoms/jl-select.d.ts +8 -3
- package/dist/atoms/jl-select.js +26 -13
- package/dist/atoms/jl-skeleton.d.ts +1 -0
- package/dist/atoms/jl-skeleton.js +4 -1
- package/dist/atoms/jl-slider.d.ts +4 -0
- package/dist/atoms/jl-slider.js +29 -15
- package/dist/atoms/jl-switch.css.js +1 -1
- package/dist/atoms/jl-switch.js +2 -8
- package/dist/atoms/jl-textarea.css.js +1 -1
- package/dist/atoms/jl-textarea.d.ts +4 -5
- package/dist/atoms/jl-textarea.js +15 -30
- package/dist/lib/calendar.js +3 -2
- package/dist/lib/floating.d.ts +10 -0
- package/dist/lib/floating.js +27 -8
- package/dist/lib/flow.d.ts +7 -3
- package/dist/lib/flow.js +19 -8
- package/dist/lib/indicator.d.ts +16 -0
- package/dist/lib/indicator.js +32 -6
- package/dist/lib/intl.d.ts +6 -0
- package/dist/lib/intl.js +19 -0
- package/dist/lib/palette.js +1 -6
- package/dist/lib/table.d.ts +14 -2
- package/dist/lib/table.js +50 -39
- package/dist/molecules/jl-accordion-item.css.js +1 -1
- package/dist/molecules/jl-accordion-item.js +1 -5
- package/dist/molecules/jl-account-button.css.js +1 -1
- package/dist/molecules/jl-account-button.js +1 -5
- package/dist/molecules/jl-alert.css.js +1 -1
- package/dist/molecules/jl-alert.d.ts +5 -5
- package/dist/molecules/jl-alert.js +4 -13
- package/dist/molecules/jl-avatar-group.d.ts +7 -5
- package/dist/molecules/jl-avatar-group.js +15 -5
- package/dist/molecules/jl-breadcrumb.d.ts +7 -4
- package/dist/molecules/jl-breadcrumb.js +32 -8
- package/dist/molecules/jl-calendar.d.ts +12 -3
- package/dist/molecules/jl-calendar.js +79 -48
- package/dist/molecules/jl-card.css.js +1 -1
- package/dist/molecules/jl-card.js +2 -8
- package/dist/molecules/jl-chip-group.css.js +1 -1
- package/dist/molecules/jl-chip-group.d.ts +6 -2
- package/dist/molecules/jl-chip-group.js +13 -18
- package/dist/molecules/jl-code-block.css.js +1 -1
- package/dist/molecules/jl-code-block.d.ts +7 -5
- package/dist/molecules/jl-code-block.js +19 -22
- package/dist/molecules/jl-combobox.css.js +1 -1
- package/dist/molecules/jl-combobox.d.ts +4 -0
- package/dist/molecules/jl-combobox.js +33 -19
- package/dist/molecules/jl-date-picker.d.ts +6 -0
- package/dist/molecules/jl-date-picker.js +29 -9
- package/dist/molecules/jl-empty.css.js +1 -1
- package/dist/molecules/jl-empty.js +4 -19
- package/dist/molecules/jl-field.css.js +1 -1
- package/dist/molecules/jl-field.d.ts +7 -1
- package/dist/molecules/jl-field.js +35 -23
- package/dist/molecules/jl-file-drop.css.js +1 -1
- package/dist/molecules/jl-file-drop.js +1 -3
- package/dist/molecules/jl-input-list.css.js +1 -1
- package/dist/molecules/jl-input-list.d.ts +12 -1
- package/dist/molecules/jl-input-list.js +81 -51
- package/dist/molecules/jl-list-item.css.js +1 -1
- package/dist/molecules/jl-list-item.d.ts +3 -1
- package/dist/molecules/jl-list-item.js +26 -27
- package/dist/molecules/jl-load-state.css.js +1 -1
- package/dist/molecules/jl-load-state.d.ts +6 -1
- package/dist/molecules/jl-load-state.js +15 -18
- package/dist/molecules/jl-menu.d.ts +1 -0
- package/dist/molecules/jl-menu.js +9 -2
- package/dist/molecules/jl-pagination.css.js +1 -1
- package/dist/molecules/jl-pagination.d.ts +7 -1
- package/dist/molecules/jl-pagination.js +43 -35
- package/dist/molecules/jl-search.css.js +1 -1
- package/dist/molecules/jl-search.js +4 -12
- package/dist/molecules/jl-segmented.css.js +1 -1
- package/dist/molecules/jl-segmented.d.ts +4 -2
- package/dist/molecules/jl-segmented.js +19 -26
- package/dist/molecules/jl-stat.css.js +1 -1
- package/dist/molecules/jl-stat.js +2 -8
- package/dist/molecules/jl-steps.d.ts +10 -3
- package/dist/molecules/jl-steps.js +82 -49
- package/dist/molecules/jl-tabs.d.ts +5 -2
- package/dist/molecules/jl-tabs.js +31 -25
- package/dist/molecules/jl-tag-input.css.js +1 -1
- package/dist/molecules/jl-tag-input.d.ts +13 -1
- package/dist/molecules/jl-tag-input.js +57 -30
- package/dist/molecules/jl-timeline.css.js +1 -1
- package/dist/molecules/jl-timeline.d.ts +3 -1
- package/dist/molecules/jl-timeline.js +9 -14
- package/dist/molecules/jl-toast.css.js +1 -1
- package/dist/molecules/jl-toast.js +2 -10
- package/dist/molecules/jl-tooltip.d.ts +2 -1
- package/dist/molecules/jl-tooltip.js +11 -15
- package/dist/organisms/jl-command-palette.css.js +1 -1
- package/dist/organisms/jl-command-palette.d.ts +8 -1
- package/dist/organisms/jl-command-palette.js +73 -42
- package/dist/organisms/jl-confirm.css.js +1 -1
- package/dist/organisms/jl-confirm.js +1 -5
- package/dist/organisms/jl-dialog.css.js +1 -1
- package/dist/organisms/jl-dialog.js +1 -5
- package/dist/organisms/jl-drawer.css.js +1 -1
- package/dist/organisms/jl-drawer.js +1 -3
- package/dist/organisms/jl-flow.d.ts +18 -2
- package/dist/organisms/jl-flow.js +128 -44
- package/dist/organisms/jl-navbar.css.js +1 -1
- package/dist/organisms/jl-navbar.d.ts +1 -1
- package/dist/organisms/jl-navbar.js +3 -5
- package/dist/organisms/jl-page-header.css.js +1 -1
- package/dist/organisms/jl-page-header.js +1 -5
- package/dist/organisms/jl-page-outlet.d.ts +4 -3
- package/dist/organisms/jl-page-outlet.js +7 -8
- package/dist/organisms/jl-side-nav.css.js +1 -1
- package/dist/organisms/jl-side-nav.d.ts +9 -2
- package/dist/organisms/jl-side-nav.js +44 -16
- package/dist/organisms/jl-tab-bar.css.js +1 -1
- package/dist/organisms/jl-tab-bar.js +0 -2
- package/dist/organisms/jl-table.css.js +1 -1
- package/dist/organisms/jl-table.d.ts +18 -6
- package/dist/organisms/jl-table.js +91 -57
- package/dist/organisms/jl-tree.css.js +1 -1
- package/dist/organisms/jl-tree.d.ts +16 -13
- package/dist/organisms/jl-tree.js +72 -70
- package/package.json +1 -1
|
@@ -44,7 +44,7 @@ var JlSideNav = class extends JlElement {
|
|
|
44
44
|
static selector = "jl-side-nav";
|
|
45
45
|
/** `collapse`: people folded the side nav into its rail (true) or unfolded it (false), for the app to remember. */
|
|
46
46
|
events = this.useEvents();
|
|
47
|
-
sections = this.useChange([], () => this.
|
|
47
|
+
sections = this.useChange([], () => this.schedule(), {
|
|
48
48
|
attribute: "sections",
|
|
49
49
|
parse: parseSections
|
|
50
50
|
});
|
|
@@ -56,24 +56,33 @@ var JlSideNav = class extends JlElement {
|
|
|
56
56
|
/** Shows only the icons, in a narrow rail; the labels become tooltips. */
|
|
57
57
|
collapsed = this.useChange(false, (value) => {
|
|
58
58
|
this.reflect("collapsed", value);
|
|
59
|
-
this.
|
|
59
|
+
this.schedule();
|
|
60
60
|
}, { attribute: "collapsed" });
|
|
61
61
|
/** Adds a button at the bottom that folds the side nav into its rail and unfolds it. */
|
|
62
|
-
collapsible = this.useChange(false, () => this.
|
|
62
|
+
collapsible = this.useChange(false, (value) => this.reflect("collapsible", value), { attribute: "collapsible" });
|
|
63
63
|
/** The fold button's text while the side nav is open; jlib's own when empty. */
|
|
64
|
-
collapseLabel = this.useChange("", () => this.
|
|
64
|
+
collapseLabel = this.useChange("", () => this.schedule(), { attribute: "collapse-label" });
|
|
65
65
|
/** Its hint while the side nav is a rail; jlib's own when empty. */
|
|
66
|
-
expandLabel = this.useChange("", () => this.
|
|
66
|
+
expandLabel = this.useChange("", () => this.schedule(), { attribute: "expand-label" });
|
|
67
67
|
/**
|
|
68
68
|
* Set by `jl-app-shell` while the side nav is its drawer, on a narrow screen: the drawer shows it whole, and its
|
|
69
69
|
* fold button hides, `collapsed` waiting for a wide screen again.
|
|
70
70
|
*/
|
|
71
|
-
inDrawer = this.useChange(false, () =>
|
|
71
|
+
inDrawer = this.useChange(false, (value) => {
|
|
72
|
+
this.reflect("in-drawer", value);
|
|
73
|
+
this.schedule();
|
|
74
|
+
}, { attribute: "in-drawer" });
|
|
72
75
|
/** The name of the navigation for screen readers. */
|
|
73
76
|
label = this.useChange("", () => this.renderLabel(), { attribute: "label" });
|
|
74
77
|
_prefix = uniqueId("jl-side-nav");
|
|
75
78
|
/** The parents people opened, or that hold the active item. */
|
|
76
79
|
_state = { open: /* @__PURE__ */ new Set() };
|
|
80
|
+
/** The sections and the form (rail or whole) the items were drawn for, and whether a drawing waits. */
|
|
81
|
+
_drawn = {
|
|
82
|
+
queued: false,
|
|
83
|
+
rail: false,
|
|
84
|
+
sections: void 0
|
|
85
|
+
};
|
|
77
86
|
_refs = this.useRefs((ref) => ({
|
|
78
87
|
fold: ref(JlButton),
|
|
79
88
|
nav: ref("nav"),
|
|
@@ -90,8 +99,7 @@ var JlSideNav = class extends JlElement {
|
|
|
90
99
|
children: [/* @__PURE__ */ jsx("slot", { name: "footer" }), /* @__PURE__ */ jsx(JlButton, {
|
|
91
100
|
class: "fold",
|
|
92
101
|
variant: "ghost",
|
|
93
|
-
block: true
|
|
94
|
-
hidden: true
|
|
102
|
+
block: true
|
|
95
103
|
})]
|
|
96
104
|
})
|
|
97
105
|
]
|
|
@@ -136,24 +144,45 @@ var JlSideNav = class extends JlElement {
|
|
|
136
144
|
this.collapsed.set(collapsed);
|
|
137
145
|
this.events.emit("collapse", collapsed);
|
|
138
146
|
}
|
|
139
|
-
/**
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
this.
|
|
147
|
+
/** Draws on the next microtask: the inputs set while connecting give one drawing, not one each. */
|
|
148
|
+
schedule() {
|
|
149
|
+
if (this._drawn.queued) return;
|
|
150
|
+
this._drawn.queued = true;
|
|
151
|
+
queueMicrotask(() => this.flush());
|
|
152
|
+
}
|
|
153
|
+
/** The rail, or the whole side nav, said on the host (`rail`) for the styles and the page. */
|
|
154
|
+
flush() {
|
|
155
|
+
this._drawn.queued = false;
|
|
156
|
+
const rail = this.isRail();
|
|
157
|
+
this.reflect("rail", rail);
|
|
143
158
|
this.renderFold();
|
|
159
|
+
this.renderItems(rail);
|
|
160
|
+
}
|
|
161
|
+
/** Draws the items again only for other sections or the other form: the rail's rows lead elsewhere. */
|
|
162
|
+
renderItems(rail) {
|
|
163
|
+
const sections = this.sections.get();
|
|
164
|
+
if (sections === this._drawn.sections && rail === this._drawn.rail) return;
|
|
165
|
+
Object.assign(this._drawn, {
|
|
166
|
+
rail,
|
|
167
|
+
sections
|
|
168
|
+
});
|
|
169
|
+
this.render();
|
|
144
170
|
}
|
|
145
171
|
drawTexts() {
|
|
146
172
|
this.renderLabel();
|
|
147
|
-
this.
|
|
148
|
-
|
|
173
|
+
for (const expander of this._refs.sections.querySelectorAll(".expander")) {
|
|
174
|
+
const name = findItem(this.sections.get(), expander.dataset.id ?? "")?.label ?? "";
|
|
175
|
+
expander.setAttribute("aria-label", jlText("showPagesOf", { name }));
|
|
176
|
+
}
|
|
177
|
+
this.schedule();
|
|
149
178
|
}
|
|
150
179
|
renderLabel() {
|
|
151
180
|
this._refs.nav.setAttribute("aria-label", this.label.get() || jlText("mainNavigation"));
|
|
152
181
|
}
|
|
182
|
+
/** The fold button's icon and text; the CSS hides it unless `collapsible`, and in a drawer. */
|
|
153
183
|
renderFold() {
|
|
154
184
|
const fold = this._refs.fold;
|
|
155
185
|
const rail = this.isRail();
|
|
156
|
-
fold.hidden = !this.collapsible.get() || this.inDrawer.get();
|
|
157
186
|
fold.icon.set(rail ? EXPAND_ICON : COLLAPSE_ICON);
|
|
158
187
|
fold.label.set(rail ? "" : this.collapseLabel.get() || jlText("collapseMenu"));
|
|
159
188
|
fold.hint.set(rail ? this.expandLabel.get() || jlText("expandMenu") : "");
|
|
@@ -315,7 +344,6 @@ var JlSideNav = class extends JlElement {
|
|
|
315
344
|
const id = (entry?.querySelector(ROW_SELECTOR))?.dataset.id ?? "";
|
|
316
345
|
const open = this._state.open.has(id);
|
|
317
346
|
list.hidden = !open;
|
|
318
|
-
entry?.classList.toggle("open", open);
|
|
319
347
|
for (const control of entry?.querySelectorAll(`[aria-controls="${list.id}"]`) ?? []) control.setAttribute("aria-expanded", String(open));
|
|
320
348
|
}
|
|
321
349
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/organisms/jl-tab-bar.css?inline
|
|
2
|
-
var jl_tab_bar_default = ":host{--height:60px;display:block}nav{min-height:var(--height);padding-bottom:env(safe-area-inset-bottom);border-top:1px solid var(--jl-line);background:var(--jl-surface);grid-auto-columns:minmax(0,1fr);grid-auto-flow:column;display:grid}.items{display:contents}.item{min-width:0;color:var(--jl-muted);cursor:pointer;transition:color var(--jl-fast) var(--jl-ease);background:0 0;border:none;flex-direction:column;justify-content:center;align-items:center;gap:2px;padding:6px 2px;font-size:11px;font-weight:600;line-height:1.4;text-decoration:none;display:flex}.item:hover{color:var(--jl-text)}.item[aria-current=page]{color:var(--jl-accent)}.item:focus-visible{box-shadow:none}.icon{border-radius:var(--jl-radius-pill);width:52px;height:28px;transition:background var(--jl-fast) var(--jl-ease);place-items:center;display:inline-grid;position:relative}.item:focus-visible .icon{box-shadow:var(--jl-focus-ring)}.item[aria-current=page] .icon{background:var(--jl-accent-soft)}.label{text-overflow:ellipsis;white-space:nowrap;max-width:100%;padding:0 2px;overflow:hidden}.badge{border:2px solid var(--jl-surface);border-radius:var(--jl-radius-pill);background:var(--jl-accent);min-width:18px;height:18px;color:var(--jl-on-accent);text-align:center;padding:0 5px;font-size:10px;font-weight:700;line-height:14px;position:absolute;top:-4px;left:calc(50% + 4px)}";
|
|
2
|
+
var jl_tab_bar_default = ":host{--height:60px;display:block}nav{min-height:var(--height);padding-bottom:env(safe-area-inset-bottom);border-top:1px solid var(--jl-line);background:var(--jl-surface);grid-auto-columns:minmax(0,1fr);grid-auto-flow:column;display:grid}.items{display:contents}.item{min-width:0;color:var(--jl-muted);cursor:pointer;transition:color var(--jl-fast) var(--jl-ease);background:0 0;border:none;flex-direction:column;justify-content:center;align-items:center;gap:2px;padding:6px 2px;font-size:11px;font-weight:600;line-height:1.4;text-decoration:none;display:flex}.item:hover{color:var(--jl-text)}.item[aria-current=page]{color:var(--jl-accent)}.more:has(.label:empty){display:none}.item:focus-visible{box-shadow:none}.icon{border-radius:var(--jl-radius-pill);width:52px;height:28px;transition:background var(--jl-fast) var(--jl-ease);place-items:center;display:inline-grid;position:relative}.item:focus-visible .icon{box-shadow:var(--jl-focus-ring)}.item[aria-current=page] .icon{background:var(--jl-accent-soft)}.label{text-overflow:ellipsis;white-space:nowrap;max-width:100%;padding:0 2px;overflow:hidden}.badge{border:2px solid var(--jl-surface);border-radius:var(--jl-radius-pill);background:var(--jl-accent);min-width:18px;height:18px;color:var(--jl-on-accent);text-align:center;padding:0 5px;font-size:10px;font-weight:700;line-height:14px;position:absolute;top:-4px;left:calc(50% + 4px)}";
|
|
3
3
|
export { jl_tab_bar_default as default };
|
|
@@ -47,7 +47,6 @@ var JlTabBar = class extends JlElement {
|
|
|
47
47
|
/** The label of a last button for the other places (`More`); empty shows none. */
|
|
48
48
|
more = this.useChange("", (value) => {
|
|
49
49
|
this._refs.moreLabel.textContent = value;
|
|
50
|
-
this._refs.more.hidden = value === "";
|
|
51
50
|
}, { attribute: "more" });
|
|
52
51
|
/** The name of the navigation for screen readers. */
|
|
53
52
|
label = this.useChange("", () => this.drawTexts(), { attribute: "label" });
|
|
@@ -63,7 +62,6 @@ var JlTabBar = class extends JlElement {
|
|
|
63
62
|
children: [/* @__PURE__ */ jsx("div", { class: "items" }), /* @__PURE__ */ jsxs("button", {
|
|
64
63
|
class: "item more",
|
|
65
64
|
type: "button",
|
|
66
|
-
hidden: true,
|
|
67
65
|
children: [/* @__PURE__ */ jsx("span", {
|
|
68
66
|
class: "icon",
|
|
69
67
|
children: /* @__PURE__ */ jsx(JlIcon, {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/organisms/jl-table.css?inline
|
|
2
|
-
var jl_table_default = ":host{contain:inline-size;--max-height:none;--cell-y:10px;--cell-x:14px;--select-width:44px;--expand-width:36px;--lead:0px;display:block}:host([expandable]){--lead:var(--expand-width)}:host([expandable][selectable]){--expand-width:28px;--lead:calc(var(--select-width) + var(--expand-width))}:host([dense]){--cell-y:6px;--cell-x:12px}.scroll{max-height:var(--max-height);border:1px solid var(--jl-line);border-radius:var(--jl-radius);background:var(--jl-surface);overscroll-behavior-x:contain;position:relative;overflow:auto}:host([expandable]) .scroll{container-type:inline-size}table{border-collapse:separate;border-spacing:0;width:100%;color:var(--jl-text);font-size:var(--jl-font-md);line-height:20px}th,td{padding:var(--cell-y) var(--cell-x);white-space:nowrap;vertical-align:middle}th{z-index:1;border-bottom:1px solid var(--jl-line);background:var(--jl-surface-2);color:var(--jl-muted);font-size:var(--jl-font-xs);letter-spacing:.01em;text-align:left;font-weight:600;position:sticky;top:0}td{border-top:1px solid var(--jl-line-soft)}tbody tr:first-child td{border-top:none}tbody tr.empty td{padding:40px var(--cell-x);color:var(--jl-muted);text-align:center}tbody tr.detail td{padding:0 var(--cell-x) calc(var(--cell-y) + 6px) calc(var(--lead) + var(--cell-x));white-space:normal;cursor:auto;border-top:none}.detail-body{left:calc(var(--lead) + var(--cell-x));max-width:calc(100cqi - var(--lead) - 2 * var(--cell-x));position:sticky}.align-left{text-align:left}.align-center{text-align:center}.align-right{text-align:right}.sort{border-radius:var(--jl-radius-xs);color:inherit;font-weight:inherit;letter-spacing:inherit;cursor:pointer;background:0 0;border:none;align-items:center;gap:4px;margin:-2px -4px;padding:2px 4px;display:inline-flex}.sort:hover{color:var(--jl-text)}.sort-icon{color:var(--jl-faint)}th[
|
|
2
|
+
var jl_table_default = ":host{contain:inline-size;--max-height:none;--cell-y:10px;--cell-x:14px;--select-width:44px;--expand-width:36px;--lead:0px;display:block}:host([expandable]){--lead:var(--expand-width)}:host([expandable][selectable]){--expand-width:28px;--lead:calc(var(--select-width) + var(--expand-width))}:host([dense]){--cell-y:6px;--cell-x:12px}.scroll{max-height:var(--max-height);border:1px solid var(--jl-line);border-radius:var(--jl-radius);background:var(--jl-surface);overscroll-behavior-x:contain;position:relative;overflow:auto}:host([expandable]) .scroll{container-type:inline-size}table{border-collapse:separate;border-spacing:0;width:100%;color:var(--jl-text);font-size:var(--jl-font-md);line-height:20px}th,td{padding:var(--cell-y) var(--cell-x);white-space:nowrap;vertical-align:middle}th{z-index:1;border-bottom:1px solid var(--jl-line);background:var(--jl-surface-2);color:var(--jl-muted);font-size:var(--jl-font-xs);letter-spacing:.01em;text-align:left;font-weight:600;position:sticky;top:0}td{border-top:1px solid var(--jl-line-soft)}tbody tr:first-child td{border-top:none}tbody tr.empty td{padding:40px var(--cell-x);color:var(--jl-muted);text-align:center}tbody tr.detail td{padding:0 var(--cell-x) calc(var(--cell-y) + 6px) calc(var(--lead) + var(--cell-x));white-space:normal;cursor:auto;border-top:none}.detail-body{left:calc(var(--lead) + var(--cell-x));max-width:calc(100cqi - var(--lead) - 2 * var(--cell-x));position:sticky}.align-left{text-align:left}.align-center{text-align:center}.align-right{text-align:right}.sort{border-radius:var(--jl-radius-xs);color:inherit;font-weight:inherit;letter-spacing:inherit;cursor:pointer;background:0 0;border:none;align-items:center;gap:4px;margin:-2px -4px;padding:2px 4px;display:inline-flex}.sort:hover{color:var(--jl-text)}.sort-icon{color:var(--jl-faint)}th[aria-sort]{color:var(--jl-text)}th[aria-sort] .sort-icon{color:var(--jl-accent)}tbody tr[data-marked] td{background:var(--jl-accent-soft)}tbody tr[data-marked] td:first-child{box-shadow:inset 3px 0 0 var(--jl-accent)}tbody tr:has(>.select-cell .checkbox:checked) td{background:var(--jl-accent-soft)}tbody tr:not(.empty,.skeleton,.detail,:has(>.select-cell .checkbox:checked)):hover td,:host([striped]) tbody tr:nth-child(2n of :where(:not(.detail))):not(.empty,[data-marked],:has(>.select-cell .checkbox:checked)) td{background:var(--jl-surface-2)}:host([striped]) tbody tr:not(.empty,.skeleton,.detail,:has(>.select-cell .checkbox:checked)):hover td{background:var(--jl-surface-3)}:host([striped]) tbody tr:nth-child(2n of :where(:not(.detail))):not([data-marked],:has(>.select-cell .checkbox:checked))+.detail td{background:var(--jl-surface-2)}.format-number{font-variant-numeric:tabular-nums}td.wrap{white-space:normal;overflow-wrap:anywhere;min-width:160px}.format-date{color:var(--jl-text-2);font-variant-numeric:tabular-nums}code{border-radius:var(--jl-radius-xs);background:var(--jl-code-bg);font-size:var(--jl-font-xs);padding:2px 6px}.select-cell{width:var(--select-width);padding-right:0;line-height:0}.expand-cell{width:var(--expand-width);padding-right:0;padding-left:calc(var(--cell-x) - 4px);line-height:0}.select-cell+.expand-cell{padding-left:0}:host([expandable]) tbody tr[data-index]{cursor:pointer}.expand{border-radius:var(--jl-radius-xs);width:24px;height:24px;color:var(--jl-muted);cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;margin:-2px 0;padding:0;display:inline-flex}.expand:hover{color:var(--jl-text)}.chevron{transition:rotate var(--jl-fast) var(--jl-ease)}.expand[aria-expanded=true] .chevron{rotate:90deg}.check{display:inline-flex;position:relative}.checkbox{border:1.5px solid var(--jl-line-strong);background:var(--jl-surface);cursor:pointer;appearance:none;width:16px;height:16px;transition:background var(--jl-fast) var(--jl-ease), border-color var(--jl-fast) var(--jl-ease);border-radius:4px;margin:0}.checkbox:hover{border-color:var(--jl-muted)}.checkbox:checked,.checkbox:indeterminate{border-color:var(--jl-accent);background:var(--jl-accent)}.checkbox:disabled{cursor:not-allowed;opacity:.5}.mark{pointer-events:none;position:absolute;inset:0}.checkbox:checked+.mark:after{border:solid var(--jl-on-accent);content:\"\";border-width:0 2px 2px 0;width:5px;height:9px;position:absolute;top:2.5px;left:5.5px;rotate:45deg}.checkbox:indeterminate+.mark:after{background:var(--jl-on-accent);content:\"\";border-radius:1px;height:2px;position:absolute;top:7px;left:4px;right:4px}.empty-content{align-items:center;gap:8px;display:inline-flex}.empty jl-icon{color:var(--jl-faint)}.bone{border-radius:var(--jl-radius-pill);background:linear-gradient(90deg, var(--jl-surface-3) 30%, var(--jl-surface-2) 50%, var(--jl-surface-3) 70%) 0 0 / 300% 100%;vertical-align:middle;width:70%;max-width:160px;height:10px;animation:1.4s linear infinite shimmer;display:inline-block}.bone.box{border-radius:4px;width:16px;height:16px}tbody tr.skeleton:nth-child(3n+2) .bone:not(.box){width:50%}tbody tr.skeleton:nth-child(3n) .bone:not(.box){width:85%}@media (prefers-reduced-motion:reduce){.bone{animation:none}}@keyframes shimmer{0%{background-position:100% 0}to{background-position:0 0}}.cell-description{color:var(--jl-muted);font-size:var(--jl-font-xs);margin-top:2px}";
|
|
3
3
|
export { jl_table_default as default };
|
|
@@ -104,7 +104,10 @@ export declare class JlTable<Row extends object = TableRow, Extra extends string
|
|
|
104
104
|
}>>;
|
|
105
105
|
private readonly _source;
|
|
106
106
|
private readonly _pending;
|
|
107
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* The rows as drawn in the order of `rows` (the rows and their checkboxes carry their place), by key, and their
|
|
109
|
+
* keys in the order shown; the keys each state was last drawn for, so a change redraws only the rows it concerns.
|
|
110
|
+
*/
|
|
108
111
|
private readonly _view;
|
|
109
112
|
private readonly _refs;
|
|
110
113
|
/** Draws what an open row shows under it, from the row: `(row) => <JlFacts items={…} />`. */
|
|
@@ -132,26 +135,35 @@ export declare class JlTable<Row extends object = TableRow, Extra extends string
|
|
|
132
135
|
private span;
|
|
133
136
|
private renderHead;
|
|
134
137
|
private headerCell;
|
|
135
|
-
/** The arrows and `aria-sort` of the headings, changed in place so a pressed heading keeps the focus. */
|
|
138
|
+
/** The arrows and `aria-sort` of the sortable headings, changed in place so a pressed heading keeps the focus. */
|
|
136
139
|
private renderSortState;
|
|
137
|
-
|
|
140
|
+
/** The drawn rows in the order of the sort; each row's sort value is read once, not at every comparison. */
|
|
141
|
+
private sortedView;
|
|
138
142
|
private renderBody;
|
|
143
|
+
/** New rows, which show no state yet: the flush draws the selection, the marks and the open rows on them. */
|
|
139
144
|
private setView;
|
|
145
|
+
/** The rows in the order of the sort, whose keys the select-all box goes by from now on. */
|
|
146
|
+
private placeInOrder;
|
|
147
|
+
/** Moves the rows into the order of the sort, each open row's detail with it: no row is drawn again. */
|
|
148
|
+
private renderOrder;
|
|
140
149
|
private bodyRow;
|
|
141
150
|
/** A cell's value, drawn by its renderer or in its format, with the row's description under it when it has one. */
|
|
142
151
|
private cell;
|
|
143
152
|
private cellValue;
|
|
144
153
|
private skeletonRows;
|
|
145
154
|
private emptyRow;
|
|
146
|
-
/** The rows of data, without the details under the open ones. */
|
|
147
|
-
private dataRows;
|
|
148
155
|
private keyOf;
|
|
156
|
+
/**
|
|
157
|
+
* Draws a state on the rows whose keys came into it or left it since it was last drawn: checking or opening one
|
|
158
|
+
* row changes that row alone, whatever the number of rows.
|
|
159
|
+
*/
|
|
160
|
+
private redraw;
|
|
149
161
|
/** The bar and the shade of marked rows, changed in place. */
|
|
150
162
|
private renderMarks;
|
|
151
163
|
/** The details of the open rows, added under them and taken away in place: one that stays open keeps its content. */
|
|
152
164
|
private renderExpansion;
|
|
153
165
|
private renderRowOpen;
|
|
154
166
|
private detailRow;
|
|
155
|
-
/** The checkboxes
|
|
167
|
+
/** The checkboxes of the rows whose selection changed, and the select-all box. */
|
|
156
168
|
private renderSelection;
|
|
157
169
|
}
|
|
@@ -3,7 +3,7 @@ import { BASE_STYLES } from "../styles/shared.js";
|
|
|
3
3
|
import { JlElement } from "../base/jl-element.js";
|
|
4
4
|
import { jsonOf, oneOf, textOf } from "../lib/attributes.js";
|
|
5
5
|
import { registerIcons } from "../lib/icons.js";
|
|
6
|
-
import { columnAlign, columnWidth, fieldOf, formatCell, nextSortDirection, openRows, rowKeyOf, rowToggles, selectionState,
|
|
6
|
+
import { columnAlign, columnWidth, fieldOf, formatCell, nextSortDirection, openRows, rowKeyOf, rowToggles, selectionState, sortBy, toggleAll, toggleKey, withRowOpen } from "../lib/table.js";
|
|
7
7
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
8
8
|
import { setOrRemove } from "../lib/dom.js";
|
|
9
9
|
import { JlBadge } from "../atoms/jl-badge.js";
|
|
@@ -31,7 +31,6 @@ var TABLE_EXPANSIONS = [
|
|
|
31
31
|
"multiple"
|
|
32
32
|
];
|
|
33
33
|
var MARKED_ATTRIBUTE = "data-marked";
|
|
34
|
-
var EXPANDED_ATTRIBUTE = "data-expanded";
|
|
35
34
|
var DETAIL_ID_PREFIX = "detail-";
|
|
36
35
|
var DEFAULT_ROW_KEY = "id";
|
|
37
36
|
var NO_SORT_KEY = "";
|
|
@@ -87,6 +86,17 @@ function detailOf(row) {
|
|
|
87
86
|
}
|
|
88
87
|
/** Whether a press ends a drag that selected text, which leaves the row as it was. */
|
|
89
88
|
var isSelectingText = () => (document.getSelection()?.toString() ?? "") !== "";
|
|
89
|
+
var NO_ROW_STATES = () => ({
|
|
90
|
+
marked: [],
|
|
91
|
+
open: [],
|
|
92
|
+
selected: []
|
|
93
|
+
});
|
|
94
|
+
/** Ticks or clears a row's own checkbox, whose state the row's shade follows in CSS. */
|
|
95
|
+
function checkRow(element, on) {
|
|
96
|
+
const input = element.querySelector(":scope > .select-cell .checkbox");
|
|
97
|
+
if (input !== null) input.checked = on;
|
|
98
|
+
}
|
|
99
|
+
var isOpen = (row) => row.querySelector(":scope > .expand-cell > .expand")?.getAttribute("aria-expanded") === "true";
|
|
90
100
|
/**
|
|
91
101
|
* Rows of data under column headings. `columns` say what each column shows and how (`format`: text, number, date,
|
|
92
102
|
* badge, code); `rows` are plain objects. Sortable headings cycle ascending, descending and unsorted, and sort the
|
|
@@ -115,11 +125,11 @@ var JlTable = class extends JlElement {
|
|
|
115
125
|
parse: textOf(DEFAULT_ROW_KEY)
|
|
116
126
|
});
|
|
117
127
|
/** The column the rows are sorted by. */
|
|
118
|
-
sortKey = this.useChange(NO_SORT_KEY, () => this.schedule("
|
|
128
|
+
sortKey = this.useChange(NO_SORT_KEY, () => this.schedule("order"), {
|
|
119
129
|
attribute: "sort-key",
|
|
120
130
|
parse: textOf(NO_SORT_KEY)
|
|
121
131
|
});
|
|
122
|
-
sortDirection = this.useChange(NO_SORT, () => this.schedule("
|
|
132
|
+
sortDirection = this.useChange(NO_SORT, () => this.schedule("order"), {
|
|
123
133
|
attribute: "sort-direction",
|
|
124
134
|
parse: oneOf(TABLE_SORT_DIRECTIONS, NO_SORT)
|
|
125
135
|
});
|
|
@@ -173,12 +183,18 @@ var JlTable = class extends JlElement {
|
|
|
173
183
|
_pending = {
|
|
174
184
|
body: false,
|
|
175
185
|
head: false,
|
|
186
|
+
order: false,
|
|
176
187
|
queued: false
|
|
177
188
|
};
|
|
178
|
-
/**
|
|
189
|
+
/**
|
|
190
|
+
* The rows as drawn in the order of `rows` (the rows and their checkboxes carry their place), by key, and their
|
|
191
|
+
* keys in the order shown; the keys each state was last drawn for, so a change redraws only the rows it concerns.
|
|
192
|
+
*/
|
|
179
193
|
_view = {
|
|
194
|
+
byKey: /* @__PURE__ */ new Map(),
|
|
195
|
+
drawn: [],
|
|
180
196
|
keys: [],
|
|
181
|
-
|
|
197
|
+
shown: NO_ROW_STATES()
|
|
182
198
|
};
|
|
183
199
|
_refs = this.useRefs((ref) => ({
|
|
184
200
|
body: ref("tbody"),
|
|
@@ -233,13 +249,18 @@ var JlTable = class extends JlElement {
|
|
|
233
249
|
queueMicrotask(() => this.flush());
|
|
234
250
|
}
|
|
235
251
|
flush() {
|
|
236
|
-
const { body, head } = this._pending;
|
|
237
|
-
this._pending
|
|
238
|
-
|
|
239
|
-
|
|
252
|
+
const { body, head, order } = this._pending;
|
|
253
|
+
Object.assign(this._pending, {
|
|
254
|
+
body: false,
|
|
255
|
+
head: false,
|
|
256
|
+
order: false,
|
|
257
|
+
queued: false
|
|
258
|
+
});
|
|
240
259
|
if (head) this.renderHead();
|
|
241
|
-
this.renderSortState();
|
|
260
|
+
if (head || order) this.renderSortState();
|
|
242
261
|
if (body) this.renderBody();
|
|
262
|
+
if (order && !body) this.renderOrder();
|
|
263
|
+
this.renderMarks();
|
|
243
264
|
this.renderSelection();
|
|
244
265
|
this.renderExpansion();
|
|
245
266
|
}
|
|
@@ -258,7 +279,7 @@ var JlTable = class extends JlElement {
|
|
|
258
279
|
changeSelection(input) {
|
|
259
280
|
const index = input.dataset.index;
|
|
260
281
|
const selected = this.selected.get();
|
|
261
|
-
const keys = index === void 0 ? toggleAll(this._view.keys, new Set(selected)) : toggleKey(selected, this._view.
|
|
282
|
+
const keys = index === void 0 ? toggleAll(this._view.keys, new Set(selected)) : toggleKey(selected, this._view.drawn[Number(index)]?.key ?? Number(index), input.checked);
|
|
262
283
|
this.selected.set(keys);
|
|
263
284
|
this.events.emit("selection", keys);
|
|
264
285
|
}
|
|
@@ -267,7 +288,7 @@ var JlTable = class extends JlElement {
|
|
|
267
288
|
const row = this.dataRowOf(event);
|
|
268
289
|
const key = row === void 0 ? void 0 : this.keyOf(row);
|
|
269
290
|
if (row === void 0 || key === void 0 || !this.opensOnPress(event, row)) return;
|
|
270
|
-
this.toggle(key, !row
|
|
291
|
+
this.toggle(key, !isOpen(row));
|
|
271
292
|
}
|
|
272
293
|
/** The row of data a press is on: one of the table's, not a row in the content of a detail. */
|
|
273
294
|
dataRowOf(event) {
|
|
@@ -333,45 +354,68 @@ var JlTable = class extends JlElement {
|
|
|
333
354
|
cell.style.width = columnWidth(column.width);
|
|
334
355
|
return cell;
|
|
335
356
|
}
|
|
336
|
-
/** The arrows and `aria-sort` of the headings, changed in place so a pressed heading keeps the focus. */
|
|
357
|
+
/** The arrows and `aria-sort` of the sortable headings, changed in place so a pressed heading keeps the focus. */
|
|
337
358
|
renderSortState() {
|
|
338
359
|
const sortKey = this.sortKey.get();
|
|
339
|
-
for (const cell of this._refs.head.querySelectorAll("th[data-key]")) {
|
|
360
|
+
for (const cell of this._refs.head.querySelectorAll("th[data-key]:has(> .sort)")) {
|
|
340
361
|
const direction = cell.dataset.key === sortKey ? this.sortDirection.get() : NO_SORT;
|
|
341
|
-
|
|
342
|
-
setOrRemove(cell, "aria-sort", sortable ? ARIA_SORT[direction] : "");
|
|
362
|
+
setOrRemove(cell, "aria-sort", ARIA_SORT[direction]);
|
|
343
363
|
cell.querySelector(".sort-icon")?.name.set(SORT_ICONS[direction]);
|
|
344
|
-
cell.toggleAttribute("data-sorted", direction !== NO_SORT);
|
|
345
364
|
}
|
|
346
365
|
}
|
|
347
|
-
|
|
366
|
+
/** The drawn rows in the order of the sort; each row's sort value is read once, not at every comparison. */
|
|
367
|
+
sortedView() {
|
|
348
368
|
const key = this.sortKey.get();
|
|
369
|
+
if (key === NO_SORT_KEY) return [...this._view.drawn];
|
|
349
370
|
const format = this.columns.get().find((column) => column.key === key)?.format;
|
|
350
|
-
return
|
|
371
|
+
return sortBy(this._view.drawn, ({ row }) => fieldOf(row, key), {
|
|
372
|
+
direction: this.sortDirection.get(),
|
|
373
|
+
format
|
|
374
|
+
});
|
|
351
375
|
}
|
|
352
376
|
renderBody() {
|
|
353
377
|
const columns = this.columns.get();
|
|
354
378
|
if (this.loading.get()) {
|
|
355
|
-
this.setView([]
|
|
379
|
+
this.setView([]);
|
|
356
380
|
this._refs.body.replaceChildren(...this.skeletonRows(columns));
|
|
357
381
|
return;
|
|
358
382
|
}
|
|
359
383
|
const rows = this.rows.get();
|
|
360
384
|
if (rows.length === 0) {
|
|
361
|
-
this.setView([]
|
|
385
|
+
this.setView([]);
|
|
362
386
|
this._refs.body.replaceChildren(this.emptyRow(this.span(columns)));
|
|
363
387
|
return;
|
|
364
388
|
}
|
|
365
389
|
const keyField = this.rowKey.get();
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
390
|
+
this.setView(rows.map((row, index) => ({
|
|
391
|
+
element: this.bodyRow(row, index, columns),
|
|
392
|
+
key: rowKeyOf(row, keyField, index),
|
|
393
|
+
row
|
|
394
|
+
})));
|
|
395
|
+
this._refs.body.replaceChildren(...this.placeInOrder().map(({ element }) => element));
|
|
396
|
+
}
|
|
397
|
+
/** New rows, which show no state yet: the flush draws the selection, the marks and the open rows on them. */
|
|
398
|
+
setView(drawn) {
|
|
399
|
+
this._view.drawn = drawn;
|
|
400
|
+
this._view.byKey = Map.groupBy(drawn, ({ key }) => key);
|
|
401
|
+
this._view.shown = NO_ROW_STATES();
|
|
402
|
+
}
|
|
403
|
+
/** The rows in the order of the sort, whose keys the select-all box goes by from now on. */
|
|
404
|
+
placeInOrder() {
|
|
405
|
+
const sorted = this.sortedView();
|
|
406
|
+
this._view.keys = sorted.map(({ key }) => key);
|
|
407
|
+
return sorted;
|
|
408
|
+
}
|
|
409
|
+
/** Moves the rows into the order of the sort, each open row's detail with it: no row is drawn again. */
|
|
410
|
+
renderOrder() {
|
|
411
|
+
const body = this._refs.body;
|
|
412
|
+
this.placeInOrder().flatMap(({ element }) => {
|
|
413
|
+
const detail = detailOf(element);
|
|
414
|
+
return detail === null ? [element] : [element, detail];
|
|
415
|
+
}).forEach((node, index) => {
|
|
416
|
+
const current = body.children.item(index);
|
|
417
|
+
if (current !== node) body.insertBefore(node, current);
|
|
418
|
+
});
|
|
375
419
|
}
|
|
376
420
|
bodyRow(row, index, columns) {
|
|
377
421
|
const first = columns[0];
|
|
@@ -458,33 +502,29 @@ var JlTable = class extends JlElement {
|
|
|
458
502
|
})
|
|
459
503
|
});
|
|
460
504
|
}
|
|
461
|
-
/** The rows of data, without the details under the open ones. */
|
|
462
|
-
dataRows() {
|
|
463
|
-
return [...this._refs.body.querySelectorAll(":scope > tr[data-index]")];
|
|
464
|
-
}
|
|
465
505
|
keyOf(row) {
|
|
466
|
-
return this._view.
|
|
506
|
+
return this._view.drawn[Number(row.dataset.index)]?.key;
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Draws a state on the rows whose keys came into it or left it since it was last drawn: checking or opening one
|
|
510
|
+
* row changes that row alone, whatever the number of rows.
|
|
511
|
+
*/
|
|
512
|
+
redraw(state, keys, draw) {
|
|
513
|
+
const changes = rowToggles(this._view.shown[state], keys);
|
|
514
|
+
this._view.shown[state] = keys;
|
|
515
|
+
for (const { key, open } of changes) for (const { element } of this._view.byKey.get(key) ?? []) draw(element, open);
|
|
467
516
|
}
|
|
468
517
|
/** The bar and the shade of marked rows, changed in place. */
|
|
469
518
|
renderMarks() {
|
|
470
|
-
|
|
471
|
-
for (const row of this.dataRows()) {
|
|
472
|
-
const key = this.keyOf(row);
|
|
473
|
-
row.toggleAttribute(MARKED_ATTRIBUTE, key !== void 0 && marked.has(key));
|
|
474
|
-
}
|
|
519
|
+
this.redraw("marked", this.marked.get(), (element, on) => element.toggleAttribute(MARKED_ATTRIBUTE, on));
|
|
475
520
|
}
|
|
476
521
|
/** The details of the open rows, added under them and taken away in place: one that stays open keeps its content. */
|
|
477
522
|
renderExpansion() {
|
|
478
|
-
|
|
479
|
-
for (const row of this.dataRows()) {
|
|
480
|
-
const key = this.keyOf(row);
|
|
481
|
-
this.renderRowOpen(row, key !== void 0 && open.has(key));
|
|
482
|
-
}
|
|
523
|
+
this.redraw("open", openRows(this.expanded.get(), this.expandable.get()), (element, open) => this.renderRowOpen(element, open));
|
|
483
524
|
}
|
|
484
525
|
renderRowOpen(row, open) {
|
|
485
526
|
const chevron = row.querySelector("button.expand");
|
|
486
527
|
if (chevron === null) return;
|
|
487
|
-
row.toggleAttribute(EXPANDED_ATTRIBUTE, open);
|
|
488
528
|
chevron.setAttribute("aria-expanded", String(open));
|
|
489
529
|
const detail = detailOf(row);
|
|
490
530
|
if (!open) {
|
|
@@ -498,7 +538,7 @@ var JlTable = class extends JlElement {
|
|
|
498
538
|
chevron.setAttribute("aria-controls", id);
|
|
499
539
|
}
|
|
500
540
|
detailRow(row, id) {
|
|
501
|
-
const data = this._view.
|
|
541
|
+
const data = this._view.drawn[Number(row.dataset.index)]?.row;
|
|
502
542
|
const draw = this._source.detail;
|
|
503
543
|
return /* @__PURE__ */ jsx("tr", {
|
|
504
544
|
class: "detail",
|
|
@@ -512,18 +552,12 @@ var JlTable = class extends JlElement {
|
|
|
512
552
|
})
|
|
513
553
|
});
|
|
514
554
|
}
|
|
515
|
-
/** The checkboxes
|
|
555
|
+
/** The checkboxes of the rows whose selection changed, and the select-all box. */
|
|
516
556
|
renderSelection() {
|
|
517
|
-
|
|
518
|
-
for (const input of this._refs.body.querySelectorAll(":scope > tr > .select-cell .checkbox")) {
|
|
519
|
-
const key = this._view.keys[Number(input.dataset.index)];
|
|
520
|
-
const on = key !== void 0 && selected.has(key);
|
|
521
|
-
input.checked = on;
|
|
522
|
-
input.closest("tr")?.toggleAttribute("data-selected", on);
|
|
523
|
-
}
|
|
557
|
+
this.redraw("selected", this.selected.get(), checkRow);
|
|
524
558
|
const all = this._refs.head.querySelector("input.checkbox");
|
|
525
559
|
if (all === null) return;
|
|
526
|
-
const state = selectionState(this._view.keys, selected);
|
|
560
|
+
const state = selectionState(this._view.keys, new Set(this.selected.get()));
|
|
527
561
|
all.checked = state === "all";
|
|
528
562
|
all.indeterminate = state === "some";
|
|
529
563
|
all.disabled = this._view.keys.length === 0;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/organisms/jl-tree.css?inline
|
|
2
|
-
var jl_tree_default = ":host{--indent:16px;--row-height:30px;display:block}.tree{color:var(--jl-text-2);font-size:var(--jl-font-md)}.group{position:relative}.group:before{top:0;bottom:4px;left:calc(8px + var(--level) * var(--indent) + 6.5px);background:var(--jl-line);content:\"\";width:1px;position:absolute}.item:focus-visible{box-shadow:none}.row{height:var(--row-height);padding:0 8px 0 calc(8px + var(--level) * var(--indent));border-radius:var(--jl-radius-sm);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:6px;display:flex}.row:hover{background:var(--jl-surface-2);color:var(--jl-text)}.item:focus-visible>.row{box-shadow:var(--jl-focus-ring)}.item[aria-selected=true]>.row{background:var(--jl-accent-soft);color:var(--jl-text);font-weight:600}.chevron{width:14px;color:var(--jl-faint);transition:rotate var(--jl-fast) var(--jl-ease);flex:none;justify-content:center;display:inline-flex}.item[aria-expanded=true]>.row>.chevron{rotate:90deg}.icon{color:var(--jl-muted)}.item[aria-selected=true]>.row>.icon{color:var(--jl-accent)}.label{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}a.row{color:inherit;text-decoration:none}.item.level-end>.row{color:var(--jl-muted)}.level-end[aria-disabled=true]>.row{cursor:default}.level-end[aria-disabled=true]>.row:hover{background:0 0}.spinner{color:var(--jl-muted);flex:none}.more,.retry{color:var(--jl-accent);flex:none;font-weight:500}.level-end>.row:hover .more,.level-end>.row:hover .retry{color:var(--jl-accent-strong)}.icon.error{color:var(--jl-danger)}.note{min-height:var(--row-height);padding:0 8px 0 calc(8px + var(--level) * var(--indent));color:var(--jl-muted);align-items:center;gap:6px;display:flex}.badge{color:var(--jl-faint);font-size:var(--jl-font-xs);font-variant-numeric:tabular-nums;flex:none;margin-left:auto}";
|
|
2
|
+
var jl_tree_default = ":host{--indent:16px;--row-height:30px;display:block}.tree{--level:0;color:var(--jl-text-2);font-size:var(--jl-font-md)}.group{--group-level:var(--level);position:relative}.group>*{--level:calc(var(--group-level) + 1)}.item[aria-expanded=false]>.group{display:none}.group:before{top:0;bottom:4px;left:calc(8px + var(--level) * var(--indent) + 6.5px);background:var(--jl-line);content:\"\";width:1px;position:absolute}.item:focus-visible{box-shadow:none}.row{height:var(--row-height);padding:0 8px 0 calc(8px + var(--level) * var(--indent));border-radius:var(--jl-radius-sm);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:6px;display:flex}.row:hover{background:var(--jl-surface-2);color:var(--jl-text)}.item:focus-visible>.row{box-shadow:var(--jl-focus-ring)}.item[aria-selected=true]>.row{background:var(--jl-accent-soft);color:var(--jl-text);font-weight:600}.chevron{width:14px;color:var(--jl-faint);transition:rotate var(--jl-fast) var(--jl-ease);flex:none;justify-content:center;display:inline-flex}.item[aria-expanded=true]>.row>.chevron{rotate:90deg}.icon{color:var(--jl-muted)}.item[aria-selected=true]>.row>.icon{color:var(--jl-accent)}.label{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}a.row{color:inherit;text-decoration:none}.item.level-end>.row{color:var(--jl-muted)}.level-end[aria-disabled=true]>.row{cursor:default}.level-end[aria-disabled=true]>.row:hover{background:0 0}.spinner{color:var(--jl-muted);flex:none}.more,.retry{color:var(--jl-accent);flex:none;font-weight:500}.level-end>.row:hover .more,.level-end>.row:hover .retry{color:var(--jl-accent-strong)}.icon.error{color:var(--jl-danger)}.note{min-height:var(--row-height);padding:0 8px 0 calc(8px + var(--level) * var(--indent));color:var(--jl-muted);align-items:center;gap:6px;display:flex}.badge{color:var(--jl-faint);font-size:var(--jl-font-xs);font-variant-numeric:tabular-nums;flex:none;margin-left:auto}";
|
|
3
3
|
export { jl_tree_default as default };
|
|
@@ -94,7 +94,7 @@ export declare class JlTree extends JlElement {
|
|
|
94
94
|
/** Marks the item; one that is not a link says so with `select`. */
|
|
95
95
|
private select;
|
|
96
96
|
private findItem;
|
|
97
|
-
/**
|
|
97
|
+
/** Gives an item the Tab stop, which one item holds, and the focus when asked. */
|
|
98
98
|
private moveFocus;
|
|
99
99
|
private hasFocusInside;
|
|
100
100
|
private scrollToRow;
|
|
@@ -102,6 +102,11 @@ export declare class JlTree extends JlElement {
|
|
|
102
102
|
private loadLevel;
|
|
103
103
|
private loadNextPage;
|
|
104
104
|
private addPage;
|
|
105
|
+
/**
|
|
106
|
+
* Shows the items with a page added: only the page's rows when its level is drawn, so a tree of thousands of rows
|
|
107
|
+
* is not drawn and laid out again for each page; the whole tree otherwise.
|
|
108
|
+
*/
|
|
109
|
+
private drawPage;
|
|
105
110
|
private failLevel;
|
|
106
111
|
/** The open folders whose children the loader has not given yet: their first page. */
|
|
107
112
|
private loadOpenFolders;
|
|
@@ -112,20 +117,19 @@ export declare class JlTree extends JlElement {
|
|
|
112
117
|
private hasLevelEndRow;
|
|
113
118
|
protected drawTexts(): void;
|
|
114
119
|
private errorLabel;
|
|
115
|
-
private
|
|
120
|
+
private renderItemsUnlessQuiet;
|
|
121
|
+
/** Sets `items` without drawing every row again, which its callback does on each set(), even of an equal value. */
|
|
122
|
+
private setItemsQuietly;
|
|
116
123
|
private renderItems;
|
|
117
124
|
/** Where the Tab stop goes once rows are drawn: where it was, else the selected item, else the first. */
|
|
118
125
|
private tabStop;
|
|
119
|
-
/**
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
private drawLevelEnd;
|
|
125
|
-
/** The element holding a level's rows; null when they are not drawn, or when the tree shows its empty note. */
|
|
126
|
+
/** Draws again the row that ends a level (its spinner, its error), and only it; the whole tree when it is not drawn. */
|
|
127
|
+
private redrawLevelEnd;
|
|
128
|
+
/** Draws items at the end of a drawn level, then the row that ends it again; the tree's other rows stay as they are. */
|
|
129
|
+
private appendToLevel;
|
|
130
|
+
/** The element holding a level's rows; null when they are not drawn, and for an empty tree, whose note only `renderItems` draws. */
|
|
126
131
|
private levelContainer;
|
|
127
|
-
/**
|
|
128
|
-
private levelOf;
|
|
132
|
+
/** An item's row, and its children's under a folder: the CSS indents each by its depth. */
|
|
129
133
|
private itemNode;
|
|
130
134
|
/** The row that ends a level, if it has one. */
|
|
131
135
|
private levelEndNodes;
|
|
@@ -135,11 +139,10 @@ export declare class JlTree extends JlElement {
|
|
|
135
139
|
private errorNode;
|
|
136
140
|
private noteNode;
|
|
137
141
|
private renderExpanded;
|
|
138
|
-
/** Opens or closes the groups of these rows, as `expanded` says. */
|
|
142
|
+
/** Opens or closes the groups of these rows, as `expanded` says; a folder already in that state is left alone. */
|
|
139
143
|
private drawExpanded;
|
|
140
144
|
private isVisible;
|
|
141
145
|
/** The item itself when it shows, else the nearest folder around it that does: the focus goes there. */
|
|
142
146
|
private visibleAncestor;
|
|
143
|
-
private renderSelection;
|
|
144
147
|
private drawSelection;
|
|
145
148
|
}
|