@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
|
@@ -33,14 +33,14 @@ var JlInputList = class extends JlElement {
|
|
|
33
33
|
parse: jsonOf([])
|
|
34
34
|
});
|
|
35
35
|
/** The input of each row: text, a number, a date, a link… */
|
|
36
|
-
type = this.useChange("text", () => this.
|
|
36
|
+
type = this.useChange("text", () => this.drawRows(), {
|
|
37
37
|
attribute: "type",
|
|
38
38
|
parse: oneOf(INPUT_TYPES, "text")
|
|
39
39
|
});
|
|
40
40
|
/** Each value on several lines, in a text area. */
|
|
41
|
-
multiline = this.useChange(false, () => this.
|
|
41
|
+
multiline = this.useChange(false, () => this.drawRows(), { attribute: "multiline" });
|
|
42
42
|
/** The values to pick from, each row a select; none lets people type. */
|
|
43
|
-
options = this.useChange([], () => this.
|
|
43
|
+
options = this.useChange([], () => this.drawRows(), {
|
|
44
44
|
attribute: "options",
|
|
45
45
|
parse: jsonOf([])
|
|
46
46
|
});
|
|
@@ -49,15 +49,19 @@ var JlInputList = class extends JlElement {
|
|
|
49
49
|
attribute: "max",
|
|
50
50
|
parse: clampedNumber(NO_LIMIT, NO_LIMIT, MAX_LIMIT)
|
|
51
51
|
});
|
|
52
|
-
placeholder = this.useChange("", () => this.
|
|
52
|
+
placeholder = this.useChange("", () => this.drawRows(), { attribute: "placeholder" });
|
|
53
53
|
/** The name of each row for screen readers: the field's label. */
|
|
54
|
-
label = this.useChange("", () => this.
|
|
54
|
+
label = this.useChange("", () => this.drawRows(), { attribute: "label" });
|
|
55
55
|
disabled = this.useChange(false, (value) => this.renderDisabled(value), { attribute: "disabled" });
|
|
56
56
|
/** The add button's text; jlib's own when empty. */
|
|
57
57
|
addLabel = this.useChange("", () => this.renderAdd(), { attribute: "add-label" });
|
|
58
58
|
/** The text a screen reader says for each row's remove button; jlib's own when empty. */
|
|
59
|
-
removeLabel = this.useChange("", () => this.
|
|
59
|
+
removeLabel = this.useChange("", () => this.drawRows(), { attribute: "remove-label" });
|
|
60
60
|
_state = { rows: [""] };
|
|
61
|
+
_drawn = {
|
|
62
|
+
kind: void 0,
|
|
63
|
+
rows: []
|
|
64
|
+
};
|
|
61
65
|
_refs = this.useRefs((ref) => ({
|
|
62
66
|
add: ref(".add"),
|
|
63
67
|
rows: ref(".rows")
|
|
@@ -87,20 +91,39 @@ var JlInputList = class extends JlElement {
|
|
|
87
91
|
this.renderRows();
|
|
88
92
|
}
|
|
89
93
|
drawTexts() {
|
|
90
|
-
this.
|
|
94
|
+
this.drawRows();
|
|
91
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Draws the rows as the inputs say: in place, or built again for another kind of control. Every input's callback
|
|
98
|
+
* runs as the list appears: a build in each made about ten per list.
|
|
99
|
+
*/
|
|
100
|
+
drawRows() {
|
|
101
|
+
if (this._drawn.kind !== this.rowKind()) {
|
|
102
|
+
this.renderRows();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
for (const row of this._drawn.rows) this.drawRow(row);
|
|
106
|
+
this.renderAdd();
|
|
107
|
+
}
|
|
108
|
+
/** Builds every row again, from the values in `_state`. */
|
|
92
109
|
renderRows() {
|
|
93
|
-
this.
|
|
110
|
+
this._drawn.kind = this.rowKind();
|
|
111
|
+
this._drawn.rows = this._state.rows.map((value, index) => this.row(value, index));
|
|
112
|
+
this._refs.rows.replaceChildren(...this._drawn.rows.map(({ control, remove }) => /* @__PURE__ */ jsxs("div", {
|
|
113
|
+
class: "row",
|
|
114
|
+
children: [control, remove]
|
|
115
|
+
})));
|
|
94
116
|
this.renderAdd();
|
|
95
117
|
}
|
|
118
|
+
/** The add button: its text, and hidden at `max`; the CSS hides it in a disabled list. */
|
|
96
119
|
renderAdd() {
|
|
97
120
|
const add = this._refs.add;
|
|
98
121
|
add.label.set(this.addLabel.get() || jlText("addValue"));
|
|
99
|
-
add.hidden =
|
|
122
|
+
add.hidden = !canAddRow(this._state.rows.length, this.max.get());
|
|
100
123
|
}
|
|
101
124
|
renderDisabled(disabled) {
|
|
102
125
|
this.reflect("disabled", disabled);
|
|
103
|
-
this.
|
|
126
|
+
this.drawRows();
|
|
104
127
|
}
|
|
105
128
|
row(value, index) {
|
|
106
129
|
const control = this.control(value, (text) => this.change(index, text));
|
|
@@ -108,51 +131,58 @@ var JlInputList = class extends JlElement {
|
|
|
108
131
|
class: "remove",
|
|
109
132
|
variant: "ghost",
|
|
110
133
|
size: "sm",
|
|
111
|
-
icon: "x"
|
|
112
|
-
hint: this.removeLabel.get() || jlText("removeValue")
|
|
134
|
+
icon: "x"
|
|
113
135
|
});
|
|
114
136
|
remove.events.register("press", () => this.removeRow(index));
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
137
|
+
const row = {
|
|
138
|
+
control,
|
|
139
|
+
remove
|
|
140
|
+
};
|
|
141
|
+
this.drawRow(row);
|
|
142
|
+
return row;
|
|
120
143
|
}
|
|
121
|
-
/**
|
|
122
|
-
control
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
options,
|
|
130
|
-
disabled
|
|
131
|
-
});
|
|
132
|
-
select.value.set(value);
|
|
133
|
-
select.events.register("change", onInput);
|
|
134
|
-
return select;
|
|
135
|
-
}
|
|
136
|
-
if (this.multiline.get()) {
|
|
137
|
-
const area = /* @__PURE__ */ jsx(JlTextarea, {
|
|
138
|
-
label,
|
|
139
|
-
value,
|
|
140
|
-
placeholder: this.placeholder.get(),
|
|
141
|
-
disabled,
|
|
142
|
-
autosize: true
|
|
143
|
-
});
|
|
144
|
-
area.events.register("input", onInput);
|
|
145
|
-
return area;
|
|
144
|
+
/** Gives a row the list's label, placeholder, type, options and state; the CSS shows or hides its remove button. */
|
|
145
|
+
drawRow({ control, remove }) {
|
|
146
|
+
control.label.set(this.label.get());
|
|
147
|
+
control.disabled.set(this.disabled.get());
|
|
148
|
+
remove.hint.set(this.removeLabel.get() || jlText("removeValue"));
|
|
149
|
+
if (control instanceof JlSelect) {
|
|
150
|
+
control.options.set(this.options.get());
|
|
151
|
+
return;
|
|
146
152
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
control.placeholder.set(this.placeholder.get());
|
|
154
|
+
if (control instanceof JlInput) control.type.set(this.type.get());
|
|
155
|
+
}
|
|
156
|
+
rowKind() {
|
|
157
|
+
if (this.options.get().length > 0) return "select";
|
|
158
|
+
return this.multiline.get() ? "textarea" : "input";
|
|
159
|
+
}
|
|
160
|
+
/** A row's control, of the list's kind, holding `value`; `onInput` hears it. drawRow gives it the rest. */
|
|
161
|
+
control(value, onInput) {
|
|
162
|
+
return {
|
|
163
|
+
input: () => {
|
|
164
|
+
const input = /* @__PURE__ */ jsx(JlInput, {
|
|
165
|
+
type: this.type.get(),
|
|
166
|
+
value
|
|
167
|
+
});
|
|
168
|
+
input.events.register("input", onInput);
|
|
169
|
+
return input;
|
|
170
|
+
},
|
|
171
|
+
select: () => {
|
|
172
|
+
const select = /* @__PURE__ */ jsx(JlSelect, { options: this.options.get() });
|
|
173
|
+
select.value.set(value);
|
|
174
|
+
select.events.register("change", onInput);
|
|
175
|
+
return select;
|
|
176
|
+
},
|
|
177
|
+
textarea: () => {
|
|
178
|
+
const area = /* @__PURE__ */ jsx(JlTextarea, {
|
|
179
|
+
value,
|
|
180
|
+
autosize: true
|
|
181
|
+
});
|
|
182
|
+
area.events.register("input", onInput);
|
|
183
|
+
return area;
|
|
184
|
+
}
|
|
185
|
+
}[this.rowKind()]();
|
|
156
186
|
}
|
|
157
187
|
change(index, text) {
|
|
158
188
|
this._state.rows = withRowAt(this._state.rows, index, text);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/molecules/jl-list-item.css?inline
|
|
2
|
-
var jl_list_item_default = ":host{--pad-x:16px;--pad-y:12px;display:block}.item{min-height:52px;padding:var(--pad-y) var(--pad-x);background:var(--jl-surface);color:var(--jl-text);transition:background var(--jl-fast) var(--jl-ease);align-items:center;gap:12px;display:flex;position:relative}:host(:not(:last-child)) .item{border-bottom:1px solid var(--jl-line)}:host([clickable]) .item{cursor:pointer}:host([clickable]) .item:hover{background:var(--jl-surface-2)}:host([selected]) .item,:host([selected][clickable]) .item:hover{background:var(--jl-accent-soft)}.link{z-index:1;position:absolute;inset:0}.link:focus-visible,.item:focus-visible{box-shadow:inset 0 0 0 2px color-mix(in srgb, var(--jl-brand) 55%, transparent)}.end{z-index:2;flex:none;align-items:center;gap:8px;display:flex;position:relative}.start{flex:none;align-items:center;display:inline-flex}.icon-box{border-radius:var(--jl-radius-sm);background:var(--jl-surface-3);width:32px;height:32px;color:var(--jl-text-2);justify-content:center;align-items:center;display:inline-flex}:host([selected]) .icon-box{background:color-mix(in srgb, var(--jl-accent) 14%, transparent);color:var(--jl-accent)}.text{flex:1;gap:1px;min-width:0;display:grid}.heading{font-size:var(--jl-font-md);text-overflow:ellipsis;white-space:nowrap;font-weight:600;line-height:1.4;overflow:hidden}:host([selected]) .heading{color:var(--jl-accent)}.description{color:var(--jl-muted);font-size:var(--jl-font-sm);line-height:1.45}.meta{color:var(--jl-muted);font-size:var(--jl-font-xs);font-variant-numeric:tabular-nums;white-space:nowrap;flex:none}.chevron{color:var(--jl-faint);margin-right:-4px}";
|
|
2
|
+
var jl_list_item_default = ":host{--pad-x:16px;--pad-y:12px;display:block}.item{min-height:52px;padding:var(--pad-y) var(--pad-x);background:var(--jl-surface);color:var(--jl-text);transition:background var(--jl-fast) var(--jl-ease);align-items:center;gap:12px;display:flex;position:relative}:host(:not(:last-child)) .item{border-bottom:1px solid var(--jl-line)}:host([clickable]) .item{cursor:pointer}:host([clickable]) .item:hover{background:var(--jl-surface-2)}:host([selected]) .item,:host([selected][clickable]) .item:hover{background:var(--jl-accent-soft)}.link{z-index:1;position:absolute;inset:0}.link:focus-visible,.item:focus-visible{box-shadow:inset 0 0 0 2px color-mix(in srgb, var(--jl-brand) 55%, transparent)}.end{z-index:2;flex:none;align-items:center;gap:8px;display:flex;position:relative}.start{flex:none;align-items:center;display:inline-flex}.icon-box{border-radius:var(--jl-radius-sm);background:var(--jl-surface-3);width:32px;height:32px;color:var(--jl-text-2);justify-content:center;align-items:center;display:inline-flex}:host([selected]) .icon-box{background:color-mix(in srgb, var(--jl-accent) 14%, transparent);color:var(--jl-accent)}.text{flex:1;gap:1px;min-width:0;display:grid}.heading{font-size:var(--jl-font-md);text-overflow:ellipsis;white-space:nowrap;font-weight:600;line-height:1.4;overflow:hidden}:host([selected]) .heading{color:var(--jl-accent)}.description:empty,.meta:empty{display:none}.description{color:var(--jl-muted);font-size:var(--jl-font-sm);line-height:1.45}.meta{color:var(--jl-muted);font-size:var(--jl-font-xs);font-variant-numeric:tabular-nums;white-space:nowrap;flex:none}.chevron{color:var(--jl-faint);margin-right:-4px}";
|
|
3
3
|
export { jl_list_item_default as default };
|
|
@@ -50,7 +50,9 @@ export declare class JlListItem extends JlElement {
|
|
|
50
50
|
/** An interactive row without a link fires `press`; a link row leaves the press to the link. */
|
|
51
51
|
private pressable;
|
|
52
52
|
private renderInteraction;
|
|
53
|
-
/** The
|
|
53
|
+
/** The chevron of a link row, made the first time the row is a link. */
|
|
54
|
+
private renderChevron;
|
|
55
|
+
/** The start holds an avatar when one is slotted, otherwise the icon (made the first time there is one), or nothing. */
|
|
54
56
|
private renderStart;
|
|
55
57
|
private renderEnd;
|
|
56
58
|
}
|
|
@@ -28,14 +28,12 @@ var JlListItem = class extends JlElement {
|
|
|
28
28
|
}, { attribute: "heading" });
|
|
29
29
|
description = this.useChange("", (value) => {
|
|
30
30
|
this._refs.description.textContent = value;
|
|
31
|
-
this._refs.description.hidden = value === "";
|
|
32
31
|
}, { attribute: "description" });
|
|
33
32
|
/** An icon at the start; `slot="start"` takes an avatar instead. */
|
|
34
33
|
icon = this.useChange("", () => this.renderStart(), { attribute: "icon" });
|
|
35
34
|
/** A short note at the end: a time, a count, a size. */
|
|
36
35
|
meta = this.useChange("", (value) => {
|
|
37
36
|
this._refs.meta.textContent = value;
|
|
38
|
-
this._refs.meta.hidden = value === "";
|
|
39
37
|
}, { attribute: "meta" });
|
|
40
38
|
/** Makes the row a link, named by its heading. The trailing controls stay pressable on their own. */
|
|
41
39
|
href = this.useChange("", () => this.renderInteraction(), { attribute: "href" });
|
|
@@ -47,12 +45,10 @@ var JlListItem = class extends JlElement {
|
|
|
47
45
|
this.renderInteraction();
|
|
48
46
|
}, { attribute: "selected" });
|
|
49
47
|
_refs = this.useRefs((ref) => ({
|
|
50
|
-
chevron: ref(".chevron"),
|
|
51
48
|
description: ref(".description"),
|
|
52
49
|
end: ref(".end"),
|
|
53
50
|
endSlot: ref("slot[name=\"end\"]"),
|
|
54
51
|
heading: ref(".heading"),
|
|
55
|
-
icon: ref(".icon"),
|
|
56
52
|
iconBox: ref(".icon-box"),
|
|
57
53
|
item: ref(".item"),
|
|
58
54
|
link: ref(".link"),
|
|
@@ -78,13 +74,7 @@ var JlListItem = class extends JlElement {
|
|
|
78
74
|
/* @__PURE__ */ jsxs("span", {
|
|
79
75
|
class: "start",
|
|
80
76
|
hidden: true,
|
|
81
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
82
|
-
class: "icon-box",
|
|
83
|
-
children: /* @__PURE__ */ jsx(JlIcon, {
|
|
84
|
-
class: "icon",
|
|
85
|
-
size: ICON_SIZE
|
|
86
|
-
})
|
|
87
|
-
}), /* @__PURE__ */ jsx("slot", { name: "start" })]
|
|
77
|
+
children: [/* @__PURE__ */ jsx("span", { class: "icon-box" }), /* @__PURE__ */ jsx("slot", { name: "start" })]
|
|
88
78
|
}),
|
|
89
79
|
/* @__PURE__ */ jsxs("span", {
|
|
90
80
|
class: "text",
|
|
@@ -93,24 +83,14 @@ var JlListItem = class extends JlElement {
|
|
|
93
83
|
id: "heading"
|
|
94
84
|
}), /* @__PURE__ */ jsx("span", {
|
|
95
85
|
class: "description",
|
|
96
|
-
id: "description"
|
|
97
|
-
hidden: true
|
|
86
|
+
id: "description"
|
|
98
87
|
})]
|
|
99
88
|
}),
|
|
100
|
-
/* @__PURE__ */ jsx("span", {
|
|
101
|
-
class: "meta",
|
|
102
|
-
hidden: true
|
|
103
|
-
}),
|
|
89
|
+
/* @__PURE__ */ jsx("span", { class: "meta" }),
|
|
104
90
|
/* @__PURE__ */ jsx("span", {
|
|
105
91
|
class: "end",
|
|
106
92
|
hidden: true,
|
|
107
93
|
children: /* @__PURE__ */ jsx("slot", { name: "end" })
|
|
108
|
-
}),
|
|
109
|
-
/* @__PURE__ */ jsx(JlIcon, {
|
|
110
|
-
class: "chevron",
|
|
111
|
-
name: "chevron-right",
|
|
112
|
-
size: CHEVRON_SIZE,
|
|
113
|
-
hidden: true
|
|
114
94
|
})
|
|
115
95
|
]
|
|
116
96
|
});
|
|
@@ -145,7 +125,7 @@ var JlListItem = class extends JlElement {
|
|
|
145
125
|
const selected = this.selected.get();
|
|
146
126
|
setOrRemove(link, "href", href);
|
|
147
127
|
link.hidden = href === "";
|
|
148
|
-
this.
|
|
128
|
+
this.renderChevron(href !== "");
|
|
149
129
|
this.reflect("clickable", this.interactive.get() || href !== "");
|
|
150
130
|
setOrRemove(link, "aria-current", selected ? "page" : "");
|
|
151
131
|
if (!this.pressable()) {
|
|
@@ -160,12 +140,31 @@ var JlListItem = class extends JlElement {
|
|
|
160
140
|
item.setAttribute("aria-labelledby", "heading");
|
|
161
141
|
setOrRemove(item, "aria-current", selected ? "true" : "");
|
|
162
142
|
}
|
|
163
|
-
/** The
|
|
143
|
+
/** The chevron of a link row, made the first time the row is a link. */
|
|
144
|
+
renderChevron(shown) {
|
|
145
|
+
const item = this._refs.item;
|
|
146
|
+
const chevron = item.querySelector(".chevron");
|
|
147
|
+
if (chevron !== null) {
|
|
148
|
+
chevron.hidden = !shown;
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (shown) item.append(/* @__PURE__ */ jsx(JlIcon, {
|
|
152
|
+
class: "chevron",
|
|
153
|
+
name: "chevron-right",
|
|
154
|
+
size: CHEVRON_SIZE
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
/** The start holds an avatar when one is slotted, otherwise the icon (made the first time there is one), or nothing. */
|
|
164
158
|
renderStart() {
|
|
165
159
|
const icon = this.icon.get();
|
|
166
160
|
const slotted = hasSlotted(this._refs.startSlot);
|
|
167
|
-
this._refs.
|
|
168
|
-
|
|
161
|
+
const box = this._refs.iconBox;
|
|
162
|
+
const drawn = box.querySelector(JlIcon.selector);
|
|
163
|
+
if (icon !== "") drawn === null ? box.append(/* @__PURE__ */ jsx(JlIcon, {
|
|
164
|
+
name: icon,
|
|
165
|
+
size: ICON_SIZE
|
|
166
|
+
})) : drawn.name.set(icon);
|
|
167
|
+
box.hidden = slotted || icon === "";
|
|
169
168
|
this._refs.start.hidden = !slotted && icon === "";
|
|
170
169
|
}
|
|
171
170
|
renderEnd() {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/molecules/jl-load-state.css?inline
|
|
2
|
-
var jl_load_state_default = ":host{display:block}.bones{gap:16px;padding:16px;display:grid}.bones.lines{gap:10px}.bones.cards{grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:12px;padding:0}.bone-row{align-items:center;gap:12px;display:flex}.bone-lines{flex:1;gap:6px;display:grid}.bone-card{border:1px solid var(--jl-line);border-radius:var(--jl-radius-lg);gap:8px;padding:12px;display:grid}";
|
|
2
|
+
var jl_load_state_default = ":host{display:block}:host(:not([state=error])) .error,:host(:not([state=empty])) .empty,:host(:not([state=ready])) .content{display:none}.bones{gap:16px;padding:16px;display:grid}.bones.lines{gap:10px}.bones.cards{grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:12px;padding:0}.bone-row{align-items:center;gap:12px;display:flex}.bone-lines{flex:1;gap:6px;display:grid}.bone-card{border:1px solid var(--jl-line);border-radius:var(--jl-radius-lg);gap:8px;padding:12px;display:grid}";
|
|
3
3
|
export { jl_load_state_default as default };
|
|
@@ -72,6 +72,11 @@ export declare class JlLoadState extends JlElement {
|
|
|
72
72
|
protected drawTexts(): void;
|
|
73
73
|
onConnect(): void;
|
|
74
74
|
onDisconnect(): void;
|
|
75
|
+
/** The CSS shows what the state on the host says; the skeleton waits for `delay` first. */
|
|
75
76
|
private renderState;
|
|
76
|
-
|
|
77
|
+
/** Shows the skeleton, made the first time it shows: most loads answer before it would. */
|
|
78
|
+
private showSkeleton;
|
|
79
|
+
/** A new shape or count changes a skeleton already made; one never shown stays unmade. */
|
|
80
|
+
private redrawSkeleton;
|
|
81
|
+
private drawSkeleton;
|
|
77
82
|
}
|
|
@@ -120,12 +120,12 @@ var JlLoadState = class JlLoadState extends JlElement {
|
|
|
120
120
|
parse: oneOf(LOAD_STATES, "loading")
|
|
121
121
|
});
|
|
122
122
|
/** The shape of the skeleton; slot `loading` takes one of the page's own instead. */
|
|
123
|
-
skeleton = this.useChange("rows", () => this.
|
|
123
|
+
skeleton = this.useChange("rows", () => this.redrawSkeleton(), {
|
|
124
124
|
attribute: "skeleton",
|
|
125
125
|
parse: oneOf(LOAD_SKELETONS, "rows")
|
|
126
126
|
});
|
|
127
127
|
/** How many rows, cards or lines the skeleton has. */
|
|
128
|
-
count = this.useChange(DEFAULT_COUNT, () => this.
|
|
128
|
+
count = this.useChange(DEFAULT_COUNT, () => this.redrawSkeleton(), {
|
|
129
129
|
attribute: "count",
|
|
130
130
|
parse: clampedNumber(DEFAULT_COUNT, 1, MAX_COUNT)
|
|
131
131
|
});
|
|
@@ -143,8 +143,6 @@ var JlLoadState = class JlLoadState extends JlElement {
|
|
|
143
143
|
_work = { latest: 0 };
|
|
144
144
|
_refs = this.useRefs((ref) => ({
|
|
145
145
|
bones: ref(".bones"),
|
|
146
|
-
content: ref(".content"),
|
|
147
|
-
empty: ref(".empty"),
|
|
148
146
|
error: ref(JlEmpty),
|
|
149
147
|
loading: ref(".loading"),
|
|
150
148
|
retry: ref(".retry")
|
|
@@ -199,7 +197,6 @@ var JlLoadState = class JlLoadState extends JlElement {
|
|
|
199
197
|
/* @__PURE__ */ jsx("jl-empty", {
|
|
200
198
|
class: "error",
|
|
201
199
|
icon: "circle-alert",
|
|
202
|
-
hidden: true,
|
|
203
200
|
children: /* @__PURE__ */ jsx(JlButton, {
|
|
204
201
|
class: "retry",
|
|
205
202
|
icon: "refresh"
|
|
@@ -207,12 +204,10 @@ var JlLoadState = class JlLoadState extends JlElement {
|
|
|
207
204
|
}),
|
|
208
205
|
/* @__PURE__ */ jsx("div", {
|
|
209
206
|
class: "empty",
|
|
210
|
-
hidden: true,
|
|
211
207
|
children: /* @__PURE__ */ jsx("slot", { name: "empty" })
|
|
212
208
|
}),
|
|
213
209
|
/* @__PURE__ */ jsx("div", {
|
|
214
210
|
class: "content",
|
|
215
|
-
hidden: true,
|
|
216
211
|
children: /* @__PURE__ */ jsx("slot", {})
|
|
217
212
|
})
|
|
218
213
|
]
|
|
@@ -227,8 +222,6 @@ var JlLoadState = class JlLoadState extends JlElement {
|
|
|
227
222
|
this._refs.retry.label.set(this.retryLabel.get() || jlText("retry"));
|
|
228
223
|
}
|
|
229
224
|
onConnect() {
|
|
230
|
-
this.renderSkeleton();
|
|
231
|
-
this.renderState(this.state.get());
|
|
232
225
|
this._refs.retry.events.register("press", () => {
|
|
233
226
|
this.events.emit("retry");
|
|
234
227
|
this._work.retry?.();
|
|
@@ -237,19 +230,23 @@ var JlLoadState = class JlLoadState extends JlElement {
|
|
|
237
230
|
onDisconnect() {
|
|
238
231
|
clearTimeout(this._work.timer);
|
|
239
232
|
}
|
|
233
|
+
/** The CSS shows what the state on the host says; the skeleton waits for `delay` first. */
|
|
240
234
|
renderState(state) {
|
|
241
|
-
const refs = this._refs;
|
|
242
235
|
clearTimeout(this._work.timer);
|
|
243
|
-
|
|
244
|
-
refs.error.hidden = state !== "error";
|
|
245
|
-
refs.empty.hidden = state !== "empty";
|
|
246
|
-
refs.content.hidden = state !== "ready";
|
|
236
|
+
this._refs.loading.hidden = true;
|
|
247
237
|
this.reflect("state", state);
|
|
248
|
-
if (state === "loading") this._work.timer = setTimeout(() =>
|
|
249
|
-
|
|
250
|
-
|
|
238
|
+
if (state === "loading") this._work.timer = setTimeout(() => this.showSkeleton(), this.delay.get());
|
|
239
|
+
}
|
|
240
|
+
/** Shows the skeleton, made the first time it shows: most loads answer before it would. */
|
|
241
|
+
showSkeleton() {
|
|
242
|
+
if (this._refs.bones.childElementCount === 0) this.drawSkeleton();
|
|
243
|
+
this._refs.loading.hidden = false;
|
|
244
|
+
}
|
|
245
|
+
/** A new shape or count changes a skeleton already made; one never shown stays unmade. */
|
|
246
|
+
redrawSkeleton() {
|
|
247
|
+
if (this._refs.bones.childElementCount > 0) this.drawSkeleton();
|
|
251
248
|
}
|
|
252
|
-
|
|
249
|
+
drawSkeleton() {
|
|
253
250
|
const kind = this.skeleton.get();
|
|
254
251
|
this._refs.bones.className = `bones ${kind}`;
|
|
255
252
|
this._refs.bones.replaceChildren(...SKELETONS[kind](this.count.get()));
|
|
@@ -29,6 +29,7 @@ export declare class JlMenu<Value extends string = string> extends JlElement {
|
|
|
29
29
|
set(setter: string | ((prevState: string) => string)): void;
|
|
30
30
|
}>>;
|
|
31
31
|
private readonly _state;
|
|
32
|
+
private readonly _drawn;
|
|
32
33
|
private readonly _refs;
|
|
33
34
|
/** Opens the menu and focuses its first item. */
|
|
34
35
|
show(): void;
|
|
@@ -50,7 +50,9 @@ var isTypeahead = (event) => event.key.length === 1 && event.key !== " " && !eve
|
|
|
50
50
|
var JlMenu = class extends JlElement {
|
|
51
51
|
static selector = "jl-menu";
|
|
52
52
|
events = this.useEvents();
|
|
53
|
-
items = this.useChange([], () =>
|
|
53
|
+
items = this.useChange([], () => {
|
|
54
|
+
if (this.isOpen()) this.renderItems();
|
|
55
|
+
}, {
|
|
54
56
|
attribute: "items",
|
|
55
57
|
parse: jsonOf([])
|
|
56
58
|
});
|
|
@@ -65,6 +67,7 @@ var JlMenu = class extends JlElement {
|
|
|
65
67
|
following: new AbortController(),
|
|
66
68
|
openAtPointerDown: false
|
|
67
69
|
};
|
|
70
|
+
_drawn = {};
|
|
68
71
|
_refs = this.useRefs((ref) => ({
|
|
69
72
|
menu: ref(".menu"),
|
|
70
73
|
trigger: ref("slot[name=\"trigger\"]")
|
|
@@ -175,6 +178,7 @@ var JlMenu = class extends JlElement {
|
|
|
175
178
|
open(focusFirst) {
|
|
176
179
|
const menu = this._refs.menu;
|
|
177
180
|
if (!this.isOpen()) {
|
|
181
|
+
this.renderItems();
|
|
178
182
|
menu.showPopover();
|
|
179
183
|
this.follow();
|
|
180
184
|
}
|
|
@@ -240,7 +244,10 @@ var JlMenu = class extends JlElement {
|
|
|
240
244
|
menu.ariaLabelledByElements = trigger === null ? null : [trigger];
|
|
241
245
|
}
|
|
242
246
|
renderItems() {
|
|
243
|
-
this.
|
|
247
|
+
const items = this.items.get();
|
|
248
|
+
if (items === this._drawn.items) return;
|
|
249
|
+
this._drawn.items = items;
|
|
250
|
+
this._refs.menu.replaceChildren(...sectionsOf(items).map((section) => this.section(section)));
|
|
244
251
|
}
|
|
245
252
|
section(section) {
|
|
246
253
|
const entries = section.entries.map((entry) => this.entry(entry));
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/molecules/jl-pagination.css?inline
|
|
2
|
-
var jl_pagination_default = ":host{--height:var(--jl-control-md);--font-size:var(--jl-font-sm);--entry:var(--height);--gap:4px;--min-button:26px;display:block}:host([size=sm]){--height:var(--jl-control-sm);--font-size:var(--jl-font-xs);--min-button:24px}:host([size=lg]){--height:var(--jl-control-lg);--font-size:var(--jl-font-md);--min-button:32px}@media (width<480px){:host{--entry:var(--min-button);--gap:2px}}nav{align-items:center;gap:var(--gap);display:flex}.pages{align-items:center;gap:var(--gap);padding:0;list-style:none;display:flex}.pages li{width:var(--entry);display:flex}.button{width:100%;height:var(--height);border-radius:var(--jl-radius-sm);color:var(--jl-text-2);font-size:var(--font-size);font-variant-numeric:tabular-nums;cursor:pointer;transition:background var(--jl-fast) var(--jl-ease), color var(--jl-fast) var(--jl-ease);background:0 0;border:1px solid #0000;justify-content:center;align-items:center;padding:0 2px;font-weight:600;display:inline-flex}.button:hover:not(:disabled,[aria-current]){background:var(--jl-surface-2);color:var(--jl-text)}.button:active:not(:disabled,[aria-current]){background:var(--jl-surface-3)}.previous,.next{width:calc(var(--entry) + 2px);border-color:var(--jl-line-strong);color:var(--jl-text);flex:none}.button:disabled{cursor:not-allowed;opacity:.4}.page[aria-current]{background:var(--jl-accent);color:var(--jl-on-accent);cursor:default}.pages .gap{width:calc(var(--entry) - 10px);color:var(--jl-faint);font-size:var(--font-size);-webkit-user-select:none;user-select:none;justify-content:center;align-items:flex-end;display:inline-flex}.status{min-width:72px;color:var(--jl-text-2);font-size:var(--font-size);font-variant-numeric:tabular-nums;text-align:center;white-space:nowrap;flex:none;padding:0 8px;font-weight:600}";
|
|
2
|
+
var jl_pagination_default = ":host{--height:var(--jl-control-md);--font-size:var(--jl-font-sm);--entry:var(--height);--gap:4px;--min-button:26px;display:block}:host([size=sm]){--height:var(--jl-control-sm);--font-size:var(--jl-font-xs);--min-button:24px}:host([size=lg]){--height:var(--jl-control-lg);--font-size:var(--jl-font-md);--min-button:32px}@media (width<480px){:host{--entry:var(--min-button);--gap:2px}}nav{align-items:center;gap:var(--gap);display:flex}.pages{align-items:center;gap:var(--gap);padding:0;list-style:none;display:flex}.pages li{width:var(--entry);display:flex}.button{width:100%;height:var(--height);border-radius:var(--jl-radius-sm);color:var(--jl-text-2);font-size:var(--font-size);font-variant-numeric:tabular-nums;cursor:pointer;transition:background var(--jl-fast) var(--jl-ease), color var(--jl-fast) var(--jl-ease);background:0 0;border:1px solid #0000;justify-content:center;align-items:center;padding:0 2px;font-weight:600;display:inline-flex}.button:hover:not(:disabled,[aria-current]){background:var(--jl-surface-2);color:var(--jl-text)}.button:active:not(:disabled,[aria-current]){background:var(--jl-surface-3)}.previous,.next{width:calc(var(--entry) + 2px);border-color:var(--jl-line-strong);color:var(--jl-text);flex:none}.button:disabled{cursor:not-allowed;opacity:.4}.page[aria-current]{background:var(--jl-accent);color:var(--jl-on-accent);cursor:default}.pages .gap{width:calc(var(--entry) - 10px);color:var(--jl-faint);font-size:var(--font-size);-webkit-user-select:none;user-select:none;justify-content:center;align-items:flex-end;display:inline-flex}.status{min-width:72px;color:var(--jl-text-2);font-size:var(--font-size);font-variant-numeric:tabular-nums;text-align:center;white-space:nowrap;flex:none;padding:0 8px;font-weight:600}:host([compact]) .pages,:host(:not([compact])) .status{display:none}jl-icon{--icon-size:16px}:host([size=sm]) jl-icon{--icon-size:14px}:host([size=lg]) jl-icon{--icon-size:18px}";
|
|
3
3
|
export { jl_pagination_default as default };
|
|
@@ -51,8 +51,14 @@ export declare class JlPagination extends JlElement {
|
|
|
51
51
|
onConnect(): void;
|
|
52
52
|
/** The current page, kept within the pages there are. */
|
|
53
53
|
private currentPage;
|
|
54
|
+
/** The CSS shows the list, or "3 of 12" when `compact`: only the one shown is drawn. */
|
|
54
55
|
private render;
|
|
55
|
-
|
|
56
|
+
/**
|
|
57
|
+
* The list's entry at a place, made only when the place has none or one of the other kind (a gap, a page): the list
|
|
58
|
+
* keeps its length from page to page, so stepping through changes the buttons' numbers, not the buttons.
|
|
59
|
+
*/
|
|
60
|
+
private entryAt;
|
|
61
|
+
private renderPageButton;
|
|
56
62
|
private renderSize;
|
|
57
63
|
/** Goes one page back or forward from an arrow; at an end, the focus moves to the other arrow. */
|
|
58
64
|
private step;
|
|
@@ -5,6 +5,7 @@ import { clampedNumber, oneOf } from "../lib/attributes.js";
|
|
|
5
5
|
import { registerIcons } from "../lib/icons.js";
|
|
6
6
|
import { CONTROL_SIZES } from "../lib/options.js";
|
|
7
7
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
8
|
+
import { setOrRemove } from "../lib/dom.js";
|
|
8
9
|
import { clampPage, pageItems } from "../lib/pagination.js";
|
|
9
10
|
import jl_pagination_default from "./jl-pagination.css.js";
|
|
10
11
|
import { css } from "@jadis/core";
|
|
@@ -15,11 +16,6 @@ registerIcons({
|
|
|
15
16
|
"chevron-left": ChevronLeft,
|
|
16
17
|
"chevron-right": ChevronRight
|
|
17
18
|
});
|
|
18
|
-
var ICON_SIZES = {
|
|
19
|
-
lg: 18,
|
|
20
|
-
md: 16,
|
|
21
|
-
sm: 14
|
|
22
|
-
};
|
|
23
19
|
var MAX_PAGES = Number.MAX_SAFE_INTEGER;
|
|
24
20
|
var MAX_NEIGHBOURS = 5;
|
|
25
21
|
var STEP_BACK = -1;
|
|
@@ -66,10 +62,9 @@ var JlPagination = class extends JlElement {
|
|
|
66
62
|
list: ref(".pages"),
|
|
67
63
|
nav: ref("nav"),
|
|
68
64
|
next: ref(".next"),
|
|
69
|
-
nextIcon: ref(".next jl-icon"),
|
|
70
65
|
previous: ref(".previous"),
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
statusPrefix: ref(".status-prefix"),
|
|
67
|
+
statusText: ref(".status-text")
|
|
73
68
|
}));
|
|
74
69
|
templateHtml() {
|
|
75
70
|
return /* @__PURE__ */ jsxs("nav", {
|
|
@@ -81,9 +76,9 @@ var JlPagination = class extends JlElement {
|
|
|
81
76
|
children: /* @__PURE__ */ jsx(JlIcon, { name: "chevron-left" })
|
|
82
77
|
}),
|
|
83
78
|
/* @__PURE__ */ jsx("ol", { class: "pages" }),
|
|
84
|
-
/* @__PURE__ */
|
|
79
|
+
/* @__PURE__ */ jsxs("span", {
|
|
85
80
|
class: "status",
|
|
86
|
-
|
|
81
|
+
children: [/* @__PURE__ */ jsx("span", { class: "status-prefix sr-only" }), /* @__PURE__ */ jsx("span", { class: "status-text" })]
|
|
87
82
|
}),
|
|
88
83
|
/* @__PURE__ */ jsx("button", {
|
|
89
84
|
type: "button",
|
|
@@ -120,46 +115,59 @@ var JlPagination = class extends JlElement {
|
|
|
120
115
|
currentPage() {
|
|
121
116
|
return clampPage(this.page.get(), this.pages.get());
|
|
122
117
|
}
|
|
118
|
+
/** The CSS shows the list, or "3 of 12" when `compact`: only the one shown is drawn. */
|
|
123
119
|
render() {
|
|
124
120
|
const pages = this.pages.get();
|
|
125
121
|
const page = this.currentPage();
|
|
126
|
-
const compact = this.compact.get();
|
|
127
122
|
this._refs.previous.disabled = page <= 1;
|
|
128
123
|
this._refs.next.disabled = page >= pages;
|
|
129
|
-
this.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
total: Math.max(pages, 1)
|
|
137
|
-
}));
|
|
138
|
-
if (!compact) {
|
|
139
|
-
const items = pageItems(page, pages, this.siblings.get(), this.boundaries.get());
|
|
140
|
-
this._refs.list.replaceChildren(...items.map((item) => this.entry(item, page)));
|
|
124
|
+
if (this.compact.get()) {
|
|
125
|
+
this._refs.statusPrefix.textContent = `${jlText("page")} `;
|
|
126
|
+
this._refs.statusText.textContent = jlText("pageOfTotal", {
|
|
127
|
+
page,
|
|
128
|
+
total: Math.max(pages, 1)
|
|
129
|
+
});
|
|
130
|
+
return;
|
|
141
131
|
}
|
|
132
|
+
const items = pageItems(page, pages, this.siblings.get(), this.boundaries.get());
|
|
133
|
+
items.forEach((item, index) => {
|
|
134
|
+
const entry = this.entryAt(index, item.type);
|
|
135
|
+
if (item.type === "page") this.renderPageButton(entry, item.page, page);
|
|
136
|
+
});
|
|
137
|
+
const list = this._refs.list;
|
|
138
|
+
while (list.childElementCount > items.length) list.lastElementChild?.remove();
|
|
142
139
|
}
|
|
143
|
-
|
|
144
|
-
|
|
140
|
+
/**
|
|
141
|
+
* The list's entry at a place, made only when the place has none or one of the other kind (a gap, a page): the list
|
|
142
|
+
* keeps its length from page to page, so stepping through changes the buttons' numbers, not the buttons.
|
|
143
|
+
*/
|
|
144
|
+
entryAt(index, kind) {
|
|
145
|
+
const list = this._refs.list;
|
|
146
|
+
const entry = list.children.item(index);
|
|
147
|
+
if (entry !== null && entry.classList.contains("gap") === (kind === "gap")) return entry;
|
|
148
|
+
const made = kind === "gap" ? /* @__PURE__ */ jsx("li", {
|
|
145
149
|
class: "gap",
|
|
146
150
|
"aria-hidden": "true",
|
|
147
151
|
children: "…"
|
|
148
|
-
})
|
|
149
|
-
const isCurrent = item.page === current;
|
|
150
|
-
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", {
|
|
152
|
+
}) : /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", {
|
|
151
153
|
type: "button",
|
|
152
|
-
class: "button page"
|
|
153
|
-
"data-page": item.page,
|
|
154
|
-
"aria-label": jlText("pageNumber", { page: item.page }),
|
|
155
|
-
"aria-current": isCurrent ? "page" : void 0,
|
|
156
|
-
children: String(item.page)
|
|
154
|
+
class: "button page"
|
|
157
155
|
}) });
|
|
156
|
+
entry === null ? list.append(made) : entry.replaceWith(made);
|
|
157
|
+
return made;
|
|
158
|
+
}
|
|
159
|
+
renderPageButton(entry, page, current) {
|
|
160
|
+
const button = entry.firstElementChild;
|
|
161
|
+
const text = String(page);
|
|
162
|
+
if (button.textContent !== text) {
|
|
163
|
+
button.textContent = text;
|
|
164
|
+
button.dataset.page = text;
|
|
165
|
+
}
|
|
166
|
+
button.setAttribute("aria-label", jlText("pageNumber", { page }));
|
|
167
|
+
setOrRemove(button, "aria-current", page === current ? "page" : "");
|
|
158
168
|
}
|
|
159
169
|
renderSize(size) {
|
|
160
170
|
this.reflect("size", size);
|
|
161
|
-
this._refs.previousIcon.size.set(ICON_SIZES[size]);
|
|
162
|
-
this._refs.nextIcon.size.set(ICON_SIZES[size]);
|
|
163
171
|
}
|
|
164
172
|
/** Goes one page back or forward from an arrow; at an end, the focus moves to the other arrow. */
|
|
165
173
|
step(direction) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/molecules/jl-search.css?inline
|
|
2
|
-
var jl_search_default = ":host{display:block}.lead{justify-content:center;width:16px}:host([loading]) .lead{color:var(--jl-muted)}.native::-webkit-search-cancel-button{appearance:none}.native::-webkit-search-decoration{appearance:none}.keys{flex:none;gap:3px;margin-right:-4px;display:inline-flex}.control:focus-within .keys{display:none}.key{border:1px solid var(--jl-line);border-radius:var(--jl-radius-xs);background:var(--jl-surface-2);min-width:20px;height:20px;color:var(--jl-muted);font-size:var(--jl-font-xs);border-bottom-width:2px;justify-content:center;align-items:center;padding:0 5px;font-weight:500;line-height:1;display:inline-flex}:host([size=sm]) .key{min-width:18px;height:18px;padding:0 4px}";
|
|
2
|
+
var jl_search_default = ":host{display:block}.lead{justify-content:center;width:16px}:host([loading]) .lead{color:var(--jl-muted)}:host([loading]) .icon,:host(:not([loading])) jl-spinner{display:none}.native::-webkit-search-cancel-button{appearance:none}.native::-webkit-search-decoration{appearance:none}.keys{flex:none;gap:3px;margin-right:-4px;display:inline-flex}.keys:empty,.control:focus-within .keys{display:none}.key{border:1px solid var(--jl-line);border-radius:var(--jl-radius-xs);background:var(--jl-surface-2);min-width:20px;height:20px;color:var(--jl-muted);font-size:var(--jl-font-xs);border-bottom-width:2px;justify-content:center;align-items:center;padding:0 5px;font-weight:500;line-height:1;display:inline-flex}:host([size=sm]) .key{min-width:18px;height:18px;padding:0 4px}";
|
|
3
3
|
export { jl_search_default as default };
|