@linxin666/dsh-ssh 0.3.23 → 0.3.24
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/lib/client.js +55 -11
- package/lib/client.js.map +1 -1
- package/lib/types/client/sidebar-entry-core.d.ts +32 -0
- package/package.json +2 -1
- package/src/client/sidebar-entry-core.ts +96 -12
package/lib/client.js
CHANGED
|
@@ -16218,10 +16218,12 @@ window.__ModuleLoader__.load({
|
|
|
16218
16218
|
if (nested !== null) return nested;
|
|
16219
16219
|
for (const child of root.children) if (child.tagName === "BUTTON") return child;
|
|
16220
16220
|
}
|
|
16221
|
-
/** Build the entry row (
|
|
16221
|
+
/** Build the entry row (detached; inserted once the shell is up). */
|
|
16222
16222
|
function createEntry(options) {
|
|
16223
|
-
const
|
|
16224
|
-
|
|
16223
|
+
const actions = options.actions ?? [];
|
|
16224
|
+
const composite = actions.length > 0;
|
|
16225
|
+
const entry = document.createElement(composite ? "div" : "button");
|
|
16226
|
+
if (!composite) entry.type = "button";
|
|
16225
16227
|
entry.setAttribute(options.rowAttribute, "");
|
|
16226
16228
|
if (options.plugin !== void 0) {
|
|
16227
16229
|
entry.setAttribute("data-dsh-plugin", options.plugin);
|
|
@@ -16233,17 +16235,57 @@ window.__ModuleLoader__.load({
|
|
|
16233
16235
|
const iconSpan = document.createElement("span");
|
|
16234
16236
|
iconSpan.className = options.css["entryIcon"] ?? "";
|
|
16235
16237
|
iconSpan.innerHTML = options.icon;
|
|
16236
|
-
|
|
16238
|
+
const main = composite ? document.createElement("button") : entry;
|
|
16239
|
+
if (composite) {
|
|
16240
|
+
main.type = "button";
|
|
16241
|
+
main.className = options.css["entryMain"] ?? "";
|
|
16242
|
+
main.append(iconSpan, labelSpan);
|
|
16243
|
+
entry.append(main);
|
|
16244
|
+
} else entry.append(iconSpan, labelSpan);
|
|
16245
|
+
const actionButtons = [];
|
|
16246
|
+
for (const action of actions) {
|
|
16247
|
+
const button = document.createElement("button");
|
|
16248
|
+
button.type = "button";
|
|
16249
|
+
button.className = options.css["entryAction"] ?? "";
|
|
16250
|
+
button.setAttribute("data-dsh-entry-action", action.id);
|
|
16251
|
+
button.innerHTML = action.icon;
|
|
16252
|
+
button.addEventListener("click", () => {
|
|
16253
|
+
action.onClick(button);
|
|
16254
|
+
});
|
|
16255
|
+
entry.append(button);
|
|
16256
|
+
actionButtons.push({
|
|
16257
|
+
action,
|
|
16258
|
+
button
|
|
16259
|
+
});
|
|
16260
|
+
}
|
|
16261
|
+
let open = false;
|
|
16262
|
+
const applyActions = () => {
|
|
16263
|
+
for (const { action, button } of actionButtons) {
|
|
16264
|
+
button.innerHTML = open || action.inactiveIcon === void 0 ? action.icon : action.inactiveIcon;
|
|
16265
|
+
const text = action.label(open);
|
|
16266
|
+
button.setAttribute("aria-label", text);
|
|
16267
|
+
button.setAttribute("title", text);
|
|
16268
|
+
if (action.inactiveIcon !== void 0) button.setAttribute("aria-expanded", String(open));
|
|
16269
|
+
}
|
|
16270
|
+
};
|
|
16237
16271
|
const applyLabel = () => {
|
|
16238
|
-
|
|
16239
|
-
if (options.tooltip !== void 0)
|
|
16272
|
+
main.setAttribute("aria-label", options.label());
|
|
16273
|
+
if (options.tooltip !== void 0) main.setAttribute("title", options.tooltip());
|
|
16240
16274
|
labelSpan.textContent = options.label();
|
|
16275
|
+
applyActions();
|
|
16241
16276
|
};
|
|
16242
16277
|
applyLabel();
|
|
16243
|
-
|
|
16278
|
+
main.addEventListener("click", options.onToggle);
|
|
16279
|
+
if (composite) entry.addEventListener("click", (event) => {
|
|
16280
|
+
if (event.target === entry) options.onToggle();
|
|
16281
|
+
});
|
|
16244
16282
|
return {
|
|
16245
16283
|
entry,
|
|
16246
|
-
applyLabel
|
|
16284
|
+
applyLabel,
|
|
16285
|
+
setOpen: (next) => {
|
|
16286
|
+
open = next;
|
|
16287
|
+
applyActions();
|
|
16288
|
+
}
|
|
16247
16289
|
};
|
|
16248
16290
|
}
|
|
16249
16291
|
/** Re-insert the entry after the New Session row (before the browser region). */
|
|
@@ -16267,7 +16309,7 @@ window.__ModuleLoader__.load({
|
|
|
16267
16309
|
*/
|
|
16268
16310
|
function mountSidebarEntry$1(options) {
|
|
16269
16311
|
if (typeof document !== "undefined" && document.querySelector(options.rowSelector) !== null) return () => {};
|
|
16270
|
-
const { entry, applyLabel } = createEntry(options);
|
|
16312
|
+
const { entry, applyLabel, setOpen } = createEntry(options);
|
|
16271
16313
|
let root;
|
|
16272
16314
|
let placed = false;
|
|
16273
16315
|
let unsubscribeRefresh;
|
|
@@ -16307,8 +16349,10 @@ window.__ModuleLoader__.load({
|
|
|
16307
16349
|
});
|
|
16308
16350
|
const unsubscribeActive = options.active === void 0 ? void 0 : (() => {
|
|
16309
16351
|
const syncActive = () => {
|
|
16310
|
-
|
|
16352
|
+
const open = options.active.isOpen();
|
|
16353
|
+
if (open) entry.dataset.active = "true";
|
|
16311
16354
|
else delete entry.dataset.active;
|
|
16355
|
+
setOpen(open);
|
|
16312
16356
|
};
|
|
16313
16357
|
const unsubscribe = options.active.subscribe(syncActive);
|
|
16314
16358
|
syncActive();
|
|
@@ -16366,7 +16410,7 @@ window.__ModuleLoader__.load({
|
|
|
16366
16410
|
/** The building package's version, when the bundle carries it. */
|
|
16367
16411
|
function bakedVersion() {
|
|
16368
16412
|
try {
|
|
16369
|
-
return "0.3.
|
|
16413
|
+
return "0.3.24";
|
|
16370
16414
|
} catch {
|
|
16371
16415
|
return;
|
|
16372
16416
|
}
|