dsh-mega-chat-nav 0.1.1

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 (192) hide show
  1. package/LICENSE +201 -0
  2. package/README.en.md +149 -0
  3. package/README.md +149 -0
  4. package/cordis.patch.yml +4 -0
  5. package/lib/client/NavOverlay.js +35 -0
  6. package/lib/client/NavRail.js +12 -0
  7. package/lib/client/QuestionNavSettingsTab.js +26 -0
  8. package/lib/client/QuestionNavStrip.js +555 -0
  9. package/lib/client/components/ConfigPanel.js +14 -0
  10. package/lib/client/components/DotRail.js +62 -0
  11. package/lib/client/components/NavOverlay.js +121 -0
  12. package/lib/client/components/NavRail.js +97 -0
  13. package/lib/client/components/RailDispatch.js +22 -0
  14. package/lib/client/components/RailHost.js +79 -0
  15. package/lib/client/components/SearchBox.js +66 -0
  16. package/lib/client/components/SettingsPage.js +46 -0
  17. package/lib/client/components/StandaloneSettings.js +16 -0
  18. package/lib/client/components/codex/CodexRail.js +139 -0
  19. package/lib/client/components/deepseek/DeepseekRail.js +264 -0
  20. package/lib/client/components/minimal/MinimalRail.js +135 -0
  21. package/lib/client/components/minimal/cards.js +32 -0
  22. package/lib/client/components/minimal/dot.js +11 -0
  23. package/lib/client/components/minimal/hint.js +30 -0
  24. package/lib/client/components/minimal/paging.js +5 -0
  25. package/lib/client/components/minimal/quick-settings.js +28 -0
  26. package/lib/client/components/minimal/search.js +67 -0
  27. package/lib/client/components/minimal/useRail.js +716 -0
  28. package/lib/client/components/rail/cards.js +32 -0
  29. package/lib/client/components/rail/hint.js +30 -0
  30. package/lib/client/components/rail/paging.js +5 -0
  31. package/lib/client/components/rail/quick-settings.js +28 -0
  32. package/lib/client/components/rail/search.js +76 -0
  33. package/lib/client/components/rail/useRail.js +845 -0
  34. package/lib/client/components/settings/SettingsPage.js +46 -0
  35. package/lib/client/components/settings/SettingsTab.js +17 -0
  36. package/lib/client/components/settings/StandaloneSettings.js +16 -0
  37. package/lib/client/components/shared/Cascade.js +26 -0
  38. package/lib/client/components/shared/ConfigPanel.js +27 -0
  39. package/lib/client/components/shared/Dot.js +8 -0
  40. package/lib/client/components/shared/Hint.js +5 -0
  41. package/lib/client/components/shared/PagingButton.js +5 -0
  42. package/lib/client/components/shared/RailShell.js +78 -0
  43. package/lib/client/components/shared/SearchBox.js +63 -0
  44. package/lib/client/components/shared/hooks.js +427 -0
  45. package/lib/client/components/shared/types.js +1 -0
  46. package/lib/client/config.js +1 -0
  47. package/lib/client/engines/jump.js +34 -0
  48. package/lib/client/engines/useAtBottom.js +25 -0
  49. package/lib/client/engines/useJump.js +40 -0
  50. package/lib/client/engines/useScrollSpy.js +88 -0
  51. package/lib/client/hooks.js +11 -0
  52. package/lib/client/index.js +312 -0
  53. package/lib/client/jump.js +255 -0
  54. package/lib/client/locales.js +142 -0
  55. package/lib/client/pure.js +61 -0
  56. package/lib/client/settings.js +369 -0
  57. package/lib/client/virtual/VirtualList.js +21 -0
  58. package/lib/client.js +3213 -0
  59. package/lib/compat.js +145 -0
  60. package/lib/config.js +37 -0
  61. package/lib/core/active-dot.js +17 -0
  62. package/lib/core/align.js +9 -0
  63. package/lib/core/config.js +37 -0
  64. package/lib/core/focus.js +38 -0
  65. package/lib/core/jump.js +98 -0
  66. package/lib/core/logic/active-dot.js +16 -0
  67. package/lib/core/logic/focus.js +34 -0
  68. package/lib/core/logic/jump.js +188 -0
  69. package/lib/core/logic/nodes.js +59 -0
  70. package/lib/core/model/nav-item.js +1 -0
  71. package/lib/core/model/turns.js +73 -0
  72. package/lib/core/nav-item.js +1 -0
  73. package/lib/core/nodes.js +57 -0
  74. package/lib/core/page-size.js +7 -0
  75. package/lib/core/question-entry.js +1 -0
  76. package/lib/core/time.js +23 -0
  77. package/lib/core/turn-dots.js +85 -0
  78. package/lib/core/utils/measure.js +24 -0
  79. package/lib/core/utils/time.js +26 -0
  80. package/lib/index.js +64 -0
  81. package/lib/nav-item.js +1 -0
  82. package/lib/nodes.js +59 -0
  83. package/lib/projection.js +126 -0
  84. package/lib/schema.js +26 -0
  85. package/lib/search.js +285 -0
  86. package/lib/settings.js +89 -0
  87. package/lib/types/client/NavOverlay.d.ts +18 -0
  88. package/lib/types/client/NavRail.d.ts +7 -0
  89. package/lib/types/client/QuestionNavSettingsTab.d.ts +16 -0
  90. package/lib/types/client/QuestionNavStrip.d.ts +48 -0
  91. package/lib/types/client/components/ConfigPanel.d.ts +14 -0
  92. package/lib/types/client/components/DotRail.d.ts +15 -0
  93. package/lib/types/client/components/NavOverlay.d.ts +30 -0
  94. package/lib/types/client/components/NavRail.d.ts +16 -0
  95. package/lib/types/client/components/RailDispatch.d.ts +8 -0
  96. package/lib/types/client/components/RailHost.d.ts +27 -0
  97. package/lib/types/client/components/SearchBox.d.ts +9 -0
  98. package/lib/types/client/components/SettingsPage.d.ts +9 -0
  99. package/lib/types/client/components/StandaloneSettings.d.ts +13 -0
  100. package/lib/types/client/components/codex/CodexRail.d.ts +3 -0
  101. package/lib/types/client/components/deepseek/DeepseekRail.d.ts +3 -0
  102. package/lib/types/client/components/minimal/MinimalRail.d.ts +8 -0
  103. package/lib/types/client/components/minimal/cards.d.ts +19 -0
  104. package/lib/types/client/components/minimal/dot.d.ts +14 -0
  105. package/lib/types/client/components/minimal/hint.d.ts +11 -0
  106. package/lib/types/client/components/minimal/paging.d.ts +10 -0
  107. package/lib/types/client/components/minimal/quick-settings.d.ts +8 -0
  108. package/lib/types/client/components/minimal/search.d.ts +27 -0
  109. package/lib/types/client/components/minimal/useRail.d.ts +90 -0
  110. package/lib/types/client/components/rail/cards.d.ts +19 -0
  111. package/lib/types/client/components/rail/hint.d.ts +11 -0
  112. package/lib/types/client/components/rail/paging.d.ts +10 -0
  113. package/lib/types/client/components/rail/quick-settings.d.ts +8 -0
  114. package/lib/types/client/components/rail/search.d.ts +34 -0
  115. package/lib/types/client/components/rail/useRail.d.ts +132 -0
  116. package/lib/types/client/components/settings/SettingsPage.d.ts +9 -0
  117. package/lib/types/client/components/settings/SettingsTab.d.ts +6 -0
  118. package/lib/types/client/components/settings/StandaloneSettings.d.ts +13 -0
  119. package/lib/types/client/components/shared/Cascade.d.ts +14 -0
  120. package/lib/types/client/components/shared/ConfigPanel.d.ts +8 -0
  121. package/lib/types/client/components/shared/Dot.d.ts +17 -0
  122. package/lib/types/client/components/shared/Hint.d.ts +6 -0
  123. package/lib/types/client/components/shared/PagingButton.d.ts +10 -0
  124. package/lib/types/client/components/shared/RailShell.d.ts +43 -0
  125. package/lib/types/client/components/shared/SearchBox.d.ts +18 -0
  126. package/lib/types/client/components/shared/hooks.d.ts +64 -0
  127. package/lib/types/client/components/shared/types.d.ts +101 -0
  128. package/lib/types/client/config.d.ts +9 -0
  129. package/lib/types/client/engines/jump.d.ts +17 -0
  130. package/lib/types/client/engines/useAtBottom.d.ts +1 -0
  131. package/lib/types/client/engines/useJump.d.ts +16 -0
  132. package/lib/types/client/engines/useScrollSpy.d.ts +12 -0
  133. package/lib/types/client/hooks.d.ts +7 -0
  134. package/lib/types/client/index.d.ts +31 -0
  135. package/lib/types/client/jump.d.ts +47 -0
  136. package/lib/types/client/locales.d.ts +142 -0
  137. package/lib/types/client/pure.d.ts +21 -0
  138. package/lib/types/client/settings.d.ts +173 -0
  139. package/lib/types/client/virtual/VirtualList.d.ts +15 -0
  140. package/lib/types/compat.d.ts +44 -0
  141. package/lib/types/config.d.ts +44 -0
  142. package/lib/types/core/active-dot.d.ts +15 -0
  143. package/lib/types/core/align.d.ts +10 -0
  144. package/lib/types/core/config.d.ts +44 -0
  145. package/lib/types/core/focus.d.ts +24 -0
  146. package/lib/types/core/jump.d.ts +39 -0
  147. package/lib/types/core/logic/active-dot.d.ts +15 -0
  148. package/lib/types/core/logic/focus.d.ts +22 -0
  149. package/lib/types/core/logic/jump.d.ts +39 -0
  150. package/lib/types/core/logic/nodes.d.ts +48 -0
  151. package/lib/types/core/model/nav-item.d.ts +12 -0
  152. package/lib/types/core/model/turns.d.ts +30 -0
  153. package/lib/types/core/nav-item.d.ts +12 -0
  154. package/lib/types/core/nodes.d.ts +43 -0
  155. package/lib/types/core/page-size.d.ts +8 -0
  156. package/lib/types/core/question-entry.d.ts +12 -0
  157. package/lib/types/core/time.d.ts +4 -0
  158. package/lib/types/core/turn-dots.d.ts +29 -0
  159. package/lib/types/core/utils/measure.d.ts +12 -0
  160. package/lib/types/core/utils/time.d.ts +4 -0
  161. package/lib/types/index.d.ts +4 -0
  162. package/lib/types/nav-item.d.ts +12 -0
  163. package/lib/types/nodes.d.ts +48 -0
  164. package/lib/types/projection.d.ts +71 -0
  165. package/lib/types/schema.d.ts +37 -0
  166. package/lib/types/search.d.ts +42 -0
  167. package/lib/types/settings.d.ts +99 -0
  168. package/package.json +71 -0
  169. package/src/client/components/RailDispatch.tsx +27 -0
  170. package/src/client/components/codex/CodexRail.tsx +348 -0
  171. package/src/client/components/deepseek/DeepseekRail.tsx +522 -0
  172. package/src/client/components/minimal/MinimalRail.tsx +324 -0
  173. package/src/client/components/minimal/dot.tsx +32 -0
  174. package/src/client/components/rail/cards.tsx +102 -0
  175. package/src/client/components/rail/hint.tsx +50 -0
  176. package/src/client/components/rail/paging.tsx +26 -0
  177. package/src/client/components/rail/quick-settings.tsx +130 -0
  178. package/src/client/components/rail/search.tsx +147 -0
  179. package/src/client/components/rail/useRail.ts +906 -0
  180. package/src/client/components/settings/SettingsPage.tsx +198 -0
  181. package/src/client/components/settings/StandaloneSettings.tsx +28 -0
  182. package/src/client/components/shared/types.ts +99 -0
  183. package/src/client/index.ts +388 -0
  184. package/src/client/jump.ts +293 -0
  185. package/src/client/locales.ts +143 -0
  186. package/src/client/settings.ts +482 -0
  187. package/src/client/styles.css +1580 -0
  188. package/src/compat.ts +161 -0
  189. package/src/index.ts +66 -0
  190. package/src/projection.ts +174 -0
  191. package/src/search.ts +291 -0
  192. package/src/settings.ts +169 -0
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ // 完整配置页(mega-settings 成员页与自足入口共用)
3
+ import { useEffect, useState } from 'react';
4
+ import { ALIGN_OPTIONS, CARD_ITEM_OPTIONS, CARD_OPTIONS, MARK_TONE_OPTIONS, SCROLL_OPTIONS, SEARCH_SCOPE_OPTIONS, SHOW_OPTIONS, STYLE_OPTIONS, STYLE_CAPABILITIES } from "../../settings.js";
5
+ function Seg(props) {
6
+ return (_jsx("div", { className: "mgcn-segmented", role: "radiogroup", children: props.options.map((o) => (_jsx("button", { type: "button", role: "radio", "aria-checked": props.value === o, className: props.value === o ? 'mgcn-segment mgcn-segmentActive' : 'mgcn-segment', onClick: () => props.onPick(o), children: props.labels[String(o)] ?? String(o) }, String(o)))) }));
7
+ }
8
+ function Field({ label, desc, children }) {
9
+ return (_jsxs("div", { className: "mgcn-settingsRow", children: [_jsxs("div", { className: "mgcn-settingsLabel", children: [_jsx("p", { className: "mgcn-settingsTitle", children: label }), desc !== undefined ? _jsx("p", { className: "mgcn-settingsDesc", children: desc }) : null] }), _jsx("div", { className: "mgcn-settingsControl", children: children })] }));
10
+ }
11
+ function useSettingsTick(subscribe) {
12
+ const [, bump] = useState(0);
13
+ useEffect(() => subscribe(() => bump((n) => n + 1)), [subscribe]);
14
+ }
15
+ export function SettingsPage(props) {
16
+ const { injected, t, hosted } = props;
17
+ useSettingsTick(injected.subscribeSettings);
18
+ if (hosted === true) {
19
+ return _jsx("div", { className: "mgcn-settings", children: t('settings.hosted') });
20
+ }
21
+ return (_jsxs("div", { className: "mgcn-settings", children: [_jsx(Field, { label: t('config.style'), children: _jsx(Seg, { options: STYLE_OPTIONS, value: injected.style(), labels: { minimal: t('config.style.minimal'), codex: t('config.style.codex'), deepseek: t('config.style.deepseek') }, onPick: (v) => injected.setStyle(v) }) }), _jsx(Field, { label: t('config.railOffset'), desc: t('config.railOffset.desc'), children: _jsxs("div", { className: "mgcn-sliderRow", children: [_jsx("input", { type: "range", min: "0", max: "32", step: "1", value: injected.railOffset(), onChange: (e) => injected.setRailOffset(Number(e.target.value)) }), _jsxs("span", { className: "mgcn-sliderValue", children: [injected.railOffset(), "px"] })] }) }), _jsx(Field, { label: t('config.align'), desc: t('settings.align.desc'), children: _jsx(Seg, { options: ALIGN_OPTIONS, value: injected.align(), labels: { left: t('settings.align.left'), right: t('settings.align.right') }, onPick: (v) => injected.setAlign(v) }) }), _jsx(Field, { label: t('config.scrollBehavior'), desc: t('config.scrollBehavior.desc'), children: _jsx(Seg, { options: SCROLL_OPTIONS, value: injected.scrollBehavior(), labels: { smooth: t('config.scrollBehavior.smooth'), instant: t('config.scrollBehavior.instant') }, onPick: (v) => injected.setScrollMode(v) }) }), STYLE_CAPABILITIES[injected.style()].hoverCards ? (_jsxs(_Fragment, { children: [_jsx(Field, { label: t('config.cardCount'), desc: t('config.cardCount.desc'), children: _jsx(Seg, { options: CARD_OPTIONS, value: injected.cardCount(), labels: { 1: '1', 3: '3', 5: '5' }, onPick: (v) => injected.setCardCount(v) }) }), _jsx(Field, { label: t('config.cardItems'), desc: t('config.cardItems.desc'), children: _jsx("div", { className: "mgcn-checkGroup", children: CARD_ITEM_OPTIONS.map((item) => {
22
+ const on = injected.cardItems().includes(item);
23
+ return (_jsxs("label", { className: "mgcn-checkItem", children: [_jsx("input", { type: "checkbox", checked: on, onChange: (e) => {
24
+ const items = e.target.checked
25
+ ? [...injected.cardItems(), item]
26
+ : injected.cardItems().filter((x) => x !== item);
27
+ injected.setCardItems(items);
28
+ } }), _jsx("span", { children: t('config.cardItems.' + item) })] }, item));
29
+ }) }) })] })) : null, injected.style() === 'codex' ? (_jsx(Field, { label: t('config.markTone'), desc: t('config.markTone.desc'), children: _jsx(Seg, { options: MARK_TONE_OPTIONS, value: injected.markTone(), labels: { soft: t('config.markTone.soft'), deep: t('config.markTone.deep') }, onPick: (v) => injected.setMarkTone(v) }) })) : null, _jsx(Field, { label: t('config.searchScopes'), desc: t('config.searchScopes.desc'), children: _jsx("div", { className: "mgcn-checkGroup", children: SEARCH_SCOPE_OPTIONS.map((scope) => {
30
+ const on = injected.searchScopes().includes(scope);
31
+ const locked = scope === 'user'; // 用户必选,不可取消
32
+ return (_jsxs("label", { className: "mgcn-checkItem", children: [_jsx("input", { type: "checkbox", checked: on, disabled: locked, onChange: (e) => {
33
+ const items = e.target.checked
34
+ ? [...injected.searchScopes(), scope]
35
+ : injected.searchScopes().filter((x) => x !== scope);
36
+ injected.setSearchScopes(items);
37
+ } }), _jsx("span", { children: t('config.searchScopes.' + scope) })] }, scope));
38
+ }) }) }), _jsx(Field, { label: t('config.showQuickSettings'), children: _jsx(ModeSeg, { value: injected.showQuickSettings(), onChange: (v) => injected.setShowQuickSettings(v), t: t }) }), _jsx(Field, { label: t('config.showSearch'), children: _jsx(ModeSeg, { value: injected.showSearch(), onChange: (v) => injected.setShowSearch(v), t: t }) }), _jsx(Field, { label: t('config.showFavorites'), children: _jsx(ModeSeg, { value: injected.showFavorites(), onChange: (v) => injected.setShowFavorites(v), t: t }) }), _jsx(Field, { label: t('config.showCount'), children: _jsx(ModeSeg, { value: injected.showCount(), onChange: (v) => injected.setShowCount(v), t: t }) }), STYLE_CAPABILITIES[injected.style()].paging ? (_jsx(Field, { label: t('config.showPaging'), children: _jsx(ModeSeg, { value: injected.showPaging(), onChange: (v) => injected.setShowPaging(v), t: t }) })) : null] }));
39
+ }
40
+ function ModeSeg({ value, onChange, t }) {
41
+ return (_jsx(Seg, { options: SHOW_OPTIONS, value: value, labels: {
42
+ show: t('config.showMode.show'),
43
+ peek: t('config.showMode.peek'),
44
+ hide: t('config.showMode.hide'),
45
+ }, onPick: (v) => onChange(v) }));
46
+ }
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // 设置页(settings.plugins.tab):对齐 + 翻页数量
3
+ import { useEffect, useState } from 'react';
4
+ import { AlignOptions, AnchorRuleOptions, PageSizeOptions, ScrollModeOptions } from "../../../core/config.js";
5
+ function useSettingsTick(subscribe) {
6
+ const [, bump] = useState(0);
7
+ useEffect(() => subscribe(() => bump((n) => n + 1)), [subscribe]);
8
+ }
9
+ export function SettingsTab(props) {
10
+ useSettingsTick(props.subscribeSettings);
11
+ const align = props.align();
12
+ const pageSize = props.pageSize();
13
+ const anchorRule = props.anchorRule();
14
+ const scrollBehavior = props.scrollBehavior();
15
+ const t = props.t;
16
+ return (_jsxs("div", { className: "mgs-settings", children: [_jsx("p", { className: "mgs-settingsTitle", children: t('settings.align.title') }), _jsx("p", { className: "mgs-settingsDesc", children: t('settings.align.desc') }), _jsx("div", { className: "mgs-segmented", role: "radiogroup", "aria-label": t('settings.align.title'), children: AlignOptions.map((option) => (_jsx("button", { type: "button", role: "radio", "aria-checked": align === option, className: align === option ? 'mgs-segment mgs-segmentActive' : 'mgs-segment', onClick: () => props.setAlign(option), children: t(option === 'left' ? 'settings.align.left' : 'settings.align.right') }, option))) }), _jsx("p", { className: "mgs-settingsTitle", children: t('settings.pagesize.title') }), _jsx("p", { className: "mgs-settingsDesc", children: t('settings.pagesize.desc') }), _jsx("div", { className: "mgs-segmented", role: "radiogroup", "aria-label": t('settings.pagesize.title'), children: PageSizeOptions.map((option) => (_jsx("button", { type: "button", role: "radio", "aria-checked": pageSize === option, className: pageSize === option ? 'mgs-segment mgs-segmentActive' : 'mgs-segment', onClick: () => props.setPageSize(option), children: option }, option))) }), _jsx("p", { className: "mgs-settingsTitle", children: t('config.anchorRule') }), _jsx("p", { className: "mgs-settingsDesc", children: t('config.anchorRule.desc') }), _jsx("div", { className: "mgs-segmented", role: "radiogroup", "aria-label": t('config.anchorRule'), children: AnchorRuleOptions.map((option) => (_jsx("button", { type: "button", role: "radio", "aria-checked": anchorRule === option, className: anchorRule === option ? 'mgs-segment mgs-segmentActive' : 'mgs-segment', onClick: () => props.setAnchorRule(option), children: t('config.anchorRule.' + option) }, option))) }), _jsx("p", { className: "mgs-settingsTitle", children: t('config.scrollBehavior') }), _jsx("p", { className: "mgs-settingsDesc", children: t('config.scrollBehavior.desc') }), _jsx("div", { className: "mgs-segmented", role: "radiogroup", "aria-label": t('config.scrollBehavior'), children: ScrollModeOptions.map((option) => (_jsx("button", { type: "button", role: "radio", "aria-checked": scrollBehavior === option, className: scrollBehavior === option ? 'mgs-segment mgs-segmentActive' : 'mgs-segment', onClick: () => props.setScrollMode(option), children: t('config.scrollBehavior.' + option) }, option))) })] }));
17
+ }
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // 自足完整配置入口:宿主(mega-settings)已收纳时让位提示,否则渲染完整配置页
3
+ import { useEffect, useState } from 'react';
4
+ import { SettingsPage } from "./SettingsPage.js";
5
+ export function StandaloneSettings(props) {
6
+ const [hosted, setHosted] = useState(false);
7
+ useEffect(() => {
8
+ const check = () => {
9
+ const n = props.slots?.entries?.('mega.settings.member')?.length ?? 0;
10
+ setHosted(n > 0);
11
+ };
12
+ check();
13
+ return props.slots?.subscribe?.('mega.settings.member', check);
14
+ }, [props.slots]);
15
+ return _jsx(SettingsPage, { injected: props.injected, t: props.t, hosted: hosted });
16
+ }
@@ -0,0 +1,26 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { createPortal } from 'react-dom';
3
+ import { focusCardMetrics, formatNavTime } from "../shared/hooks.js";
4
+ export function Cascade(props) {
5
+ const { focus, align, onJump, onEnter, onLeave } = props;
6
+ return createPortal(_jsx("div", { className: align === 'right' ? 'mgs-cascade mgs-cascadeRight' : 'mgs-cascade', style: {
7
+ ...(focus.left !== undefined ? { left: focus.left } : {}),
8
+ ...(focus.right !== undefined ? { right: focus.right } : {}),
9
+ top: focus.centerY,
10
+ transform: 'translateY(-50%)',
11
+ }, onMouseEnter: onEnter, onMouseLeave: onLeave, children: focus.items.map((item) => {
12
+ const metrics = focusCardMetrics(item.distance);
13
+ if (metrics === null)
14
+ return null;
15
+ const isSelected = item.distance === 0;
16
+ const text = item.dot.texts.join(' · ');
17
+ const cls = isSelected
18
+ ? 'mgs-card mgs-cardSelected' + (align === 'right' ? ' mgs-cardSelectedRight' : '')
19
+ : 'mgs-card';
20
+ return (_jsxs("div", { className: cls, role: "button", tabIndex: -1, style: { width: metrics.widthPx }, onClick: () => onJump(item.dot), children: [isSelected && item.dot.turn !== null ? (_jsxs("div", { className: "mgs-cardTitle", children: ["Turn ", item.dot.turn] })) : null, _jsx("div", { className: isSelected ? 'mgs-cardBody' : 'mgs-cardClamp', style: isSelected
21
+ ? undefined
22
+ : { WebkitLineClamp: metrics.maxLines, fontSize: metrics.fontSize }, children: isSelected
23
+ ? item.dot.texts.map((line, lineIndex) => (_jsx("div", { className: "mgs-cardLine", children: line }, lineIndex)))
24
+ : text }), _jsx("div", { className: "mgs-cardTime", children: formatNavTime(item.dot.time, Date.now()) })] }, item.dot.key));
25
+ }) }), document.body);
26
+ }
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // ⚙ 组件内面板:高频配置(对齐方式/节点栏高度/悬停卡片数/显示模式)
3
+ import { useEffect, useState } from 'react';
4
+ import { AlignOptions, BandHeightOptions, CardCountOptions, ShowModeOptions } from "../../../core/config.js";
5
+ function Seg(props) {
6
+ return (_jsx("div", { className: "mgs-segmented", role: "radiogroup", children: props.options.map((o) => (_jsx("button", { type: "button", role: "radio", "aria-checked": props.value === o, className: props.value === o ? 'mgs-segment mgs-segmentActive' : 'mgs-segment', onClick: () => props.onPick(o), children: props.labels[String(o)] ?? String(o) }, o))) }));
7
+ }
8
+ function useSettingsTick(subscribe) {
9
+ const [, bump] = useState(0);
10
+ useEffect(() => subscribe(() => bump((n) => n + 1)), [subscribe]);
11
+ }
12
+ export function ConfigPanel(props) {
13
+ const { injected, t, onClose } = props;
14
+ useSettingsTick(injected.subscribeSettings);
15
+ return (_jsxs("div", { className: "mgs-config-panel", role: "dialog", "aria-label": t('config.title'), children: [_jsxs("div", { className: "mgs-config-head", children: [_jsxs("span", { className: "mgs-config-title", children: [t('config.style.' + injected.style()), " \u00B7 ", t('config.settings')] }), _jsx("button", { type: "button", className: "mgs-config-close", "aria-label": t('config.close'), onClick: onClose, children: "\u2715" })] }), _jsxs("div", { className: "mgs-config-row", children: [_jsx("span", { className: "mgs-config-label", children: t('config.align') }), _jsx(Seg, { options: AlignOptions, value: injected.align(), labels: { left: t('settings.align.left'), right: t('settings.align.right') }, onPick: (v) => injected.setAlign(v) })] }), _jsxs("div", { className: "mgs-config-row", children: [_jsx("span", { className: "mgs-config-label", children: t('config.bandHeight') }), _jsx(Seg, { options: BandHeightOptions, value: injected.bandHeight(), labels: {
16
+ compact: t('config.bandHeight.compact'),
17
+ standard: t('config.bandHeight.standard'),
18
+ tall: t('config.bandHeight.tall'),
19
+ }, onPick: (v) => injected.setBandHeight(v) })] }), _jsxs("div", { className: "mgs-config-row", children: [_jsx("span", { className: "mgs-config-label", children: t('config.cardCount') }), _jsx(Seg, { options: CardCountOptions, value: injected.cardCount(), labels: { 1: '1', 3: '3', 5: '5' }, onPick: (v) => injected.setCardCount(v) })] }), _jsx("div", { className: "mgs-config-sep" }), _jsxs("div", { className: "mgs-config-row", children: [_jsx("span", { className: "mgs-config-label", children: t('config.showCount') }), _jsx(ModeSeg, { value: injected.showCount(), onChange: (v) => injected.setShowCount(v), t: t })] }), _jsxs("div", { className: "mgs-config-row", children: [_jsx("span", { className: "mgs-config-label", children: t('config.showSearch') }), _jsx(ModeSeg, { value: injected.showSearch(), onChange: (v) => injected.setShowSearch(v), t: t })] }), _jsxs("div", { className: "mgs-config-row", children: [_jsx("span", { className: "mgs-config-label", children: t('config.showQuickSettings') }), _jsx(ModeSeg, { value: injected.showQuickSettings(), onChange: (v) => injected.setShowQuickSettings(v), t: t })] })] }));
20
+ }
21
+ function ModeSeg({ value, onChange, t }) {
22
+ return (_jsx(Seg, { options: ShowModeOptions, value: value, labels: {
23
+ show: t('config.showMode.show'),
24
+ peek: t('config.showMode.peek'),
25
+ hide: t('config.showMode.hide'),
26
+ }, onPick: (v) => onChange(v) }));
27
+ }
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export function Dot(props) {
3
+ const { scale, className, label, index, keyName, focused, revealed, onEnter, onClick } = props;
4
+ return (_jsx("button", { type: "button", className: className, style: {
5
+ transform: 'scale(' + scale + ')',
6
+ ...(revealed !== undefined ? { animationDelay: revealed.order * 35 + 'ms' } : {}),
7
+ }, "data-mega-chat-nav-focused": focused ? 'true' : undefined, "data-mega-chat-nav-index": index, "data-mega-chat-nav-key": keyName, "aria-label": label, onMouseEnter: (e) => onEnter(e.currentTarget), onClick: onClick }));
8
+ }
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createPortal } from 'react-dom';
3
+ export function Hint({ text, align }) {
4
+ return createPortal(_jsx("div", { className: "mgs-hint", style: align === 'right' ? { right: 60, top: 20 } : { left: 60, top: 20 }, children: text }), document.body);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export function PagingButton(props) {
3
+ const cls = props.dir === -1 ? 'mgs-navBtn mgs-navUp' : 'mgs-navBtn mgs-navDown';
4
+ return (_jsx("button", { type: "button", className: cls, "aria-label": props.label, style: { visibility: props.visible ? 'visible' : 'hidden' }, onMouseEnter: props.onEnter, onMouseLeave: props.onLeave, onClick: props.onClick }));
5
+ }
@@ -0,0 +1,78 @@
1
+ // RailShell:跨风格装配壳——会话/数据/布局/滚动/聚焦/提示全部在此组合,
2
+ // 通过 render-prop 把状态交给风格组件(样式与形态由风格组件自持)。
3
+ import { useEffect, useRef, useState } from 'react';
4
+ import { useVisibleSession, useSessionDots, useRailLayout, useScrollSpyDot, useNavSettings, usePaging, useFocus, useJumpHint } from "./hooks.js";
5
+ import { DOT_GAP, DOT_SIZE } from "../../../core/utils/measure.js";
6
+ export function RailShell(props) {
7
+ const { injected, useSessions, t } = props;
8
+ const panelRef = useRef(null);
9
+ const listRef = useRef(null);
10
+ const [jumpingKey, setJumpingKey] = useState(null);
11
+ const { sessionId, visible } = useVisibleSession(useSessions);
12
+ const dots = useSessionDots(injected, sessionId, visible);
13
+ const { style, align, bandHeight, cardCount, scrollBehavior, showCount, showSearch, showQuickSettings } = useNavSettings(injected);
14
+ useRailLayout(panelRef, visible, align);
15
+ const [currentKey] = useScrollSpyDot(visible, dots);
16
+ const focusRadius = Math.floor((cardCount - 1) / 2);
17
+ const { focus, openFocus, cancelClearFocus, scheduleClearFocus } = useFocus(dots, align, focusRadius);
18
+ const { hint } = useJumpHint(t);
19
+ const { scrollable, revealed, syncScroll, pageBy, canPageUp, canPageDown } = usePaging(listRef, dots, align);
20
+ // 激活节点跟随(居中定位,参考实现 scrollNavToDot):
21
+ // 点击跳转后不冻结——正文平滑滚动时激活随正文实时联动,导航列表持续跟随,
22
+ // 滚动稳定后激活落在目标节点。点击瞬间已由 forceKey 高亮目标。
23
+ useEffect(() => {
24
+ const list = listRef.current;
25
+ if (list === null || currentKey === null)
26
+ return;
27
+ const index = dots.findIndex((d) => d.key === currentKey);
28
+ if (index < 0)
29
+ return;
30
+ const step = DOT_SIZE + DOT_GAP;
31
+ const dotTop = 8 + index * step; // 列表上内边距 8px + 节点位置
32
+ const contentHeight = 16 + dots.length * step - DOT_GAP;
33
+ const maxScroll = Math.max(0, contentHeight - list.clientHeight);
34
+ let target = dotTop - list.clientHeight / 2 + step / 2;
35
+ target = Math.max(0, Math.min(target, maxScroll));
36
+ if (Math.abs(target - list.scrollTop) < 2)
37
+ return;
38
+ list.scrollTo({ top: target, behavior: 'smooth' });
39
+ }, [currentKey, dots, listRef]);
40
+ if (!visible || injected === undefined)
41
+ return null;
42
+ const onJump = (dot) => {
43
+ if (sessionId === undefined)
44
+ return;
45
+ setJumpingKey(dot.key);
46
+ injected.jump(sessionId, dot.key);
47
+ window.setTimeout(() => setJumpingKey((k) => (k === dot.key ? null : k)), 600);
48
+ };
49
+ return props.children({
50
+ injected,
51
+ sessionId,
52
+ dots,
53
+ style,
54
+ align,
55
+ bandHeight,
56
+ scrollBehavior,
57
+ showCount,
58
+ showSearch,
59
+ showQuickSettings,
60
+ cardCount,
61
+ currentKey,
62
+ hint,
63
+ scrollable,
64
+ canPageUp,
65
+ canPageDown,
66
+ revealed,
67
+ jumpingKey,
68
+ panelRef,
69
+ listRef,
70
+ focus,
71
+ openFocus,
72
+ cancelClearFocus,
73
+ scheduleClearFocus,
74
+ syncScroll,
75
+ pageBy,
76
+ onJump,
77
+ });
78
+ }
@@ -0,0 +1,63 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // 搜索浮层:防抖 + AbortController + 命中词高亮 + 点击直达
3
+ import { useCallback, useEffect, useRef, useState } from 'react';
4
+ import { formatNavTime } from "../../../core/utils/time.js";
5
+ export function SearchBox(props) {
6
+ const [q, setQ] = useState('');
7
+ const [results, setResults] = useState([]);
8
+ const [busy, setBusy] = useState(false);
9
+ const [empty, setEmpty] = useState(false);
10
+ const abortRef = useRef(null);
11
+ const timerRef = useRef(null);
12
+ const inputRef = useRef(null);
13
+ const run = useCallback((query) => {
14
+ abortRef.current?.abort();
15
+ const ac = new AbortController();
16
+ abortRef.current = ac;
17
+ const trimmed = query.trim();
18
+ if (trimmed.length < 1) {
19
+ setResults([]);
20
+ setEmpty(false);
21
+ setBusy(false);
22
+ return;
23
+ }
24
+ setBusy(true);
25
+ const url = '/mega-chat-nav/search?session=' + encodeURIComponent(props.sessionId ?? '')
26
+ + '&q=' + encodeURIComponent(trimmed) + '&limit=20';
27
+ fetch(url, { signal: ac.signal })
28
+ .then((resp) => resp.json())
29
+ .then((data) => {
30
+ if (!data.ok) {
31
+ setResults([]);
32
+ setEmpty(false);
33
+ return;
34
+ }
35
+ const hits = data.hits ?? [];
36
+ setResults(hits);
37
+ setEmpty(hits.length === 0);
38
+ })
39
+ .catch((e) => {
40
+ if (e.name !== 'AbortError') {
41
+ setResults([]);
42
+ setEmpty(false);
43
+ }
44
+ })
45
+ .finally(() => setBusy(false));
46
+ }, [props.sessionId]);
47
+ const onChange = (v) => {
48
+ setQ(v);
49
+ if (timerRef.current !== null)
50
+ window.clearTimeout(timerRef.current);
51
+ timerRef.current = window.setTimeout(() => run(v), 200);
52
+ };
53
+ useEffect(() => {
54
+ inputRef.current?.focus();
55
+ return () => {
56
+ if (timerRef.current !== null)
57
+ window.clearTimeout(timerRef.current);
58
+ abortRef.current?.abort();
59
+ };
60
+ }, []);
61
+ return (_jsxs("div", { className: "mgs-search", role: "dialog", "aria-label": props.t('search.placeholder'), children: [_jsx("input", { ref: inputRef, className: "mgs-search-input", value: q, placeholder: props.t('search.placeholder'), onChange: (e) => onChange(e.target.value), onKeyDown: (e) => { if (e.key === 'Escape')
62
+ props.onClose(); } }), busy ? _jsx("div", { className: "mgs-search-busy", children: "\u2026" }) : null, _jsxs("div", { className: "mgs-search-results", children: [empty ? _jsx("div", { className: "mgs-search-empty", children: props.t('search.empty') }) : null, results.map((hit) => (_jsxs("button", { type: "button", className: "mgs-search-hit", onClick: () => props.onJump(hit.key), children: [_jsx("span", { className: 'mgs-search-role mgs-search-role--' + hit.role, "aria-hidden": "true" }), _jsx("span", { className: "mgs-search-text", children: hit.hitStart >= 0 && hit.hitLen > 0 ? (_jsxs(_Fragment, { children: [hit.snippet.slice(0, hit.hitStart), _jsx("mark", { className: "mgs-search-mark", children: hit.snippet.slice(hit.hitStart, hit.hitStart + hit.hitLen) }), hit.snippet.slice(hit.hitStart + hit.hitLen)] })) : hit.snippet }), _jsx("span", { className: "mgs-search-time", children: formatNavTime(hit.time, Date.now()) })] }, hit.key + ':' + hit.seq)))] })] }));
63
+ }