knight-ui 1.2.3 → 1.2.5

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.
@@ -9,12 +9,22 @@ type TooltipTheme = "dark" | "light";
9
9
  export declare class Tooltip extends AbstractUI<TooltipProps, TooltipState> {
10
10
  private zIndex;
11
11
  private wrapperRef;
12
+ private bubbleRef;
13
+ /** 视口夹取的累计偏移 — 量出溢出后回填,两个都为 0 表示无需偏移 */
14
+ private shiftX;
15
+ private shiftY;
12
16
  private animTimer;
13
17
  private leaveTimer;
14
18
  private enterTimer;
15
19
  constructor(props: TooltipProps);
16
20
  componentDidMount(): void;
17
21
  componentDidUpdate(prevProps: Readonly<TooltipProps>): void;
22
+ /**
23
+ * 视口夹取 — 气泡是固定定位,只按触发元素居中,靠屏幕边缘时会挂出去一截。
24
+ * 量在 componentDidUpdate:此时 DOM 已提交、浏览器尚未绘制,补一次 setState 仍落在同一帧,
25
+ * 校正过程不可见(不会先闪一下再跳)。偏移累计到 shift 上,收敛后不再 setState。
26
+ */
27
+ private clampToViewport;
18
28
  componentWillUnmount(): void;
19
29
  private enter;
20
30
  private exit;
@@ -22,6 +32,8 @@ export declare class Tooltip extends AbstractUI<TooltipProps, TooltipState> {
22
32
  private cleanup;
23
33
  protected OnRenderContent(): React.ReactElement;
24
34
  private getArrowStyle;
35
+ /** 叠加视口夹取偏移 — 走 transform 而不是改 left/right:12 个方位的锚点各不相同,只有位移对全体一致 */
36
+ private OnShiftPosition;
25
37
  private calcPosition;
26
38
  }
27
39
  type TooltipAnimPhase = "entering" | "entered" | "leaving" | "exited";
@@ -30,6 +42,8 @@ export interface TooltipProps extends UIProps {
30
42
  defaultVisible?: boolean;
31
43
  content?: React.ReactNode;
32
44
  title?: React.ReactNode;
45
+ /** 内容宽度上限(px) — 传了就允许换行并以它为上限;不传则单行不换行 */
46
+ maxWidth?: number;
33
47
  position?: TooltipPosition;
34
48
  trigger?: "hover" | "click" | "focus" | "custom";
35
49
  theme?: TooltipTheme;
@@ -5,11 +5,30 @@ import { AbstractUI, type UIProps, type UIState } from "../../base";
5
5
  * 支持完整 CommonMark + GFM: 表格/任务列表/删除线/链接/图片/代码块/引用.
6
6
  */
7
7
  export declare class Markdown extends AbstractUI<MarkdownProps, MarkdownState> {
8
+ /** 代码块折叠阈值(行)默认值 — 超过即默认收起 */
9
+ private static readonly DEFAULT_CODE_FOLD_LINES;
10
+ /** 代码块收起态可视高度(px)默认值 */
11
+ private static readonly DEFAULT_CODE_FOLD_HEIGHT;
8
12
  constructor(props: MarkdownProps);
9
13
  componentDidMount(): void;
10
14
  componentWillUnmount(): void;
11
15
  private onWheel;
12
- private static readonly components;
16
+ /** 渲染组件表 — 每实例一份: pre 要读实例 props(折叠阈值/高度), 故写成箭头函数绑定 this;
17
+ * 实例字段只构造一次, 函数标识跨渲染稳定, 折叠状态不会因重渲染丢失 */
18
+ private readonly components;
19
+ /** 抽纯文本 — 只用于统计代码块的行数与体量(react-markdown 把代码文本挂在 code 子节点的 children 上) */
20
+ private static extractText;
21
+ /** 语言标签 — 从 code 子节点的 `language-json` 类名取, 取不到写"代码" */
22
+ private static readLang;
23
+ /** 体量标签 — 1KB 以内按字节, 超出按 KB 保留一位 */
24
+ private static readSize;
25
+ /** 整理源码里的 JSON 围栏 — 渲染前改写, 高亮与折叠行数都基于整理后的文本 */
26
+ private static formatCodeFences;
27
+ /** 按语言整理一段围栏正文 — 目前只处理 json, 其余语言原样 */
28
+ private static pushFenceBody;
29
+ /** JSON 缩进整理 — 只重排空白, 字面量逐字保留(不走 parse→stringify 往返, 大整数与 1.0 这类写法不会失真)
30
+ * 返回 null 表示不是合法 JSON, 调用方保持原样 */
31
+ private static prettifyJson;
13
32
  protected OnRenderContent(): React.ReactElement;
14
33
  }
15
34
  export interface MarkdownProps extends UIProps {
@@ -17,6 +36,12 @@ export interface MarkdownProps extends UIProps {
17
36
  renderMode?: "default" | "preview" | "raw";
18
37
  /** 最大可视行数 (每行约 18px) */
19
38
  rows?: number;
39
+ /** 代码块折叠阈值(行) — 超过即默认收起; 传 0 或负数表示不折叠 @default 16 */
40
+ codeFoldLines?: number;
41
+ /** 折叠收起态的可视高度(px) @default 180 */
42
+ codeFoldHeight?: number;
43
+ /** 是否整理代码块内容 — 目前只做 JSON 缩进规范化(只重排空白, 不改字面量) @default true */
44
+ codeFormat?: boolean;
20
45
  }
21
46
  export interface MarkdownState extends UIState {
22
47
  }