@michengai/dsh-codex-ui 0.2.54 → 0.2.55

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.
Files changed (2) hide show
  1. package/dist/client.js +73 -49
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -4246,19 +4246,19 @@ header [data-dcu-title-folder] svg,header [data-dcu-title-more] svg{display:bloc
4246
4246
  //#region src/client/TurnNavigator.tsx
4247
4247
  const stylesheet = `
4248
4248
  .dcu-turn-navigator{position:fixed;z-index:20;top:50%;left:var(--dcu-turn-left,288px);transform:translateY(-50%);width:16px;max-height:calc(100vh - 120px);overflow:visible;pointer-events:none}
4249
- .dcu-turn-list{display:grid;gap:2px;margin:0;padding:4px 0;list-style:none;max-height:inherit;overflow-y:auto;scrollbar-width:none;width:min(296px,calc(100vw - 64px));pointer-events:none}
4250
- .dcu-turn-list::-webkit-scrollbar{display:none}
4249
+ .dcu-turn-scroll{width:16px;max-height:inherit;overflow-x:hidden;overflow-y:auto;scrollbar-width:none;pointer-events:none}
4250
+ .dcu-turn-scroll::-webkit-scrollbar{display:none}
4251
+ .dcu-turn-list{display:grid;gap:2px;margin:0;padding:4px 0;list-style:none;width:16px;pointer-events:none}
4251
4252
  .dcu-turn-link{pointer-events:auto;position:relative;display:flex;align-items:center;width:16px;height:8px;overflow:visible;padding:0;border:0;border-radius:4px;background:transparent;color:var(--dsw-alias-label-tertiary);font:13px/18px var(--dsw-font-family);text-align:left;cursor:pointer;transition:color 320ms cubic-bezier(.16,1,.3,1)}
4252
4253
  .dcu-turn-link::before{width:var(--dcu-tick-w,5px);height:var(--dcu-tick-h,1px);flex:0 0 var(--dcu-tick-w,5px);border-radius:1px;background:currentcolor;content:'';transition:width 360ms cubic-bezier(.16,1,.3,1),height 360ms cubic-bezier(.16,1,.3,1),flex-basis 360ms cubic-bezier(.16,1,.3,1),background-color 320ms cubic-bezier(.16,1,.3,1)}
4253
- .dcu-turn-summary{position:absolute;left:16px;top:50%;transform:translateY(-50%);box-sizing:border-box;width:max-content;max-width:240px;height:32px;padding:0 12px;border-radius:16px;background:var(--dsw-alias-button-floating-hover,#3a3d3c);color:var(--dsw-alias-label-primary);box-shadow:none;opacity:0;pointer-events:none;z-index:2;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;line-height:32px;transition:opacity 220ms cubic-bezier(.16,1,.3,1)}
4254
+ .dcu-turn-summary{position:absolute;left:16px;top:var(--dcu-summary-top,50%);transform:translateY(-50%);box-sizing:border-box;width:max-content;max-width:240px;height:32px;padding:0 12px;border-radius:16px;background:#3a3d3c;color:#e8ebe9;box-shadow:0 8px 24px rgba(0,0,0,.28);pointer-events:none;z-index:2;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;line-height:32px}
4254
4255
  .dcu-turn-link[data-active=true]{color:var(--dsw-alias-label-primary)}
4255
- .dcu-turn-link[data-active=true] .dcu-turn-summary{opacity:1}
4256
4256
  .dcu-turn-link[aria-current=true]{color:var(--dsw-alias-label-primary)}
4257
4257
  .dcu-turn-link[aria-current=true]::before{width:var(--dcu-tick-w,5px);flex-basis:var(--dcu-tick-w,5px);height:var(--dcu-tick-h,1px)}
4258
4258
  .dcu-turn-navigator[data-hovering=true] .dcu-turn-link[aria-current=true]{color:var(--dsw-alias-label-tertiary)}
4259
4259
  .dcu-turn-navigator[data-hovering=true] .dcu-turn-link[data-active=true]{color:var(--dsw-alias-label-primary)}
4260
4260
  .dcu-turn-link:focus-visible{outline:0;box-shadow:0 0 0 2px var(--dsw-alias-button-info-fill)}
4261
- @media (prefers-reduced-motion:reduce){.dcu-turn-link,.dcu-turn-link::before,.dcu-turn-summary{transition:none}}
4261
+ @media (prefers-reduced-motion:reduce){.dcu-turn-link,.dcu-turn-link::before{transition:none}}
4262
4262
  @media (max-width:760px){.dcu-turn-summary{max-width:200px}}
4263
4263
  `;
4264
4264
  function tickMarkSize(index, hoverAt, _isCurrent) {
@@ -4320,8 +4320,12 @@ header [data-dcu-title-folder] svg,header [data-dcu-title-more] svg{display:bloc
4320
4320
  const [current, setCurrent] = (0, react.useState)(turns[0]?.key ?? null);
4321
4321
  const [hoverAt, setHoverAt] = (0, react.useState)(null);
4322
4322
  const [railLeft, setRailLeft] = (0, react.useState)(288);
4323
+ const [summaryTop, setSummaryTop] = (0, react.useState)(0);
4324
+ const navRef = (0, react.useRef)(null);
4325
+ const listRef = (0, react.useRef)(null);
4323
4326
  const turnKeys = (0, react.useMemo)(() => turns.map((turn) => turn.key).join("|"), [turns]);
4324
4327
  const activeIndex = hoverAt === null ? -1 : Math.max(0, Math.min(turns.length - 1, Math.round(hoverAt)));
4328
+ const activeTurn = activeIndex >= 0 ? turns[activeIndex] : void 0;
4325
4329
  (0, react.useEffect)(() => {
4326
4330
  const sidebar = document.querySelector(".dcu-root");
4327
4331
  const update = () => {
@@ -4363,63 +4367,83 @@ header [data-dcu-title-folder] svg,header [data-dcu-title-more] svg{display:bloc
4363
4367
  if (frame !== null) window.cancelAnimationFrame(frame);
4364
4368
  };
4365
4369
  }, [turnKeys, turns]);
4370
+ (0, react.useEffect)(() => {
4371
+ const nav = navRef.current;
4372
+ const list = listRef.current;
4373
+ if (nav === null || list === null || activeIndex < 0) return;
4374
+ const button = list.querySelectorAll(".dcu-turn-link")[activeIndex];
4375
+ if (button === void 0) return;
4376
+ const next = Math.round(button.getBoundingClientRect().top + button.getBoundingClientRect().height / 2 - nav.getBoundingClientRect().top);
4377
+ setSummaryTop((previous) => previous === next ? previous : next);
4378
+ }, [activeIndex, turns.length]);
4366
4379
  if (turns.length === 0) return null;
4367
4380
  const moveHover = (event) => {
4368
4381
  setHoverAt(hoverIndexFromPoint(event.currentTarget, event.clientY, turns.length));
4369
4382
  };
4370
- const style = { "--dcu-turn-left": `${railLeft}px` };
4383
+ const style = {
4384
+ "--dcu-turn-left": `${railLeft}px`,
4385
+ "--dcu-summary-top": `${summaryTop}px`
4386
+ };
4371
4387
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("nav", {
4388
+ ref: navRef,
4372
4389
  className: "dcu-turn-navigator",
4373
4390
  "data-hovering": hoverAt !== null || void 0,
4374
4391
  "aria-label": t("turns.label"),
4375
4392
  style,
4376
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: stylesheet }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ol", {
4377
- className: "dcu-turn-list",
4378
- onMouseMove: moveHover,
4379
- onMouseLeave: () => {
4380
- setHoverAt(null);
4381
- },
4382
- children: turns.map((turn, index) => {
4383
- const mark = tickMarkSize(index, hoverAt, current === turn.key);
4384
- const active = hoverAt !== null && index === activeIndex;
4385
- const tickStyle = hoverAt === null ? void 0 : {
4386
- "--dcu-tick-w": `${mark.width}px`,
4387
- "--dcu-tick-h": `${mark.height}px`
4388
- };
4389
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4390
- type: "button",
4391
- className: "dcu-turn-link",
4392
- "data-active": active || void 0,
4393
- "aria-current": current === turn.key || void 0,
4394
- "aria-label": t("turns.jump", {
4395
- index: index + 1,
4396
- summary: turn.summary
4397
- }),
4398
- title: turn.summary,
4399
- style: tickStyle,
4400
- onFocus: () => {
4401
- setHoverAt(index);
4402
- },
4403
- onBlur: () => {
4393
+ children: [
4394
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: stylesheet }),
4395
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4396
+ className: "dcu-turn-scroll",
4397
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ol", {
4398
+ ref: listRef,
4399
+ className: "dcu-turn-list",
4400
+ onMouseMove: moveHover,
4401
+ onMouseLeave: () => {
4404
4402
  setHoverAt(null);
4405
4403
  },
4406
- onClick: () => {
4407
- const host = conversationScrollRoot();
4408
- const anchor = host === null ? null : conversationAnchor(host, turn.key);
4409
- if (host === null || anchor === null) return;
4410
- const reduceMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? false;
4411
- host.scrollTo({
4412
- top: host.scrollTop + anchor.getBoundingClientRect().top - host.getBoundingClientRect().top - 12,
4413
- behavior: reduceMotion ? "auto" : "smooth"
4414
- });
4415
- },
4416
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4417
- className: "dcu-turn-summary",
4418
- children: turn.summary
4404
+ children: turns.map((turn, index) => {
4405
+ const mark = tickMarkSize(index, hoverAt, current === turn.key);
4406
+ const active = hoverAt !== null && index === activeIndex;
4407
+ const tickStyle = hoverAt === null ? void 0 : {
4408
+ "--dcu-tick-w": `${mark.width}px`,
4409
+ "--dcu-tick-h": `${mark.height}px`
4410
+ };
4411
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4412
+ type: "button",
4413
+ className: "dcu-turn-link",
4414
+ "data-active": active || void 0,
4415
+ "aria-current": current === turn.key || void 0,
4416
+ "aria-label": t("turns.jump", {
4417
+ index: index + 1,
4418
+ summary: turn.summary
4419
+ }),
4420
+ title: turn.summary,
4421
+ style: tickStyle,
4422
+ onFocus: () => {
4423
+ setHoverAt(index);
4424
+ },
4425
+ onBlur: () => {
4426
+ setHoverAt(null);
4427
+ },
4428
+ onClick: () => {
4429
+ const host = conversationScrollRoot();
4430
+ const anchor = host === null ? null : conversationAnchor(host, turn.key);
4431
+ if (host === null || anchor === null) return;
4432
+ const reduceMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? false;
4433
+ host.scrollTo({
4434
+ top: host.scrollTop + anchor.getBoundingClientRect().top - host.getBoundingClientRect().top - 12,
4435
+ behavior: reduceMotion ? "auto" : "smooth"
4436
+ });
4437
+ }
4438
+ }) }, turn.key);
4419
4439
  })
4420
- }) }, turn.key);
4440
+ })
4441
+ }),
4442
+ activeTurn !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4443
+ className: "dcu-turn-summary",
4444
+ children: activeTurn.summary
4421
4445
  })
4422
- })]
4446
+ ]
4423
4447
  });
4424
4448
  }
4425
4449
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michengai/dsh-codex-ui",
3
- "version": "0.2.54",
3
+ "version": "0.2.55",
4
4
  "description": "以 Codex 风格重构 DSH Web 侧栏的独立客户端插件",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {