@qzsy/dsh-workspace-combobox 0.2.1 → 0.2.2
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/README.md +1 -1
- package/dist/client.js +7 -25
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/client.js
CHANGED
|
@@ -546,7 +546,7 @@ window.__ModuleLoader__.load({
|
|
|
546
546
|
* trigger chip and hands over open/close state, the anchor, and the
|
|
547
547
|
* selection; this panel adds pinyin-aware search over names and paths.
|
|
548
548
|
*/
|
|
549
|
-
function HeroWorkspaceCombobox({ open, anchorRef, selectedId, onPick, onClose, actions, getHome, shortcutLabel,
|
|
549
|
+
function HeroWorkspaceCombobox({ open, anchorRef, selectedId, onPick, onClose, actions, getHome, shortcutLabel, useWorkspaces, useSessions, t }) {
|
|
550
550
|
const home = typeof getHome === 'function' ? getHome() : '';
|
|
551
551
|
const rows = useWorkspaceRows(useWorkspaces, useSessions, home, false);
|
|
552
552
|
const [query, setQuery] = useState('');
|
|
@@ -559,9 +559,7 @@ window.__ModuleLoader__.load({
|
|
|
559
559
|
const items = useWorkspaceSearch(rows, query);
|
|
560
560
|
const selectedRow = selectedId === undefined || selectedId === null ? undefined : rows.find((row) => String(row.id) === String(selectedId));
|
|
561
561
|
const selectedPath = selectedRow === undefined ? '' : String(selectedRow.path ?? '');
|
|
562
|
-
|
|
563
|
-
if (selection !== undefined && typeof selection.set === 'function') selection.set(selectedPath);
|
|
564
|
-
}, [selection, selectedPath]);
|
|
562
|
+
const branch = selectedPath.length === 0 ? null : h(BranchSelector, { path: selectedPath, t });
|
|
565
563
|
|
|
566
564
|
useEffect(() => {
|
|
567
565
|
if (!open) return undefined;
|
|
@@ -646,7 +644,7 @@ window.__ModuleLoader__.load({
|
|
|
646
644
|
.finally(() => setAdding(false));
|
|
647
645
|
};
|
|
648
646
|
|
|
649
|
-
if (!open || position === null) return
|
|
647
|
+
if (!open || position === null) return branch;
|
|
650
648
|
const activeOption = items.length === 0 ? undefined : Math.min(Math.max(activeIndex, 0), items.length - 1);
|
|
651
649
|
const panel = h('div', {
|
|
652
650
|
className: 'wsc-card wsc-heroCard',
|
|
@@ -698,8 +696,8 @@ window.__ModuleLoader__.load({
|
|
|
698
696
|
);
|
|
699
697
|
// The shipped picker portals its menu out of the Hero tree; mirror that so
|
|
700
698
|
// no transformed or clipped ancestor can displace the panel.
|
|
701
|
-
if (createPortal !== null && typeof document !== 'undefined') return createPortal(panel, document.body);
|
|
702
|
-
return panel;
|
|
699
|
+
if (createPortal !== null && typeof document !== 'undefined') return h(React.Fragment, null, branch, createPortal(panel, document.body));
|
|
700
|
+
return h(React.Fragment, null, branch, panel);
|
|
703
701
|
}
|
|
704
702
|
|
|
705
703
|
//#region git branch
|
|
@@ -747,8 +745,8 @@ window.__ModuleLoader__.load({
|
|
|
747
745
|
return body.value === null || typeof body.value !== 'object' ? {} : body.value;
|
|
748
746
|
}
|
|
749
747
|
|
|
750
|
-
function BranchSelector({
|
|
751
|
-
const path =
|
|
748
|
+
function BranchSelector({ path: activePath, t }) {
|
|
749
|
+
const path = typeof activePath === 'string' ? activePath : '';
|
|
752
750
|
const [status, setStatus] = useState(null);
|
|
753
751
|
const [loading, setLoading] = useState(false);
|
|
754
752
|
const [open, setOpen] = useState(false);
|
|
@@ -1169,7 +1167,6 @@ window.__ModuleLoader__.load({
|
|
|
1169
1167
|
ctx.effect(() => installStyles(), 'workspace-combobox: styles');
|
|
1170
1168
|
const t = ctx.locale.bind(NS);
|
|
1171
1169
|
const store = createStore({ open: false });
|
|
1172
|
-
const selectedPathStore = createPathStore();
|
|
1173
1170
|
const workspaces = ctx.get('workspaces');
|
|
1174
1171
|
const uiWorkspace = ctx.get('uiWorkspace');
|
|
1175
1172
|
const remote = ctx.get('remote');
|
|
@@ -1231,7 +1228,6 @@ window.__ModuleLoader__.load({
|
|
|
1231
1228
|
createWorkspace: actions.createWorkspace
|
|
1232
1229
|
},
|
|
1233
1230
|
getHome,
|
|
1234
|
-
selection: selectedPathStore,
|
|
1235
1231
|
shortcutLabel
|
|
1236
1232
|
})
|
|
1237
1233
|
}, HeroWorkspaceCombobox);
|
|
@@ -1240,20 +1236,6 @@ window.__ModuleLoader__.load({
|
|
|
1240
1236
|
return () => {};
|
|
1241
1237
|
}
|
|
1242
1238
|
});
|
|
1243
|
-
ctx.slots.inject('conversation.hero.options', () => {
|
|
1244
|
-
try {
|
|
1245
|
-
return ctx.slots.register({
|
|
1246
|
-
name: 'conversation.hero.options',
|
|
1247
|
-
id: 'workspace-combobox.branch',
|
|
1248
|
-
order: 20,
|
|
1249
|
-
locale: NS,
|
|
1250
|
-
inject: () => ({ selection: selectedPathStore })
|
|
1251
|
-
}, BranchSelector);
|
|
1252
|
-
} catch (error) {
|
|
1253
|
-
console.warn('workspace combobox: branch selector registration failed', error);
|
|
1254
|
-
return () => {};
|
|
1255
|
-
}
|
|
1256
|
-
});
|
|
1257
1239
|
}
|
|
1258
1240
|
//#endregion
|
|
1259
1241
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qzsy/dsh-workspace-combobox",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Pinyin-aware workspace combobox for the New Session picker, plus a Git branch picker with local/remote branch switching and a Ctrl+. frame-wide workspace switcher.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|