@easyv/biz-components 0.0.6 → 0.0.8

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.
@@ -1,10 +1,9 @@
1
1
  const n = `.markdown-container {
2
- --base-font: 16px;
3
2
  /* // 基础文本样式 */
4
3
  color: #fff;
5
4
  font-family: 'PingFang SC', BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
6
5
  line-height: 1.6;
7
- font-size: 16px;
6
+ font-size: var(--base-font);
8
7
  font-style: normal;
9
8
  font-weight: 400;
10
9
  user-select: text;
@@ -29,7 +28,8 @@ h3,
29
28
  h4,
30
29
  h5,
31
30
  h6 {
32
- margin: calc(1.5 * var(--base-font)) var(--base-font);
31
+ margin-top: calc(1.5 * var(--base-font));
32
+ margin-bottom: calc(1.5 * var(--base-font));
33
33
  font-weight: 600;
34
34
  line-height: 1.25;
35
35
  color: #fff;
@@ -65,11 +65,6 @@ h6 {
65
65
  color: #6a737d;
66
66
  }
67
67
 
68
- /* // 段落和文本 */
69
- p {
70
- margin: 0 0 var(--base-font);
71
- }
72
-
73
68
  strong {
74
69
  font-weight: 600;
75
70
  }
@@ -127,8 +122,9 @@ code {
127
122
  background-color: #ececec;
128
123
  color: #404040;
129
124
  border-radius: calc(0.25 * var(--base-font));
130
- padding: 0calc (2 * var(--base-font)) calc(0.4 * var(--base-font));
131
- font-size: 85%;
125
+ padding: calc(0.15 * var(--base-font)) calc(0.3 * var(--base-font));
126
+ margin: 0 calc(0.15 * var(--base-font));
127
+ font-size: calc(0.875 * var(--base-font));
132
128
  }
133
129
 
134
130
  /* // 表格样式 */
@@ -1 +1 @@
1
- {"version":3,"file":"index.less.es.js","sources":["../../../src/components/AiMessageRender/index.less?raw"],"sourcesContent":["export default \".markdown-container {\\n --base-font: 16px;\\n /* // 基础文本样式 */\\n color: #fff;\\n font-family: 'PingFang SC', BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\\n line-height: 1.6;\\n font-size: 16px;\\n font-style: normal;\\n font-weight: 400;\\n user-select: text;\\n}\\n\\n/* // 重置一些元素的默认样式 */\\n* {\\n box-sizing: border-box;\\n margin: 0;\\n padding: 0;\\n}\\n\\nimg {\\n max-width: 50%;\\n border-radius: calc(0.5 * var(--base-font));\\n}\\n\\n/* // 标题样式 */\\nh1,\\nh2,\\nh3,\\nh4,\\nh5,\\nh6 {\\n margin: calc(1.5 * var(--base-font)) var(--base-font);\\n font-weight: 600;\\n line-height: 1.25;\\n color: #fff;\\n\\n &:first-child {\\n margin-top: 0;\\n }\\n}\\n\\nh1 {\\n font-size: calc(2 * var(--base-font));\\n border-bottom: 1px solid #eaecef;\\n padding-bottom: calc(0.3 * var(--base-font));\\n}\\n\\nh2 {\\n font-size: calc(1.5 * var(--base-font));\\n border-bottom: 1px solid #eaecef;\\n padding-bottom: calc(0.3 * var(--base-font));\\n}\\n\\nh3 {\\n font-size: calc(1.25 * var(--base-font));\\n}\\nh4 {\\n font-size: var(--base-font);\\n}\\nh5 {\\n font-size: calc(0.875 * var(--base-font));\\n}\\nh6 {\\n font-size: calc(0.85 * var(--base-font));\\n color: #6a737d;\\n}\\n\\n/* // 段落和文本 */\\np {\\n margin: 0 0 var(--base-font);\\n}\\n\\nstrong {\\n font-weight: 600;\\n}\\n\\nem {\\n font-style: italic;\\n}\\n\\n/* // 链接 */\\na {\\n color: #0366d6;\\n text-decoration: none;\\n\\n &:hover {\\n text-decoration: underline;\\n }\\n}\\n\\n/* // 列表 */\\nul,\\nol {\\n margin-bottom: var(--base-font);\\n padding-left: calc(2 * var(--base-font));\\n}\\n\\nli {\\n margin-bottom: calc(0.25 * var(--base-font));\\n\\n > p {\\n margin: 0;\\n }\\n}\\n\\n/* // 代码块和内联代码 */\\npre {\\n background-color: #fafafa;\\n border-radius: calc(0.3 * var(--base-font));\\n padding: var(--base-font);\\n overflow: auto;\\n margin-bottom: var(--base-font);\\n line-height: 1.45;\\n overflow-x: auto;\\n\\n code {\\n color: #494949;\\n background-color: transparent;\\n padding: 0;\\n border-radius: 0;\\n border: none;\\n }\\n}\\n\\ncode {\\n font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;\\n background-color: #ececec;\\n color: #404040;\\n border-radius: calc(0.25 * var(--base-font));\\n padding: 0calc (2 * var(--base-font)) calc(0.4 * var(--base-font));\\n font-size: 85%;\\n}\\n\\n/* // 表格样式 */\\ntable {\\n border-collapse: collapse;\\n width: 100%;\\n margin-bottom: var(--base-font);\\n display: block;\\n overflow-x: auto;\\n color: #4a4e55;\\n}\\ntable th,\\ntable td {\\n padding: calc(0.75 * var(--base-font)) var(--base-font);\\n border: 1px solid #dfe2e5;\\n}\\n\\ntable th {\\n background-color: #f6f8fa;\\n font-weight: 600;\\n text-align: left;\\n}\\n\\ntable tr {\\n background-color: #fff;\\n border-top: 1px solid #c6cbd1;\\n\\n &:nth-child(2n) {\\n background-color: #f6f8fa;\\n }\\n}\\n\\n/* // 引用块 */\\nblockquote {\\n border-left: calc(0.25 * var(--base-font)) solid #dfe2e5;\\n color: #fff;\\n padding: 0 var(--base-font);\\n margin: 0 0 var(--base-font) 0;\\n\\n p {\\n margin: 0;\\n }\\n}\\n\\n/* // 水平线 */\\nhr {\\n height: 1px;\\n background-color: #e1e4e8;\\n border: 0;\\n margin: calc(1.5 * var(--base-font)) 0;\\n}\\n\\n/* // 任务列表 */\\n.task-list-item {\\n list-style-type: none;\\n\\n input[type='checkbox'] {\\n margin: 0 0calc (2 * var(--base-font)) calc(0.25 * var(--base-font)) -1.6em;\\n vertical-align: middle;\\n }\\n}\\n\""],"names":["messageRenderCss"],"mappings":"AAAA,MAAeA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
1
+ {"version":3,"file":"index.less.es.js","sources":["../../../src/components/AiMessageRender/index.less?raw"],"sourcesContent":["export default \".markdown-container {\\n /* // 基础文本样式 */\\n color: #fff;\\n font-family: 'PingFang SC', BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\\n line-height: 1.6;\\n font-size: var(--base-font);\\n font-style: normal;\\n font-weight: 400;\\n user-select: text;\\n}\\n\\n/* // 重置一些元素的默认样式 */\\n* {\\n box-sizing: border-box;\\n margin: 0;\\n padding: 0;\\n}\\n\\nimg {\\n max-width: 50%;\\n border-radius: calc(0.5 * var(--base-font));\\n}\\n\\n/* // 标题样式 */\\nh1,\\nh2,\\nh3,\\nh4,\\nh5,\\nh6 {\\n margin-top: calc(1.5 * var(--base-font));\\n margin-bottom: calc(1.5 * var(--base-font));\\n font-weight: 600;\\n line-height: 1.25;\\n color: #fff;\\n\\n &:first-child {\\n margin-top: 0;\\n }\\n}\\n\\nh1 {\\n font-size: calc(2 * var(--base-font));\\n border-bottom: 1px solid #eaecef;\\n padding-bottom: calc(0.3 * var(--base-font));\\n}\\n\\nh2 {\\n font-size: calc(1.5 * var(--base-font));\\n border-bottom: 1px solid #eaecef;\\n padding-bottom: calc(0.3 * var(--base-font));\\n}\\n\\nh3 {\\n font-size: calc(1.25 * var(--base-font));\\n}\\nh4 {\\n font-size: var(--base-font);\\n}\\nh5 {\\n font-size: calc(0.875 * var(--base-font));\\n}\\nh6 {\\n font-size: calc(0.85 * var(--base-font));\\n color: #6a737d;\\n}\\n\\nstrong {\\n font-weight: 600;\\n}\\n\\nem {\\n font-style: italic;\\n}\\n\\n/* // 链接 */\\na {\\n color: #0366d6;\\n text-decoration: none;\\n\\n &:hover {\\n text-decoration: underline;\\n }\\n}\\n\\n/* // 列表 */\\nul,\\nol {\\n margin-bottom: var(--base-font);\\n padding-left: calc(2 * var(--base-font));\\n}\\n\\nli {\\n margin-bottom: calc(0.25 * var(--base-font));\\n\\n > p {\\n margin: 0;\\n }\\n}\\n\\n/* // 代码块和内联代码 */\\npre {\\n background-color: #fafafa;\\n border-radius: calc(0.3 * var(--base-font));\\n padding: var(--base-font);\\n overflow: auto;\\n margin-bottom: var(--base-font);\\n line-height: 1.45;\\n overflow-x: auto;\\n\\n code {\\n color: #494949;\\n background-color: transparent;\\n padding: 0;\\n border-radius: 0;\\n border: none;\\n }\\n}\\n\\ncode {\\n font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;\\n background-color: #ececec;\\n color: #404040;\\n border-radius: calc(0.25 * var(--base-font));\\n padding: calc(0.15 * var(--base-font)) calc(0.3 * var(--base-font));\\n margin: 0 calc(0.15 * var(--base-font));\\n font-size: calc(0.875 * var(--base-font));\\n}\\n\\n/* // 表格样式 */\\ntable {\\n border-collapse: collapse;\\n width: 100%;\\n margin-bottom: var(--base-font);\\n display: block;\\n overflow-x: auto;\\n color: #4a4e55;\\n}\\ntable th,\\ntable td {\\n padding: calc(0.75 * var(--base-font)) var(--base-font);\\n border: 1px solid #dfe2e5;\\n}\\n\\ntable th {\\n background-color: #f6f8fa;\\n font-weight: 600;\\n text-align: left;\\n}\\n\\ntable tr {\\n background-color: #fff;\\n border-top: 1px solid #c6cbd1;\\n\\n &:nth-child(2n) {\\n background-color: #f6f8fa;\\n }\\n}\\n\\n/* // 引用块 */\\nblockquote {\\n border-left: calc(0.25 * var(--base-font)) solid #dfe2e5;\\n color: #fff;\\n padding: 0 var(--base-font);\\n margin: 0 0 var(--base-font) 0;\\n\\n p {\\n margin: 0;\\n }\\n}\\n\\n/* // 水平线 */\\nhr {\\n height: 1px;\\n background-color: #e1e4e8;\\n border: 0;\\n margin: calc(1.5 * var(--base-font)) 0;\\n}\\n\\n/* // 任务列表 */\\n.task-list-item {\\n list-style-type: none;\\n\\n input[type='checkbox'] {\\n margin: 0 0calc (2 * var(--base-font)) calc(0.25 * var(--base-font)) -1.6em;\\n vertical-align: middle;\\n }\\n}\\n\""],"names":["messageRenderCss"],"mappings":"AAAA,MAAeA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ interface ScrollControllerProps {
4
+ children: ReactNode;
5
+ containerHeight?: string;
6
+ scrollBuffer?: number;
7
+ scrollBehavior?: 'auto' | 'smooth';
8
+ className?: string;
9
+ }
10
+ export declare function ScrollController(props: ScrollControllerProps): JSX.Element;
11
+ export {};
@@ -0,0 +1,42 @@
1
+ import { j as v } from "../../node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.es.js";
2
+ import { useState as E, useRef as l, useCallback as s, useEffect as S } from "react";
3
+ function R(d) {
4
+ const {
5
+ children: i,
6
+ containerHeight: p = "100%",
7
+ scrollBuffer: u = 50,
8
+ scrollBehavior: o = "smooth",
9
+ className: g
10
+ } = d, [a, f] = E(!0), r = l(null), t = l(!1), n = l(), h = s(() => {
11
+ if (!r.current) return !1;
12
+ const { scrollHeight: e, scrollTop: T, clientHeight: j } = r.current;
13
+ return e - T - j < u;
14
+ }, [u]), m = s(() => {
15
+ a && r.current && r.current.scrollTo({
16
+ top: r.current.scrollHeight,
17
+ behavior: o
18
+ });
19
+ }, [a, o]), c = s(() => {
20
+ r.current && (n.current && clearTimeout(n.current), t.current || (t.current = !0), n.current = setTimeout(() => {
21
+ t.current = !1;
22
+ }, 100), h() ? f(!0) : f(!1));
23
+ }, [h]);
24
+ S(() => {
25
+ const e = r.current;
26
+ if (e)
27
+ return e.addEventListener("scroll", c), () => e.removeEventListener("scroll", c);
28
+ }, [c]), S(() => {
29
+ t.current || m();
30
+ }, [i, m]);
31
+ const x = {
32
+ height: p,
33
+ overflowY: "auto",
34
+ scrollBehavior: o,
35
+ position: "relative"
36
+ };
37
+ return /* @__PURE__ */ v.jsx("div", { ref: r, style: x, className: g, children: /* @__PURE__ */ v.jsx("div", { children: i }) });
38
+ }
39
+ export {
40
+ R as ScrollController
41
+ };
42
+ //# sourceMappingURL=ScrollController.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollController.es.js","sources":["../../../src/components/ScrollController/ScrollController.tsx"],"sourcesContent":["import React, { CSSProperties, ReactNode, useCallback, useEffect, useRef, useState } from 'react';\n\ninterface ScrollControllerProps {\n children: ReactNode;\n containerHeight?: string;\n scrollBuffer?: number;\n scrollBehavior?: 'auto' | 'smooth';\n className?: string;\n}\n\nexport function ScrollController(props: ScrollControllerProps) {\n const {\n children,\n containerHeight = '100%',\n scrollBuffer = 50,\n scrollBehavior = 'smooth',\n className,\n } = props;\n const [isAutoScroll, setIsAutoScroll] = useState(true);\n const containerRef = useRef<HTMLDivElement>(null);\n const isUserScrolling = useRef(false);\n const scrollTimeout = useRef<NodeJS.Timeout>();\n\n // 检测是否接近底部\n const isNearBottom = useCallback(() => {\n if (!containerRef.current) return false;\n const { scrollHeight, scrollTop, clientHeight } = containerRef.current;\n return scrollHeight - scrollTop - clientHeight < scrollBuffer;\n }, [scrollBuffer]);\n\n // 自动滚动逻辑\n const autoScroll = useCallback(() => {\n if (isAutoScroll && containerRef.current) {\n containerRef.current.scrollTo({\n top: containerRef.current.scrollHeight,\n behavior: scrollBehavior,\n });\n }\n }, [isAutoScroll, scrollBehavior]);\n\n // 处理滚动事件\n const handleScroll = useCallback(() => {\n if (!containerRef.current) return;\n\n // 清除之前的定时器\n if (scrollTimeout.current) clearTimeout(scrollTimeout.current);\n\n // 标记用户滚动行为\n if (!isUserScrolling.current) {\n isUserScrolling.current = true;\n }\n\n // 设置滚动状态重置\n scrollTimeout.current = setTimeout(() => {\n isUserScrolling.current = false;\n }, 100);\n\n // 判断是否接近底部\n if (isNearBottom()) {\n setIsAutoScroll(true);\n } else {\n setIsAutoScroll(false);\n }\n }, [isNearBottom]);\n\n // 初始化事件监听\n useEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n\n container.addEventListener('scroll', handleScroll);\n return () => container.removeEventListener('scroll', handleScroll);\n }, [handleScroll]);\n\n // 内容变化时自动滚动\n useEffect(() => {\n if (!isUserScrolling.current) {\n autoScroll();\n }\n }, [children, autoScroll]);\n\n // 容器样式\n const containerStyle: CSSProperties = {\n height: containerHeight,\n overflowY: 'auto',\n scrollBehavior: scrollBehavior,\n position: 'relative',\n };\n\n return (\n <div ref={containerRef} style={containerStyle} className={className}>\n <div>{children}</div>\n </div>\n );\n}\n"],"names":["ScrollController","props","children","containerHeight","scrollBuffer","scrollBehavior","className","isAutoScroll","setIsAutoScroll","useState","containerRef","useRef","isUserScrolling","scrollTimeout","isNearBottom","useCallback","scrollHeight","scrollTop","clientHeight","autoScroll","handleScroll","useEffect","container","containerStyle","jsx"],"mappings":";;AAUO,SAASA,EAAiBC,GAA8B;AACvD,QAAA;AAAA,IACJ,UAAAC;AAAA,IACA,iBAAAC,IAAkB;AAAA,IAClB,cAAAC,IAAe;AAAA,IACf,gBAAAC,IAAiB;AAAA,IACjB,WAAAC;AAAA,EAAA,IACEL,GACE,CAACM,GAAcC,CAAe,IAAIC,EAAS,EAAI,GAC/CC,IAAeC,EAAuB,IAAI,GAC1CC,IAAkBD,EAAO,EAAK,GAC9BE,IAAgBF,EAAuB,GAGvCG,IAAeC,EAAY,MAAM;AACjC,QAAA,CAACL,EAAa,QAAgB,QAAA;AAClC,UAAM,EAAE,cAAAM,GAAc,WAAAC,GAAW,cAAAC,MAAiBR,EAAa;AACxD,WAAAM,IAAeC,IAAYC,IAAed;AAAA,EAAA,GAChD,CAACA,CAAY,CAAC,GAGXe,IAAaJ,EAAY,MAAM;AAC/B,IAAAR,KAAgBG,EAAa,WAC/BA,EAAa,QAAQ,SAAS;AAAA,MAC5B,KAAKA,EAAa,QAAQ;AAAA,MAC1B,UAAUL;AAAA,IAAA,CACX;AAAA,EACH,GACC,CAACE,GAAcF,CAAc,CAAC,GAG3Be,IAAeL,EAAY,MAAM;AACjC,IAACL,EAAa,YAGdG,EAAc,WAAsB,aAAAA,EAAc,OAAO,GAGxDD,EAAgB,YACnBA,EAAgB,UAAU,KAIdC,EAAA,UAAU,WAAW,MAAM;AACvC,MAAAD,EAAgB,UAAU;AAAA,OACzB,GAAG,GAGFE,MACFN,EAAgB,EAAI,IAEpBA,EAAgB,EAAK;AAAA,EACvB,GACC,CAACM,CAAY,CAAC;AAGjB,EAAAO,EAAU,MAAM;AACd,UAAMC,IAAYZ,EAAa;AAC/B,QAAKY;AAEK,aAAAA,EAAA,iBAAiB,UAAUF,CAAY,GAC1C,MAAME,EAAU,oBAAoB,UAAUF,CAAY;AAAA,EAAA,GAChE,CAACA,CAAY,CAAC,GAGjBC,EAAU,MAAM;AACV,IAACT,EAAgB,WACRO,EAAA;AAAA,EACb,GACC,CAACjB,GAAUiB,CAAU,CAAC;AAGzB,QAAMI,IAAgC;AAAA,IACpC,QAAQpB;AAAA,IACR,WAAW;AAAA,IACX,gBAAAE;AAAA,IACA,UAAU;AAAA,EACZ;AAGE,SAAAmB,gBAAAA,EAAA,IAAC,OAAI,EAAA,KAAKd,GAAc,OAAOa,GAAgB,WAAAjB,GAC7C,UAAAkB,gBAAAA,EAAAA,IAAC,OAAK,EAAA,UAAAtB,EAAA,CAAS,EACjB,CAAA;AAEJ;"}
@@ -0,0 +1 @@
1
+ export { ScrollController } from './ScrollController';
@@ -1,2 +1,3 @@
1
1
  export * from './AiMessageRender';
2
2
  export * from './ShadowDom';
3
+ export * from './ScrollController';
@@ -0,0 +1 @@
1
+ export * from './useDivAutoScroll';
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+
3
+ interface ScrollControllerProps {
4
+ scrollBuffer?: number;
5
+ scrollBehavior?: 'auto' | 'smooth';
6
+ containerRef: React.RefObject<HTMLDivElement | null>;
7
+ }
8
+ export declare function useDivAutoScroll(params: ScrollControllerProps): () => void;
9
+ export {};
@@ -0,0 +1,28 @@
1
+ import { useState as v, useRef as S, useCallback as o, useEffect as A } from "react";
2
+ function d(g) {
3
+ const { scrollBuffer: n = 50, scrollBehavior: s = "smooth", containerRef: r } = g, [u, i] = v(!0), e = S(!1), c = S(), f = o(() => {
4
+ if (!r.current) return !1;
5
+ const { scrollHeight: t, scrollTop: m, clientHeight: h } = r.current;
6
+ return t - m - h < n;
7
+ }, [r, n]), a = o(() => {
8
+ u && r.current && r.current.scrollTo({
9
+ top: r.current.scrollHeight,
10
+ behavior: s
11
+ });
12
+ }, [r, u, s]), l = o(() => {
13
+ r.current && (c.current && clearTimeout(c.current), e.current || (e.current = !0), c.current = setTimeout(() => {
14
+ e.current = !1;
15
+ }, 100), f() ? i(!0) : i(!1));
16
+ }, [r, f]);
17
+ return A(() => {
18
+ const t = r.current;
19
+ if (t)
20
+ return t.addEventListener("scroll", l), () => t.removeEventListener("scroll", l);
21
+ }, [r, l]), o(() => {
22
+ e.current || a();
23
+ }, [a, e]);
24
+ }
25
+ export {
26
+ d as useDivAutoScroll
27
+ };
28
+ //# sourceMappingURL=useDivAutoScroll.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDivAutoScroll.es.js","sources":["../../src/hooks/useDivAutoScroll.ts"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\n\ninterface ScrollControllerProps {\n scrollBuffer?: number;\n scrollBehavior?: 'auto' | 'smooth';\n containerRef: React.RefObject<HTMLDivElement | null>;\n}\n\nexport function useDivAutoScroll(params: ScrollControllerProps) {\n const { scrollBuffer = 50, scrollBehavior = 'smooth', containerRef } = params;\n const [isAutoScroll, setIsAutoScroll] = useState(true);\n const isUserScrolling = useRef(false);\n const scrollTimeout = useRef<NodeJS.Timeout>();\n\n // 检测是否接近底部\n const isNearBottom = useCallback(() => {\n if (!containerRef.current) return false;\n const { scrollHeight, scrollTop, clientHeight } = containerRef.current;\n return scrollHeight - scrollTop - clientHeight < scrollBuffer;\n }, [containerRef, scrollBuffer]);\n\n // 自动滚动逻辑\n const autoScroll = useCallback(() => {\n if (isAutoScroll && containerRef.current) {\n containerRef.current.scrollTo({\n top: containerRef.current.scrollHeight,\n behavior: scrollBehavior,\n });\n }\n }, [containerRef, isAutoScroll, scrollBehavior]);\n\n // 处理滚动事件\n const handleScroll = useCallback(() => {\n if (!containerRef.current) return;\n\n // 清除之前的定时器\n if (scrollTimeout.current) clearTimeout(scrollTimeout.current);\n\n // 标记用户滚动行为\n if (!isUserScrolling.current) {\n isUserScrolling.current = true;\n }\n\n // 设置滚动状态重置\n scrollTimeout.current = setTimeout(() => {\n isUserScrolling.current = false;\n }, 100);\n\n // 判断是否接近底部\n if (isNearBottom()) {\n setIsAutoScroll(true);\n } else {\n setIsAutoScroll(false);\n }\n }, [containerRef, isNearBottom]);\n\n // 初始化事件监听\n useEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n\n container.addEventListener('scroll', handleScroll);\n return () => container.removeEventListener('scroll', handleScroll);\n }, [containerRef, handleScroll]);\n\n // 内容变化时自动滚动\n const triggerAutoScroll = useCallback(() => {\n if (!isUserScrolling.current) {\n autoScroll();\n }\n }, [autoScroll, isUserScrolling]);\n\n return triggerAutoScroll;\n}\n"],"names":["useDivAutoScroll","params","scrollBuffer","scrollBehavior","containerRef","isAutoScroll","setIsAutoScroll","useState","isUserScrolling","useRef","scrollTimeout","isNearBottom","useCallback","scrollHeight","scrollTop","clientHeight","autoScroll","handleScroll","useEffect","container"],"mappings":";AAQO,SAASA,EAAiBC,GAA+B;AAC9D,QAAM,EAAE,cAAAC,IAAe,IAAI,gBAAAC,IAAiB,UAAU,cAAAC,MAAiBH,GACjE,CAACI,GAAcC,CAAe,IAAIC,EAAS,EAAI,GAC/CC,IAAkBC,EAAO,EAAK,GAC9BC,IAAgBD,EAAuB,GAGvCE,IAAeC,EAAY,MAAM;AACjC,QAAA,CAACR,EAAa,QAAgB,QAAA;AAClC,UAAM,EAAE,cAAAS,GAAc,WAAAC,GAAW,cAAAC,MAAiBX,EAAa;AACxD,WAAAS,IAAeC,IAAYC,IAAeb;AAAA,EAAA,GAChD,CAACE,GAAcF,CAAY,CAAC,GAGzBc,IAAaJ,EAAY,MAAM;AAC/B,IAAAP,KAAgBD,EAAa,WAC/BA,EAAa,QAAQ,SAAS;AAAA,MAC5B,KAAKA,EAAa,QAAQ;AAAA,MAC1B,UAAUD;AAAA,IAAA,CACX;AAAA,EAEF,GAAA,CAACC,GAAcC,GAAcF,CAAc,CAAC,GAGzCc,IAAeL,EAAY,MAAM;AACjC,IAACR,EAAa,YAGdM,EAAc,WAAsB,aAAAA,EAAc,OAAO,GAGxDF,EAAgB,YACnBA,EAAgB,UAAU,KAIdE,EAAA,UAAU,WAAW,MAAM;AACvC,MAAAF,EAAgB,UAAU;AAAA,OACzB,GAAG,GAGFG,MACFL,EAAgB,EAAI,IAEpBA,EAAgB,EAAK;AAAA,EACvB,GACC,CAACF,GAAcO,CAAY,CAAC;AAG/B,SAAAO,EAAU,MAAM;AACd,UAAMC,IAAYf,EAAa;AAC/B,QAAKe;AAEK,aAAAA,EAAA,iBAAiB,UAAUF,CAAY,GAC1C,MAAME,EAAU,oBAAoB,UAAUF,CAAY;AAAA,EAAA,GAChE,CAACb,GAAca,CAAY,CAAC,GAGLL,EAAY,MAAM;AACtC,IAACJ,EAAgB,WACRQ,EAAA;AAAA,EACb,GACC,CAACA,GAAYR,CAAe,CAAC;AAGlC;"}
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './components';
2
+ export * from './hooks';
package/dist/index.es.js CHANGED
@@ -1,7 +1,11 @@
1
- import { AiMessageRender as r } from "./components/AiMessageRender/AiMessageRender.es.js";
2
- import { ShadowDom as a } from "./components/ShadowDom/ShadowDom.es.js";
1
+ import { AiMessageRender as e } from "./components/AiMessageRender/AiMessageRender.es.js";
2
+ import { ShadowDom as t } from "./components/ShadowDom/ShadowDom.es.js";
3
+ import { ScrollController as f } from "./components/ScrollController/ScrollController.es.js";
4
+ import { useDivAutoScroll as x } from "./hooks/useDivAutoScroll.es.js";
3
5
  export {
4
- r as AiMessageRender,
5
- a as ShadowDom
6
+ e as AiMessageRender,
7
+ f as ScrollController,
8
+ t as ShadowDom,
9
+ x as useDivAutoScroll
6
10
  };
7
11
  //# sourceMappingURL=index.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
1
+ {"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/biz-components",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",