@xiping/react-components 0.0.50 → 0.0.57
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/LICENSE +21 -0
- package/dist/cjs/App.d.ts +2 -0
- package/dist/cjs/components/button/Button.d.ts +24 -0
- package/dist/cjs/components/button/Button.js +1 -0
- package/dist/cjs/components/image-viewer/ImageViewer.d.ts +7 -0
- package/dist/cjs/components/image-viewer/ImageViewer.js +1 -0
- package/dist/cjs/components/image-viewer/index.d.ts +3 -0
- package/dist/cjs/components/pinch-content/PinchContent.d.ts +13 -0
- package/dist/cjs/components/pinch-content/PinchContent.js +1 -0
- package/dist/cjs/components/pinch-content/index.d.ts +4 -0
- package/dist/cjs/components/pinch-content/index.js +1 -0
- package/dist/cjs/components/translate/Translate.d.ts +5 -0
- package/dist/cjs/components/txt-reader/TxtReader.d.ts +14 -0
- package/dist/cjs/components/txt-reader/TxtReader.js +1 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/main.d.ts +0 -0
- package/dist/cjs/node_modules/.pnpm/react-icons@5.4.0_react@18.3.1/node_modules/react-icons/io5/index.js +1 -0
- package/dist/cjs/node_modules/.pnpm/react-icons@5.4.0_react@18.3.1/node_modules/react-icons/lib/iconBase.js +1 -0
- package/dist/cjs/node_modules/.pnpm/react-icons@5.4.0_react@18.3.1/node_modules/react-icons/lib/iconContext.js +1 -0
- package/dist/cjs/pages/home/Home.d.ts +2 -0
- package/dist/cjs/react-components.css +1 -0
- package/dist/es/App.d.ts +2 -0
- package/dist/es/components/button/Button.d.ts +24 -0
- package/dist/{components → es/components}/button/Button.js +34 -35
- package/dist/es/components/image-viewer/ImageViewer.d.ts +7 -0
- package/dist/es/components/image-viewer/ImageViewer.js +39 -0
- package/dist/es/components/image-viewer/index.d.ts +3 -0
- package/dist/es/components/pinch-content/PinchContent.d.ts +13 -0
- package/dist/es/components/pinch-content/PinchContent.js +61 -0
- package/dist/es/components/pinch-content/index.d.ts +4 -0
- package/dist/es/components/pinch-content/index.js +5 -0
- package/dist/es/components/translate/Translate.d.ts +5 -0
- package/dist/es/components/txt-reader/TxtReader.d.ts +14 -0
- package/dist/es/components/txt-reader/TxtReader.js +68 -0
- package/dist/es/index.d.ts +4 -0
- package/dist/es/index.js +11 -0
- package/dist/es/main.d.ts +0 -0
- package/dist/es/node_modules/.pnpm/react-icons@5.4.0_react@18.3.1/node_modules/react-icons/io5/index.js +8 -0
- package/dist/es/node_modules/.pnpm/react-icons@5.4.0_react@18.3.1/node_modules/react-icons/lib/iconBase.js +108 -0
- package/dist/es/node_modules/.pnpm/react-icons@5.4.0_react@18.3.1/node_modules/react-icons/lib/iconContext.js +12 -0
- package/dist/es/pages/home/Home.d.ts +2 -0
- package/dist/es/react-components.css +1 -0
- package/dist/es/vite.svg +1 -0
- package/package.json +20 -10
- package/dist/_virtual/jsx-runtime.js +0 -6
- package/dist/_virtual/jsx-runtime.js.map +0 -1
- package/dist/_virtual/jsx-runtime2.js +0 -5
- package/dist/_virtual/jsx-runtime2.js.map +0 -1
- package/dist/_virtual/react-jsx-runtime.development.js +0 -5
- package/dist/_virtual/react-jsx-runtime.development.js.map +0 -1
- package/dist/_virtual/react-jsx-runtime.production.min.js +0 -5
- package/dist/_virtual/react-jsx-runtime.production.min.js.map +0 -1
- package/dist/components/button/Button.js.map +0 -1
- package/dist/components/txt-reader/TxtReader.js +0 -69
- package/dist/components/txt-reader/TxtReader.js.map +0 -1
- package/dist/index.js +0 -8
- package/dist/index.js.map +0 -1
- package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.development.js +0 -609
- package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.development.js.map +0 -1
- package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.production.min.js +0 -29
- package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.production.min.js.map +0 -1
- package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js +0 -11
- package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js.map +0 -1
- package/dist/react-components.css +0 -1
- /package/dist/{vite.svg → cjs/vite.svg} +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xiping/react-components",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.57",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"sideEffects": false,
|
|
12
12
|
"scripts": {
|
|
13
13
|
"dev": "vite",
|
|
14
|
-
"build": "vite build",
|
|
14
|
+
"build": "tsc && vite build",
|
|
15
15
|
"lint": "eslint ",
|
|
16
16
|
"preview": "vite preview",
|
|
17
|
-
"storybook": "storybook dev -p
|
|
17
|
+
"storybook": "storybook dev -p 6008",
|
|
18
18
|
"build-storybook": "storybook build"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
@@ -22,20 +22,29 @@
|
|
|
22
22
|
"react-dom": ">=18 || >= 19"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
+
"@nextui-org/button": "^2.2.9",
|
|
26
|
+
"@nextui-org/modal": "^2.2.7",
|
|
27
|
+
"@nextui-org/react": "^2.6.11",
|
|
28
|
+
"@nextui-org/system": "^2.4.6",
|
|
29
|
+
"@nextui-org/theme": "^2.4.5",
|
|
30
|
+
"@react-spring/web": "^9.7.5",
|
|
31
|
+
"@use-gesture/react": "^10.3.1",
|
|
25
32
|
"ahooks": "^3.8.4",
|
|
26
33
|
"axios": "^1.7.9",
|
|
27
34
|
"clsx": "^2.1.1",
|
|
28
35
|
"dayjs": "^1.11.13",
|
|
36
|
+
"framer-motion": "^11.17.0",
|
|
29
37
|
"lodash-es": "^4.17.21",
|
|
30
38
|
"react": "^18.3.1",
|
|
31
39
|
"react-dom": "^18.3.1",
|
|
32
40
|
"react-icons": "^5.4.0",
|
|
33
41
|
"react-router-dom": "^7.1.1",
|
|
34
|
-
"zustand": "^5.0.
|
|
42
|
+
"zustand": "^5.0.3"
|
|
35
43
|
},
|
|
36
44
|
"devDependencies": {
|
|
37
45
|
"@chromatic-com/storybook": "^3.2.3",
|
|
38
46
|
"@eslint/js": "^9.17.0",
|
|
47
|
+
"@faker-js/faker": "^9.3.0",
|
|
39
48
|
"@storybook/addon-essentials": "^8.4.7",
|
|
40
49
|
"@storybook/addon-interactions": "^8.4.7",
|
|
41
50
|
"@storybook/addon-onboarding": "^8.4.7",
|
|
@@ -44,7 +53,7 @@
|
|
|
44
53
|
"@storybook/react-vite": "^8.4.7",
|
|
45
54
|
"@storybook/test": "^8.4.7",
|
|
46
55
|
"@types/lodash-es": "^4.17.12",
|
|
47
|
-
"@types/node": "^22.10.
|
|
56
|
+
"@types/node": "^22.10.5",
|
|
48
57
|
"@types/react": "^18.3.18",
|
|
49
58
|
"@types/react-dom": "^18.3.5",
|
|
50
59
|
"@vitejs/plugin-react": "^4.3.4",
|
|
@@ -52,7 +61,7 @@
|
|
|
52
61
|
"eslint": "^9.17.0",
|
|
53
62
|
"eslint-plugin-react-hooks": "^5.1.0",
|
|
54
63
|
"eslint-plugin-react-refresh": "^0.4.16",
|
|
55
|
-
"eslint-plugin-storybook": "^0.11.
|
|
64
|
+
"eslint-plugin-storybook": "^0.11.2",
|
|
56
65
|
"globals": "^15.14.0",
|
|
57
66
|
"postcss": "^8.4.49",
|
|
58
67
|
"prettier": "^3.4.2",
|
|
@@ -61,10 +70,11 @@
|
|
|
61
70
|
"svgo": "^3.3.2",
|
|
62
71
|
"tailwindcss": "^3.4.17",
|
|
63
72
|
"typescript": "~5.6.3",
|
|
64
|
-
"typescript-eslint": "^8.
|
|
65
|
-
"vite": "^6.0.
|
|
66
|
-
"vite-plugin-dts": "^4.
|
|
73
|
+
"typescript-eslint": "^8.19.1",
|
|
74
|
+
"vite": "^6.0.7",
|
|
75
|
+
"vite-plugin-dts": "^4.5.0",
|
|
67
76
|
"vite-plugin-image-optimizer": "^1.1.8",
|
|
77
|
+
"vite-plugin-lib-inject-css": "^2.2.1",
|
|
68
78
|
"vite-plugin-zip-pack": "^1.2.4",
|
|
69
79
|
"vite-tsconfig-paths": "^5.1.4"
|
|
70
80
|
},
|
|
@@ -74,5 +84,5 @@
|
|
|
74
84
|
"engines": {
|
|
75
85
|
"node": ">=18"
|
|
76
86
|
},
|
|
77
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "3d5bd8601f319bf9e47829ae8fbc828415da5ae1"
|
|
78
88
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-jsx-runtime.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-jsx-runtime.production.min.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../src/components/button/Button.tsx"],"sourcesContent":["import { ReactNode, ButtonHTMLAttributes } from \"react\";\nimport clsx from \"clsx\";\n\nexport type ButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost';\nexport type ButtonSize = 'small' | 'medium' | 'large';\n\nexport interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'disabled'> {\n /** Button variant that changes the visual style */\n variant?: ButtonVariant;\n /** Size of the button */\n size?: ButtonSize;\n /** Custom class name */\n className?: string;\n /** Button contents */\n children: ReactNode;\n /** Optional icon to show before the button text */\n leftIcon?: ReactNode;\n /** Optional icon to show after the button text */\n rightIcon?: ReactNode;\n /** Whether the button is in loading state */\n isLoading?: boolean;\n /** Whether the button is disabled */\n isDisabled?: boolean;\n /** Full width button */\n fullWidth?: boolean;\n}\n\nexport const Button = ({\n variant = 'primary',\n size = 'medium',\n className,\n children,\n leftIcon,\n rightIcon,\n isLoading = false,\n isDisabled = false,\n fullWidth = false,\n type = 'button',\n ...rest\n}: ButtonProps) => {\n const baseStyles = \"inline-flex items-center justify-center rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2\";\n \n const variantStyles = {\n primary: \"bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500\",\n secondary: \"bg-gray-600 text-white hover:bg-gray-700 focus:ring-gray-500\",\n outline: \"border border-gray-300 bg-transparent hover:bg-gray-50 focus:ring-gray-500\",\n ghost: \"bg-transparent hover:bg-gray-100 focus:ring-gray-500\"\n };\n\n const sizeStyles = {\n small: \"px-3 py-1.5 text-sm\",\n medium: \"px-4 py-2 text-base\",\n large: \"px-6 py-3 text-lg\"\n };\n\n const classes = clsx(\n baseStyles,\n variantStyles[variant],\n sizeStyles[size],\n {\n 'opacity-50 cursor-not-allowed': isDisabled,\n 'w-full': fullWidth,\n 'cursor-wait': isLoading\n },\n className\n );\n\n return (\n <button\n type={type}\n className={classes}\n disabled={isDisabled || isLoading}\n {...rest}\n >\n {isLoading && (\n <svg \n className=\"animate-spin -ml-1 mr-2 h-4 w-4\" \n xmlns=\"http://www.w3.org/2000/svg\" \n fill=\"none\" \n viewBox=\"0 0 24 24\"\n >\n <circle \n className=\"opacity-25\" \n cx=\"12\" \n cy=\"12\" \n r=\"10\" \n stroke=\"currentColor\" \n strokeWidth=\"4\"\n />\n <path \n className=\"opacity-75\" \n fill=\"currentColor\" \n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n />\n </svg>\n )}\n {!isLoading && leftIcon && <span className=\"mr-2\">{leftIcon}</span>}\n {children}\n {!isLoading && rightIcon && <span className=\"ml-2\">{rightIcon}</span>}\n </button>\n );\n};\n"],"names":["Button","variant","size","className","children","leftIcon","rightIcon","isLoading","isDisabled","fullWidth","type","rest","baseStyles","variantStyles","sizeStyles","classes","clsx","jsxs","jsx"],"mappings":";;AA2BO,MAAMA,IAAS,CAAC;AAAA,EACrB,SAAAC,IAAU;AAAA,EACV,MAAAC,IAAO;AAAA,EACP,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,YAAAC,IAAa;AAAA,EACb,WAAAC,IAAY;AAAA,EACZ,MAAAC,IAAO;AAAA,EACP,GAAGC;AACL,MAAmB;AACjB,QAAMC,IAAa,wIAEbC,IAAgB;AAAA,IACpB,SAAS;AAAA,IACT,WAAW;AAAA,IACX,SAAS;AAAA,IACT,OAAO;AAAA,EACT,GAEMC,IAAa;AAAA,IACjB,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,OAAO;AAAA,EACT,GAEMC,IAAUC;AAAA,IACdJ;AAAA,IACAC,EAAcZ,CAAO;AAAA,IACrBa,EAAWZ,CAAI;AAAA,IACf;AAAA,MACE,iCAAiCM;AAAA,MACjC,UAAUC;AAAA,MACV,eAAeF;AAAA,IACjB;AAAA,IACAJ;AAAA,EACF;AAGE,SAAAc,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAAP;AAAA,MACA,WAAWK;AAAA,MACX,UAAUP,KAAcD;AAAA,MACvB,GAAGI;AAAA,MAEH,UAAA;AAAA,QACCJ,KAAAU,gBAAAA,EAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,OAAM;AAAA,YACN,MAAK;AAAA,YACL,SAAQ;AAAA,YAER,UAAA;AAAA,cAAAC,gBAAAA,EAAA;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,WAAU;AAAA,kBACV,IAAG;AAAA,kBACH,IAAG;AAAA,kBACH,GAAE;AAAA,kBACF,QAAO;AAAA,kBACP,aAAY;AAAA,gBAAA;AAAA,cACd;AAAA,cACAA,gBAAAA,EAAA;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,WAAU;AAAA,kBACV,MAAK;AAAA,kBACL,GAAE;AAAA,gBAAA;AAAA,cAAA;AAAA,YACJ;AAAA,UAAA;AAAA,QACF;AAAA,QAED,CAACX,KAAaF,2BAAa,QAAK,EAAA,WAAU,QAAQ,UAASA,GAAA;AAAA,QAC3DD;AAAA,QACA,CAACG,KAAaD,2BAAc,QAAK,EAAA,WAAU,QAAQ,UAAUA,EAAA,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAChE;AAEJ;"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { j as c } from "../../_virtual/jsx-runtime.js";
|
|
2
|
-
import { useRef as H, useState as I, useCallback as u, useEffect as d } from "react";
|
|
3
|
-
import { debounce as R } from "lodash-es";
|
|
4
|
-
import L from "clsx";
|
|
5
|
-
const N = 16, _ = 1.5, j = "normal", A = ({
|
|
6
|
-
content: f,
|
|
7
|
-
lineHeight: p = _,
|
|
8
|
-
fontSize: m = N,
|
|
9
|
-
fontWeight: x = j,
|
|
10
|
-
className: E = "",
|
|
11
|
-
style: T = {},
|
|
12
|
-
onProgressChange: s,
|
|
13
|
-
initialScrollPosition: i,
|
|
14
|
-
cacheKey: e
|
|
15
|
-
}) => {
|
|
16
|
-
const r = H(null), [b, v] = I(0), l = u(() => {
|
|
17
|
-
if (!r.current) return;
|
|
18
|
-
const t = r.current, o = t.scrollTop, g = t.scrollHeight, w = t.clientHeight, a = Math.min(
|
|
19
|
-
Math.round(o / (g - w) * 100),
|
|
20
|
-
100
|
|
21
|
-
);
|
|
22
|
-
v(a), s == null || s(a), e && localStorage.setItem(`txtReader-${e}`, o.toString());
|
|
23
|
-
}, [e, s]), n = u(
|
|
24
|
-
R(l, 100),
|
|
25
|
-
[l]
|
|
26
|
-
);
|
|
27
|
-
return d(() => {
|
|
28
|
-
if (!r.current) return;
|
|
29
|
-
let t = i;
|
|
30
|
-
if (e) {
|
|
31
|
-
const o = localStorage.getItem(`txtReader-${e}`);
|
|
32
|
-
o && (t = parseInt(o, 10));
|
|
33
|
-
}
|
|
34
|
-
t && (r.current.scrollTop = t, l());
|
|
35
|
-
}, [e, i, l]), d(() => {
|
|
36
|
-
const t = r.current;
|
|
37
|
-
if (t)
|
|
38
|
-
return t.addEventListener("scroll", n), () => {
|
|
39
|
-
t.removeEventListener("scroll", n);
|
|
40
|
-
};
|
|
41
|
-
}, [n]), /* @__PURE__ */ c.jsxs("div", { className: "relative w-full h-full", children: [
|
|
42
|
-
/* @__PURE__ */ c.jsx(
|
|
43
|
-
"div",
|
|
44
|
-
{
|
|
45
|
-
ref: r,
|
|
46
|
-
className: L(
|
|
47
|
-
"w-full overflow-auto whitespace-pre-wrap break-words",
|
|
48
|
-
E
|
|
49
|
-
),
|
|
50
|
-
style: {
|
|
51
|
-
fontSize: `${m}px`,
|
|
52
|
-
lineHeight: p,
|
|
53
|
-
fontWeight: x,
|
|
54
|
-
...T
|
|
55
|
-
},
|
|
56
|
-
children: f
|
|
57
|
-
}
|
|
58
|
-
),
|
|
59
|
-
/* @__PURE__ */ c.jsxs("div", { className: "fixed text-white rounded text-sm bg-black bg-opacity-70 pl-2 pr-2 pb-1 pt-1 right-5 bottom-5", children: [
|
|
60
|
-
b,
|
|
61
|
-
"%"
|
|
62
|
-
] })
|
|
63
|
-
] });
|
|
64
|
-
};
|
|
65
|
-
export {
|
|
66
|
-
A as TxtReader,
|
|
67
|
-
A as default
|
|
68
|
-
};
|
|
69
|
-
//# sourceMappingURL=TxtReader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TxtReader.js","sources":["../../../src/components/txt-reader/TxtReader.tsx"],"sourcesContent":["import {\n useEffect,\n useRef,\n useState,\n useCallback,\n CSSProperties,\n FC,\n} from \"react\";\nimport { debounce } from \"lodash-es\";\nimport clsx from \"clsx\";\ninterface TxtReaderProps {\n content: string;\n lineHeight?: number;\n fontSize?: number;\n fontWeight?: number | string;\n className?: string;\n style?: CSSProperties;\n onProgressChange?: (progress: number) => void;\n initialScrollPosition?: number;\n cacheKey?: string; // 用于缓存阅读位置的key\n}\n\nconst DEFAULT_FONT_SIZE = 16;\nconst DEFAULT_LINE_HEIGHT = 1.5;\nconst DEFAULT_FONT_WEIGHT = \"normal\";\n\nexport const TxtReader: FC<TxtReaderProps> = ({\n content,\n lineHeight = DEFAULT_LINE_HEIGHT,\n fontSize = DEFAULT_FONT_SIZE,\n fontWeight = DEFAULT_FONT_WEIGHT,\n className = \"\",\n style = {},\n onProgressChange,\n initialScrollPosition,\n cacheKey,\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const [readingProgress, setReadingProgress] = useState(0);\n\n // 计算阅读进度\n const calculateProgress = useCallback(() => {\n if (!containerRef.current) return;\n\n const container = containerRef.current;\n const scrollTop = container.scrollTop;\n const scrollHeight = container.scrollHeight;\n const clientHeight = container.clientHeight;\n\n const progress = Math.min(\n Math.round((scrollTop / (scrollHeight - clientHeight)) * 100),\n 100,\n );\n\n setReadingProgress(progress);\n onProgressChange?.(progress);\n\n // 保存阅读位置到 localStorage\n if (cacheKey) {\n localStorage.setItem(`txtReader-${cacheKey}`, scrollTop.toString());\n }\n }, [cacheKey, onProgressChange]);\n\n // 使用 debounce 优化滚动事件处理\n const debouncedCalculateProgress = useCallback(\n debounce(calculateProgress, 100),\n [calculateProgress],\n );\n\n // 初始化滚动位置\n useEffect(() => {\n if (!containerRef.current) return;\n\n let scrollPosition = initialScrollPosition;\n\n // 如果有缓存key,尝试从localStorage获取保存的位置\n if (cacheKey) {\n const savedPosition = localStorage.getItem(`txtReader-${cacheKey}`);\n if (savedPosition) {\n scrollPosition = parseInt(savedPosition, 10);\n }\n }\n\n if (scrollPosition) {\n containerRef.current.scrollTop = scrollPosition;\n calculateProgress();\n }\n }, [cacheKey, initialScrollPosition, calculateProgress]);\n\n // 监听滚动事件\n useEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n\n container.addEventListener(\"scroll\", debouncedCalculateProgress);\n return () => {\n container.removeEventListener(\"scroll\", debouncedCalculateProgress);\n };\n }, [debouncedCalculateProgress]);\n\n return (\n <div className=\"relative w-full h-full\">\n <div\n ref={containerRef}\n className={clsx(\n \"w-full overflow-auto whitespace-pre-wrap break-words\",\n className,\n )}\n style={{\n fontSize: `${fontSize}px`,\n lineHeight: lineHeight,\n fontWeight: fontWeight,\n ...style,\n }}\n >\n {content}\n </div>\n <div className=\"fixed text-white rounded text-sm bg-black bg-opacity-70 pl-2 pr-2 pb-1 pt-1 right-5 bottom-5\">\n {readingProgress}%\n </div>\n </div>\n );\n};\n\nexport default TxtReader;\n"],"names":["DEFAULT_FONT_SIZE","DEFAULT_LINE_HEIGHT","DEFAULT_FONT_WEIGHT","TxtReader","content","lineHeight","fontSize","fontWeight","className","style","onProgressChange","initialScrollPosition","cacheKey","containerRef","useRef","readingProgress","setReadingProgress","useState","calculateProgress","useCallback","container","scrollTop","scrollHeight","clientHeight","progress","debouncedCalculateProgress","debounce","useEffect","scrollPosition","savedPosition","jsxs","jsx","clsx"],"mappings":";;;;AAsBA,MAAMA,IAAoB,IACpBC,IAAsB,KACtBC,IAAsB,UAEfC,IAAgC,CAAC;AAAA,EAC5C,SAAAC;AAAA,EACA,YAAAC,IAAaJ;AAAA,EACb,UAAAK,IAAWN;AAAA,EACX,YAAAO,IAAaL;AAAA,EACb,WAAAM,IAAY;AAAA,EACZ,OAAAC,IAAQ,CAAC;AAAA,EACT,kBAAAC;AAAA,EACA,uBAAAC;AAAA,EACA,UAAAC;AACF,MAAM;AACE,QAAAC,IAAeC,EAAuB,IAAI,GAC1C,CAACC,GAAiBC,CAAkB,IAAIC,EAAS,CAAC,GAGlDC,IAAoBC,EAAY,MAAM;AACtC,QAAA,CAACN,EAAa,QAAS;AAE3B,UAAMO,IAAYP,EAAa,SACzBQ,IAAYD,EAAU,WACtBE,IAAeF,EAAU,cACzBG,IAAeH,EAAU,cAEzBI,IAAW,KAAK;AAAA,MACpB,KAAK,MAAOH,KAAaC,IAAeC,KAAiB,GAAG;AAAA,MAC5D;AAAA,IACF;AAEA,IAAAP,EAAmBQ,CAAQ,GAC3Bd,KAAA,QAAAA,EAAmBc,IAGfZ,KACF,aAAa,QAAQ,aAAaA,CAAQ,IAAIS,EAAU,UAAU;AAAA,EACpE,GACC,CAACT,GAAUF,CAAgB,CAAC,GAGzBe,IAA6BN;AAAA,IACjCO,EAASR,GAAmB,GAAG;AAAA,IAC/B,CAACA,CAAiB;AAAA,EACpB;AAGA,SAAAS,EAAU,MAAM;AACV,QAAA,CAACd,EAAa,QAAS;AAE3B,QAAIe,IAAiBjB;AAGrB,QAAIC,GAAU;AACZ,YAAMiB,IAAgB,aAAa,QAAQ,aAAajB,CAAQ,EAAE;AAClE,MAAIiB,MACeD,IAAA,SAASC,GAAe,EAAE;AAAA,IAC7C;AAGF,IAAID,MACFf,EAAa,QAAQ,YAAYe,GACfV,EAAA;AAAA,EAEnB,GAAA,CAACN,GAAUD,GAAuBO,CAAiB,CAAC,GAGvDS,EAAU,MAAM;AACd,UAAMP,IAAYP,EAAa;AAC/B,QAAKO;AAEK,aAAAA,EAAA,iBAAiB,UAAUK,CAA0B,GACxD,MAAM;AACD,QAAAL,EAAA,oBAAoB,UAAUK,CAA0B;AAAA,MACpE;AAAA,EAAA,GACC,CAACA,CAA0B,CAAC,GAG7BK,gBAAAA,EAAA,KAAC,OAAI,EAAA,WAAU,0BACb,UAAA;AAAA,IAAAC,gBAAAA,EAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAKlB;AAAA,QACL,WAAWmB;AAAA,UACT;AAAA,UACAxB;AAAA,QACF;AAAA,QACA,OAAO;AAAA,UACL,UAAU,GAAGF,CAAQ;AAAA,UACrB,YAAAD;AAAA,UACA,YAAAE;AAAA,UACA,GAAGE;AAAA,QACL;AAAA,QAEC,UAAAL;AAAA,MAAA;AAAA,IACH;AAAA,IACA0B,gBAAAA,EAAAA,KAAC,OAAI,EAAA,WAAU,gGACZ,UAAA;AAAA,MAAAf;AAAA,MAAgB;AAAA,IAAA,EACnB,CAAA;AAAA,EAAA,GACF;AAEJ;"}
|
package/dist/index.js
DELETED
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|