@easyv/biz-components 0.0.35 → 0.0.37
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/dist/components/AiMessageRender/AiMessageRender.d.ts +3 -3
- package/dist/components/AiMessageRender/AiMessageRender.es.js +3 -25
- package/dist/components/AiMessageRender/AiMessageRender.es.js.map +1 -1
- package/dist/components/AiMessageRender/index.d.ts +1 -1
- package/dist/components/AiMessageRender/types.d.ts +15 -6
- package/dist/components/EChartsRender/EchartsRender.d.ts +12 -0
- package/dist/components/EChartsRender/EchartsRender.es.js +36 -0
- package/dist/components/EChartsRender/EchartsRender.es.js.map +1 -0
- package/dist/components/EChartsRender/index.d.ts +2 -0
- package/dist/components/EChartsRender/test/base.cy.d.ts +1 -0
- package/dist/components/EChartsRender/types.d.ts +5 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/hooks/useWatchValue/useWatchValue.d.ts +5 -6
- package/dist/hooks/useWatchValue/useWatchValue.es.js +5 -8
- package/dist/hooks/useWatchValue/useWatchValue.es.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.es.js +2 -0
- package/dist/index.es.js.map +1 -1
- package/dist/node_modules/.pnpm/ahooks@3.8.5_react@18.2.0/node_modules/ahooks/es/useMemoizedFn/index.es.js +29 -0
- package/dist/node_modules/.pnpm/ahooks@3.8.5_react@18.2.0/node_modules/ahooks/es/useMemoizedFn/index.es.js.map +1 -0
- package/dist/node_modules/.pnpm/ahooks@3.8.5_react@18.2.0/node_modules/ahooks/es/utils/index.es.js +7 -0
- package/dist/node_modules/.pnpm/ahooks@3.8.5_react@18.2.0/node_modules/ahooks/es/utils/index.es.js.map +1 -0
- package/dist/node_modules/.pnpm/ahooks@3.8.5_react@18.2.0/node_modules/ahooks/es/utils/isDev.es.js +5 -0
- package/dist/node_modules/.pnpm/ahooks@3.8.5_react@18.2.0/node_modules/ahooks/es/utils/isDev.es.js.map +1 -0
- package/package.json +3 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AiMessageContentItem } from './types';
|
|
2
2
|
|
|
3
3
|
export interface AiMessageRenderProps {
|
|
4
4
|
className?: string;
|
|
5
|
-
contents:
|
|
6
|
-
renderDashboardContent?: (msg:
|
|
5
|
+
contents: AiMessageContentItem[];
|
|
6
|
+
renderDashboardContent?: (msg: AiMessageContentItem) => React.ReactNode;
|
|
7
7
|
showFooterButtons?: boolean;
|
|
8
8
|
onCopy?: () => void;
|
|
9
9
|
onRedo?: () => void;
|
|
@@ -29,34 +29,12 @@ ${markdownStyle}`;
|
|
|
29
29
|
style: finalMarkdownStyle,
|
|
30
30
|
shadowRootDivClassName: markdownClassName + " markdown-container",
|
|
31
31
|
rootFontSize,
|
|
32
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Markdown, { remarkPlugins: [remarkGfm], children: msg })
|
|
32
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Markdown, { remarkPlugins: [remarkGfm], children: msg.text })
|
|
33
33
|
}
|
|
34
34
|
);
|
|
35
35
|
};
|
|
36
36
|
const renderDashboardContent = (msg) => {
|
|
37
|
-
|
|
38
|
-
if (propsRenderDashboardContent) {
|
|
39
|
-
return propsRenderDashboardContent(msg);
|
|
40
|
-
}
|
|
41
|
-
let finalData = data;
|
|
42
|
-
if (filterCode) {
|
|
43
|
-
const filterFunc = new Function("data", filterCode);
|
|
44
|
-
finalData = filterFunc(data);
|
|
45
|
-
}
|
|
46
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
47
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
48
|
-
"组件名称:",
|
|
49
|
-
plotModuleName
|
|
50
|
-
] }),
|
|
51
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
52
|
-
"组件版本:",
|
|
53
|
-
plotVersion
|
|
54
|
-
] }),
|
|
55
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
56
|
-
"组件数据:",
|
|
57
|
-
finalData.slice(0, 5).map((i) => JSON.stringify(i))
|
|
58
|
-
] })
|
|
59
|
-
] });
|
|
37
|
+
return propsRenderDashboardContent == null ? void 0 : propsRenderDashboardContent(msg);
|
|
60
38
|
};
|
|
61
39
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
62
40
|
"div",
|
|
@@ -68,7 +46,7 @@ ${markdownStyle}`;
|
|
|
68
46
|
),
|
|
69
47
|
children: [
|
|
70
48
|
contents.map((msg, index) => {
|
|
71
|
-
if (
|
|
49
|
+
if (msg.text) {
|
|
72
50
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "biz-contents", children: renderStringContent(msg) }, index);
|
|
73
51
|
} else {
|
|
74
52
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "biz-contents", children: renderDashboardContent(msg) }, index);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiMessageRender.es.js","sources":["../../../src/components/AiMessageRender/AiMessageRender.tsx"],"sourcesContent":["import { CopyCircleOutlined } from '@easyv/react-icons';\nimport classNames from 'classnames';\nimport Markdown from 'react-markdown';\nimport remarkGfm from 'remark-gfm';\nimport { ShadowDom } from '../ShadowDom';\nimport messageRenderCss from './index.less?raw';\nimport {
|
|
1
|
+
{"version":3,"file":"AiMessageRender.es.js","sources":["../../../src/components/AiMessageRender/AiMessageRender.tsx"],"sourcesContent":["import { CopyCircleOutlined } from '@easyv/react-icons';\nimport classNames from 'classnames';\nimport Markdown from 'react-markdown';\nimport remarkGfm from 'remark-gfm';\nimport { ShadowDom } from '../ShadowDom';\nimport messageRenderCss from './index.less?raw';\nimport { AiMessageContentItem } from './types';\n\nexport interface AiMessageRenderProps {\n className?: string;\n contents: AiMessageContentItem[];\n renderDashboardContent?: (msg: AiMessageContentItem) => React.ReactNode;\n showFooterButtons?: boolean;\n onCopy?: () => void;\n onRedo?: () => void;\n markdownClassName?: string;\n rootFontSize?: number;\n /**隐藏默认样式 */\n hideDefaultStyle?: boolean;\n markdownStyle?: string;\n}\n\nexport const AiMessageRender = (props: AiMessageRenderProps) => {\n const {\n className = '',\n onCopy,\n renderDashboardContent: propsRenderDashboardContent,\n showFooterButtons = false,\n contents,\n markdownClassName = '',\n rootFontSize,\n hideDefaultStyle,\n markdownStyle,\n } = props;\n\n let finalMarkdownStyle = hideDefaultStyle ? '' : messageRenderCss;\n if (markdownStyle) {\n finalMarkdownStyle += `\\n${markdownStyle}`;\n }\n const renderStringContent = (msg: AiMessageContentItem) => {\n return (\n <ShadowDom\n style={finalMarkdownStyle}\n shadowRootDivClassName={markdownClassName + ' markdown-container'}\n rootFontSize={rootFontSize}\n >\n <Markdown remarkPlugins={[remarkGfm]}>{msg.text}</Markdown>\n </ShadowDom>\n );\n };\n const renderDashboardContent = (msg: AiMessageContentItem) => {\n return propsRenderDashboardContent?.(msg);\n };\n\n return (\n <div\n className={classNames(\n 'biz-px-4 biz-py-3 biz-flex biz-flex-col biz-gap-3 biz-rounded-lg',\n 'biz-bg-[#FFFFFF14] biz-select-text',\n className,\n )}\n >\n {contents.map((msg, index) => {\n if (msg.text) {\n return (\n <div key={index} className='biz-contents'>\n {renderStringContent(msg)}\n </div>\n );\n } else {\n return (\n <div key={index} className='biz-contents'>\n {renderDashboardContent(msg)}\n </div>\n );\n }\n })}\n {showFooterButtons && (\n <div className='biz-flex biz-gap-1'>\n <div className='copy-btn biz-w-6 biz-h-6 biz-rounded-md biz-flex biz-justify-center biz-items-center biz-hover:bg-bg-white biz-cursor-pointer'>\n <CopyCircleOutlined\n className='biz-w-3.5 biz-h-3.5 biz-text-text-2'\n onClick={() => onCopy?.()}\n />\n </div>\n {/* <div className='redo-btn biz-w-6 biz-h-6 biz-rounded-md biz-flex biz-justify-center biz-items-center biz-hover:bg-bg-white biz-cursor-pointer'>\n <RedoOutlined className='biz-w-3.5 biz-h-3.5 biz-text-text-2' />\n </div> */}\n </div>\n )}\n </div>\n );\n};\n"],"names":["jsx","jsxs"],"mappings":";;;;;;;AAsBa,MAAA,kBAAkB,CAAC,UAAgC;AACxD,QAAA;AAAA,IACJ,YAAY;AAAA,IACZ;AAAA,IACA,wBAAwB;AAAA,IACxB,oBAAoB;AAAA,IACpB;AAAA,IACA,oBAAoB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE;AAEA,MAAA,qBAAqB,mBAAmB,KAAK;AACjD,MAAI,eAAe;AACK,0BAAA;AAAA,EAAK,aAAa;AAAA,EAAA;AAEpC,QAAA,sBAAsB,CAAC,QAA8B;AAEvD,WAAAA,kCAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,OAAO;AAAA,QACP,wBAAwB,oBAAoB;AAAA,QAC5C;AAAA,QAEA,gDAAC,UAAS,EAAA,eAAe,CAAC,SAAS,GAAI,cAAI,KAAK,CAAA;AAAA,MAAA;AAAA,IAClD;AAAA,EAEJ;AACM,QAAA,yBAAyB,CAAC,QAA8B;AAC5D,WAAO,2EAA8B;AAAA,EACvC;AAGE,SAAAC,kCAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MAEC,UAAA;AAAA,QAAS,SAAA,IAAI,CAAC,KAAK,UAAU;AAC5B,cAAI,IAAI,MAAM;AACZ,yDACG,OAAgB,EAAA,WAAU,gBACxB,UAAoB,oBAAA,GAAG,KADhB,KAEV;AAAA,UAAA,OAEG;AACL,yDACG,OAAgB,EAAA,WAAU,gBACxB,UAAuB,uBAAA,GAAG,KADnB,KAEV;AAAA,UAAA;AAAA,QAEJ,CACD;AAAA,QACA,2DACE,OAAI,EAAA,WAAU,sBACb,UAACD,kCAAA,IAAA,OAAA,EAAI,WAAU,iIACb,UAAAA,kCAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,SAAS,MAAM;AAAA,UAAS;AAAA,WAE5B,EAIF,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAEJ;AAEJ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { AiMessageRender } from './AiMessageRender';
|
|
2
|
-
export
|
|
2
|
+
export * from './types';
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
|
|
1
|
+
export interface EchartsPlot {
|
|
2
|
+
option: object;
|
|
3
3
|
filterCode?: string;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
}
|
|
5
|
+
export interface EasyvPlot {
|
|
6
|
+
filterCode?: string;
|
|
7
|
+
data: any[];
|
|
6
8
|
plotModuleName: string;
|
|
7
|
-
/** 组件版本 */
|
|
8
9
|
plotVersion: string;
|
|
9
|
-
extraConfig
|
|
10
|
+
extraConfig?: object;
|
|
11
|
+
}
|
|
12
|
+
export interface AiMessageContentItem {
|
|
13
|
+
/** 文本消息 */
|
|
14
|
+
text?: string;
|
|
15
|
+
/** easyv 图表消息 */
|
|
16
|
+
plotContext?: EasyvPlot;
|
|
17
|
+
/** echarts 图表消息 */
|
|
18
|
+
echartsContext?: EchartsPlot;
|
|
10
19
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ECOption } from './types';
|
|
2
|
+
import type * as EchartsInner from 'echarts';
|
|
3
|
+
export interface EchartsRenderProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
className?: string;
|
|
5
|
+
echarts: typeof EchartsInner;
|
|
6
|
+
option: ECOption;
|
|
7
|
+
theme?: 'light' | 'dark';
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Echarts 渲染组件. 基础示例参考本仓库同层级的 test/base.cy.tsx 文件
|
|
11
|
+
*/
|
|
12
|
+
export declare const EchartsRender: (props: EchartsRenderProps) => JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { j as jsxRuntimeExports } from "../../node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.es.js";
|
|
2
|
+
import { useState, useRef, useEffect } from "react";
|
|
3
|
+
import useMemoizedFn from "../../node_modules/.pnpm/ahooks@3.8.5_react@18.2.0/node_modules/ahooks/es/useMemoizedFn/index.es.js";
|
|
4
|
+
import classNames from "../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.es.js";
|
|
5
|
+
import { useWatchValue } from "../../hooks/useWatchValue/useWatchValue.es.js";
|
|
6
|
+
const EchartsRender = (props) => {
|
|
7
|
+
const { className = "", echarts, option, theme = "dark", ...rest } = props;
|
|
8
|
+
const [echartsInstance, setEchartsInstance] = useState(null);
|
|
9
|
+
const divRef = useRef(null);
|
|
10
|
+
const initEcharts = useMemoizedFn(() => {
|
|
11
|
+
const myChart = echarts.init(divRef.current, theme);
|
|
12
|
+
myChart.setOption(option);
|
|
13
|
+
setEchartsInstance(myChart);
|
|
14
|
+
});
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
initEcharts();
|
|
17
|
+
}, [initEcharts]);
|
|
18
|
+
useWatchValue({
|
|
19
|
+
value: option,
|
|
20
|
+
callback: () => {
|
|
21
|
+
echartsInstance == null ? void 0 : echartsInstance.setOption(option);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
useWatchValue({
|
|
25
|
+
value: theme,
|
|
26
|
+
callback: () => {
|
|
27
|
+
echarts == null ? void 0 : echarts.dispose(divRef.current);
|
|
28
|
+
initEcharts();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: classNames("biz-min-h-10", className), ref: divRef, ...rest, children: "EchartsRender" });
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
EchartsRender
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=EchartsRender.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EchartsRender.es.js","sources":["../../../src/components/EChartsRender/EchartsRender.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { useMemoizedFn } from 'ahooks';\nimport classNames from 'classnames';\nimport type * as EchartsInner from 'echarts';\nimport { useWatchValue } from '@/hooks';\nimport { ECOption } from './types';\n\nexport interface EchartsRenderProps extends React.HTMLAttributes<HTMLDivElement> {\n className?: string;\n echarts: typeof EchartsInner;\n option: ECOption;\n theme?: 'light' | 'dark';\n}\n\n/**\n * Echarts 渲染组件. 基础示例参考本仓库同层级的 test/base.cy.tsx 文件\n */\nexport const EchartsRender = (props: EchartsRenderProps) => {\n const { className = '', echarts, option: option, theme = 'dark', ...rest } = props;\n const [echartsInstance, setEchartsInstance] = useState<EchartsInner.ECharts | null>(null);\n const divRef = useRef<HTMLDivElement>(null);\n\n const initEcharts = useMemoizedFn(() => {\n const myChart = echarts.init(divRef.current!, theme);\n myChart.setOption(option);\n setEchartsInstance(myChart);\n });\n\n useEffect(() => {\n initEcharts();\n }, [initEcharts]);\n\n useWatchValue({\n value: option,\n callback: () => {\n echartsInstance?.setOption(option);\n },\n });\n useWatchValue({\n value: theme,\n callback: () => {\n echarts?.dispose(divRef.current!); // 销毁当前图表\n initEcharts();\n },\n });\n\n return (\n <div className={classNames('biz-min-h-10', className)} ref={divRef} {...rest}>\n EchartsRender\n </div>\n );\n};\n"],"names":["jsx"],"mappings":";;;;;AAiBa,MAAA,gBAAgB,CAAC,UAA8B;AACpD,QAAA,EAAE,YAAY,IAAI,SAAS,QAAgB,QAAQ,QAAQ,GAAG,KAAA,IAAS;AAC7E,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,SAAsC,IAAI;AAClF,QAAA,SAAS,OAAuB,IAAI;AAEpC,QAAA,cAAc,cAAc,MAAM;AACtC,UAAM,UAAU,QAAQ,KAAK,OAAO,SAAU,KAAK;AACnD,YAAQ,UAAU,MAAM;AACxB,uBAAmB,OAAO;AAAA,EAAA,CAC3B;AAED,YAAU,MAAM;AACF,gBAAA;AAAA,EAAA,GACX,CAAC,WAAW,CAAC;AAEF,gBAAA;AAAA,IACZ,OAAO;AAAA,IACP,UAAU,MAAM;AACd,yDAAiB,UAAU;AAAA,IAAM;AAAA,EACnC,CACD;AACa,gBAAA;AAAA,IACZ,OAAO;AAAA,IACP,UAAU,MAAM;AACL,yCAAA,QAAQ,OAAO;AACZ,kBAAA;AAAA,IAAA;AAAA,EACd,CACD;AAGC,SAAAA,kCAAA,IAAC,OAAI,EAAA,WAAW,WAAW,gBAAgB,SAAS,GAAG,KAAK,QAAS,GAAG,MAAM,UAE9E,gBAAA,CAAA;AAEJ;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BarSeriesOption, LineSeriesOption } from 'echarts/charts';
|
|
2
|
+
import { DatasetComponentOption, GridComponentOption, TitleComponentOption, TooltipComponentOption } from 'echarts/components';
|
|
3
|
+
import { ComposeOption } from 'echarts/core';
|
|
4
|
+
|
|
5
|
+
export type ECOption = ComposeOption<BarSeriesOption | LineSeriesOption | TitleComponentOption | TooltipComponentOption | GridComponentOption | DatasetComponentOption>;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
type BaseValueType = string | number | boolean | object | Array<unknown> | null | undefined;
|
|
2
2
|
interface Params<T> {
|
|
3
3
|
value: T;
|
|
4
|
-
callback: (newValue: T, oldValue?: T
|
|
4
|
+
callback: (newValue: T, oldValue?: T) => void | Promise<void> | (() => void);
|
|
5
5
|
options?: {
|
|
6
6
|
equalFn?: (value1: T, value2: T) => boolean;
|
|
7
7
|
immediate?: boolean;
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @param params { value: T; callback: (newValue: T, oldValue?: T) => void | Promise<void>; options?: { equalFn: (value1: T, value2: T) => boolean; immediate?: boolean; }}
|
|
14
|
-
* - 注意:如果你需要使用 useEffect 的 cleanUp 函数,可以考虑在 callback 中使用。或者使用 useEffect。
|
|
10
|
+
/**监听值变化,
|
|
11
|
+
* 值变化时调用 callback
|
|
12
|
+
* 判断值是否变化默认使用 lodash 的 isEqual
|
|
13
|
+
* @param params { value: T; callback: (newValue: T, oldValue?: T) => void | Promise<void>; options?: { equalFn: (value1: T, value2: T) => boolean; immediate?: boolean; } }
|
|
15
14
|
*/
|
|
16
15
|
export declare function useWatchValue<T extends BaseValueType>(params: Params<T>): void;
|
|
17
16
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { useRef, useEffect } from "react";
|
|
2
2
|
import isEqual from "../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isEqual.es.js";
|
|
3
|
+
const initValue = Symbol("initValue");
|
|
3
4
|
function useWatchValue(params) {
|
|
4
5
|
const { value, callback, options } = params;
|
|
5
|
-
const ref = useRef(
|
|
6
|
+
const ref = useRef(initValue);
|
|
6
7
|
const initialRef = useRef(false);
|
|
7
8
|
const { equalFn = isEqual, immediate } = options || {};
|
|
8
9
|
const fnObj = useRef({
|
|
@@ -22,16 +23,12 @@ function useWatchValue(params) {
|
|
|
22
23
|
immediate: immediateInner
|
|
23
24
|
} = fnObj.current;
|
|
24
25
|
if (immediateInner && !initialRef.current) {
|
|
25
|
-
callbackInner(value);
|
|
26
|
-
ref.current = value;
|
|
27
|
-
}
|
|
28
|
-
if (initialRef.current === false) {
|
|
26
|
+
callbackInner(value, value);
|
|
29
27
|
initialRef.current = true;
|
|
30
28
|
}
|
|
31
|
-
|
|
32
|
-
if (ref.current === void 0) {
|
|
29
|
+
if (ref.current === initValue) {
|
|
33
30
|
ref.current = value;
|
|
34
|
-
} else if (
|
|
31
|
+
} else if (equalFnInner(value, ref.current) === false) {
|
|
35
32
|
callbackInner(value, ref.current);
|
|
36
33
|
ref.current = value;
|
|
37
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWatchValue.es.js","sources":["../../../src/hooks/useWatchValue/useWatchValue.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { isEqual } from 'lodash-es';\n\ntype BaseValueType = string | number | boolean | object | Array<unknown> | null | undefined;\n\ninterface Params<T> {\n value: T;\n callback: (newValue: T, oldValue?: T
|
|
1
|
+
{"version":3,"file":"useWatchValue.es.js","sources":["../../../src/hooks/useWatchValue/useWatchValue.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { isEqual } from 'lodash-es';\n\ntype BaseValueType = string | number | boolean | object | Array<unknown> | null | undefined;\n\nconst initValue = Symbol('initValue');\n\ninterface Params<T> {\n value: T;\n callback: (newValue: T, oldValue?: T) => void | Promise<void> | (() => void);\n options?: {\n equalFn?: (value1: T, value2: T) => boolean;\n immediate?: boolean;\n };\n}\n/**监听值变化,\n * 值变化时调用 callback\n * 判断值是否变化默认使用 lodash 的 isEqual\n * @param params { value: T; callback: (newValue: T, oldValue?: T) => void | Promise<void>; options?: { equalFn: (value1: T, value2: T) => boolean; immediate?: boolean; } }\n */\nexport function useWatchValue<T extends BaseValueType>(params: Params<T>) {\n const { value, callback, options } = params;\n const ref = useRef<T | typeof initValue>(initValue);\n const initialRef = useRef(false);\n\n const { equalFn = isEqual, immediate } = options || {};\n\n const fnObj = useRef({\n callback,\n equalFn,\n immediate,\n });\n fnObj.current = {\n callback,\n equalFn,\n immediate,\n };\n\n useEffect(() => {\n const {\n callback: callbackInner,\n equalFn: equalFnInner,\n immediate: immediateInner,\n } = fnObj.current;\n if (immediateInner && !initialRef.current) {\n callbackInner(value, value);\n initialRef.current = true;\n }\n\n if (ref.current === initValue) {\n ref.current = value;\n } else if (equalFnInner(value, ref.current) === false) {\n callbackInner(value, ref.current as T);\n ref.current = value;\n }\n }, [value]);\n}\n"],"names":[],"mappings":";;AAKA,MAAM,YAAY,OAAO,WAAW;AAe7B,SAAS,cAAuC,QAAmB;AACxE,QAAM,EAAE,OAAO,UAAU,QAAY,IAAA;AAC/B,QAAA,MAAM,OAA6B,SAAS;AAC5C,QAAA,aAAa,OAAO,KAAK;AAE/B,QAAM,EAAE,UAAU,SAAS,UAAU,IAAI,WAAW,CAAC;AAErD,QAAM,QAAQ,OAAO;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AACD,QAAM,UAAU;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,YAAU,MAAM;AACR,UAAA;AAAA,MACJ,UAAU;AAAA,MACV,SAAS;AAAA,MACT,WAAW;AAAA,QACT,MAAM;AACN,QAAA,kBAAkB,CAAC,WAAW,SAAS;AACzC,oBAAc,OAAO,KAAK;AAC1B,iBAAW,UAAU;AAAA,IAAA;AAGnB,QAAA,IAAI,YAAY,WAAW;AAC7B,UAAI,UAAU;AAAA,IAAA,WACL,aAAa,OAAO,IAAI,OAAO,MAAM,OAAO;AACvC,oBAAA,OAAO,IAAI,OAAY;AACrC,UAAI,UAAU;AAAA,IAAA;AAAA,EAChB,GACC,CAAC,KAAK,CAAC;AACZ;"}
|
package/dist/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }body .biz-flex{display:flex}body .biz-contents{display:contents}body .biz-h-3\.5{height:.875rem}body .biz-h-6{height:1.5rem}body .biz-h-full{height:100%}body .biz-w-3\.5{width:.875rem}body .biz-w-6{width:1.5rem}body .biz-w-\[0\.4rem\]{width:.4rem}body .biz-cursor-pointer{cursor:pointer}body .biz-select-text{-webkit-user-select:text;-moz-user-select:text;user-select:text}body .biz-flex-col{flex-direction:column}body .biz-items-center{align-items:center}body .biz-justify-center{justify-content:center}body .biz-justify-between{justify-content:space-between}body .biz-gap-1{gap:.25rem}body .biz-gap-3{gap:.75rem}body .biz-rounded-full{border-radius:9999px}body .biz-rounded-lg{border-radius:.5rem}body .biz-rounded-md{border-radius:.375rem}body .biz-bg-\[\#FFFFFF14\]{background-color:#ffffff14}body .biz-px-4{padding-left:1rem;padding-right:1rem}body .biz-py-3{padding-bottom:.75rem;padding-top:.75rem}body .biz-text-text-2{--tw-text-opacity:1;color:rgb(180 183 193/var(--tw-text-opacity,1))}
|
|
1
|
+
*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }body .biz-flex{display:flex}body .biz-contents{display:contents}body .biz-h-3\.5{height:.875rem}body .biz-h-6{height:1.5rem}body .biz-h-full{height:100%}body .biz-min-h-10{min-height:2.5rem}body .biz-w-3\.5{width:.875rem}body .biz-w-6{width:1.5rem}body .biz-w-\[0\.4rem\]{width:.4rem}body .biz-cursor-pointer{cursor:pointer}body .biz-select-text{-webkit-user-select:text;-moz-user-select:text;user-select:text}body .biz-flex-col{flex-direction:column}body .biz-items-center{align-items:center}body .biz-justify-center{justify-content:center}body .biz-justify-between{justify-content:space-between}body .biz-gap-1{gap:.25rem}body .biz-gap-3{gap:.75rem}body .biz-rounded-full{border-radius:9999px}body .biz-rounded-lg{border-radius:.5rem}body .biz-rounded-md{border-radius:.375rem}body .biz-bg-\[\#FFFFFF14\]{background-color:#ffffff14}body .biz-px-4{padding-left:1rem;padding-right:1rem}body .biz-py-3{padding-bottom:.75rem;padding-top:.75rem}body .biz-text-text-2{--tw-text-opacity:1;color:rgb(180 183 193/var(--tw-text-opacity,1))}
|
package/dist/index.es.js
CHANGED
|
@@ -2,6 +2,7 @@ import { AiMessageRender } from "./components/AiMessageRender/AiMessageRender.es
|
|
|
2
2
|
import { ShadowDom } from "./components/ShadowDom/ShadowDom.es.js";
|
|
3
3
|
import { ScrollController } from "./components/ScrollController/ScrollController.es.js";
|
|
4
4
|
import { VoiceAnimation } from "./components/VoiceAnimation/VoiceAnimation.es.js";
|
|
5
|
+
import { EchartsRender } from "./components/EChartsRender/EchartsRender.es.js";
|
|
5
6
|
import { useDivAutoScroll } from "./hooks/useDivAutoScroll.es.js";
|
|
6
7
|
import { useXunFeiSteamVoiceManager } from "./hooks/useXunFeiSteamVoiceManager.es.js";
|
|
7
8
|
import { useInitialized } from "./hooks/useInitialized.es.js";
|
|
@@ -11,6 +12,7 @@ import { XFStreamVoiceManager } from "./utils/xunFeiVoice/XFStreamVoiceManager.e
|
|
|
11
12
|
import { RecorderManager } from "./utils/xunFeiVoice/RecorderManager/RecorderManager.es.js";
|
|
12
13
|
export {
|
|
13
14
|
AiMessageRender,
|
|
15
|
+
EchartsRender,
|
|
14
16
|
FunASRManager,
|
|
15
17
|
RecorderManager,
|
|
16
18
|
ScrollController,
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useRef, useMemo } from "react";
|
|
2
|
+
import { isFunction } from "../utils/index.es.js";
|
|
3
|
+
import isDev from "../utils/isDev.es.js";
|
|
4
|
+
function useMemoizedFn(fn) {
|
|
5
|
+
if (isDev) {
|
|
6
|
+
if (!isFunction(fn)) {
|
|
7
|
+
console.error("useMemoizedFn expected parameter is a function, got ".concat(typeof fn));
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
var fnRef = useRef(fn);
|
|
11
|
+
fnRef.current = useMemo(function() {
|
|
12
|
+
return fn;
|
|
13
|
+
}, [fn]);
|
|
14
|
+
var memoizedFn = useRef();
|
|
15
|
+
if (!memoizedFn.current) {
|
|
16
|
+
memoizedFn.current = function() {
|
|
17
|
+
var args = [];
|
|
18
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
19
|
+
args[_i] = arguments[_i];
|
|
20
|
+
}
|
|
21
|
+
return fnRef.current.apply(this, args);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return memoizedFn.current;
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
useMemoizedFn as default
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=index.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../../../../../../../../../node_modules/.pnpm/ahooks@3.8.5_react@18.2.0/node_modules/ahooks/es/useMemoizedFn/index.js"],"sourcesContent":["import { useMemo, useRef } from 'react';\nimport { isFunction } from '../utils';\nimport isDev from '../utils/isDev';\nfunction useMemoizedFn(fn) {\n if (isDev) {\n if (!isFunction(fn)) {\n console.error(\"useMemoizedFn expected parameter is a function, got \".concat(typeof fn));\n }\n }\n var fnRef = useRef(fn);\n // why not write `fnRef.current = fn`?\n // https://github.com/alibaba/hooks/issues/728\n fnRef.current = useMemo(function () {\n return fn;\n }, [fn]);\n var memoizedFn = useRef();\n if (!memoizedFn.current) {\n memoizedFn.current = function () {\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n return fnRef.current.apply(this, args);\n };\n }\n return memoizedFn.current;\n}\nexport default useMemoizedFn;"],"names":[],"mappings":";;;AAGA,SAAS,cAAc,IAAI;AACzB,MAAI,OAAO;AACT,QAAI,CAAC,WAAW,EAAE,GAAG;AACnB,cAAQ,MAAM,uDAAuD,OAAO,OAAO,EAAE,CAAC;AAAA,IAC5F;AAAA,EACA;AACE,MAAI,QAAQ,OAAO,EAAE;AAGrB,QAAM,UAAU,QAAQ,WAAY;AAClC,WAAO;AAAA,EACX,GAAK,CAAC,EAAE,CAAC;AACP,MAAI,aAAa,OAAQ;AACzB,MAAI,CAAC,WAAW,SAAS;AACvB,eAAW,UAAU,WAAY;AAC/B,UAAI,OAAO,CAAE;AACb,eAAS,KAAK,GAAG,KAAK,UAAU,QAAQ,MAAM;AAC5C,aAAK,EAAE,IAAI,UAAU,EAAE;AAAA,MAC/B;AACM,aAAO,MAAM,QAAQ,MAAM,MAAM,IAAI;AAAA,IACtC;AAAA,EACL;AACE,SAAO,WAAW;AACpB;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../../../../../../../../../node_modules/.pnpm/ahooks@3.8.5_react@18.2.0/node_modules/ahooks/es/utils/index.js"],"sourcesContent":["export var isObject = function (value) {\n return value !== null && typeof value === 'object';\n};\nexport var isFunction = function (value) {\n return typeof value === 'function';\n};\nexport var isString = function (value) {\n return typeof value === 'string';\n};\nexport var isBoolean = function (value) {\n return typeof value === 'boolean';\n};\nexport var isNumber = function (value) {\n return typeof value === 'number';\n};\nexport var isUndef = function (value) {\n return typeof value === 'undefined';\n};"],"names":[],"mappings":"AAGU,IAAC,aAAa,SAAU,OAAO;AACvC,SAAO,OAAO,UAAU;AAC1B;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isDev.es.js","sources":["../../../../../../../../../../node_modules/.pnpm/ahooks@3.8.5_react@18.2.0/node_modules/ahooks/es/utils/isDev.js"],"sourcesContent":["var isDev = process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test';\nexport default isDev;"],"names":[],"mappings":"AAAG,IAAC,QAAQ,QAAQ,IAAI,aAAa,iBAAiB,QAAQ,IAAI,aAAa;","x_google_ignoreList":[0]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easyv/biz-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.es.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"sideEffects": false,
|
|
12
12
|
"dependencies": {
|
|
13
|
+
"ahooks": "^3.8.5",
|
|
13
14
|
"classnames": "^2.5.1",
|
|
14
15
|
"co-web-worker": "^1.0.1",
|
|
15
16
|
"crypto-js": "^4.2.0",
|
|
@@ -20,6 +21,7 @@
|
|
|
20
21
|
},
|
|
21
22
|
"peerDependencies": {
|
|
22
23
|
"@easyv/react-icons": "6.3.0",
|
|
24
|
+
"echarts": "5.4.1",
|
|
23
25
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
24
26
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
25
27
|
},
|