@xiping/react-components 0.0.56 → 0.0.58

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 (46) hide show
  1. package/dist/cjs/App.d.ts +2 -0
  2. package/dist/cjs/components/button/Button.d.ts +24 -0
  3. package/dist/cjs/components/image-viewer/ImageViewer.d.ts +7 -0
  4. package/dist/cjs/components/image-viewer/ImageViewer.js +1 -0
  5. package/dist/cjs/components/image-viewer/index.d.ts +3 -0
  6. package/dist/cjs/components/pinch-content/PinchContent.d.ts +13 -0
  7. package/dist/{components → cjs/components}/pinch-content/PinchContent.js +1 -1
  8. package/dist/cjs/components/pinch-content/index.d.ts +4 -0
  9. package/dist/cjs/components/pinch-content/index.js +1 -0
  10. package/dist/cjs/components/translate/Translate.d.ts +5 -0
  11. package/dist/cjs/components/txt-reader/TxtReader.d.ts +14 -0
  12. package/dist/cjs/index.d.ts +4 -0
  13. package/dist/{index.js → cjs/index.js} +1 -1
  14. package/dist/cjs/main.d.ts +0 -0
  15. package/dist/cjs/node_modules/.pnpm/react-icons@5.4.0_react@18.3.1/node_modules/react-icons/io5/index.js +1 -0
  16. package/dist/cjs/node_modules/.pnpm/react-icons@5.4.0_react@18.3.1/node_modules/react-icons/lib/iconBase.js +1 -0
  17. package/dist/cjs/node_modules/.pnpm/react-icons@5.4.0_react@18.3.1/node_modules/react-icons/lib/iconContext.js +1 -0
  18. package/dist/cjs/pages/home/Home.d.ts +2 -0
  19. package/dist/cjs/react-components.css +1 -0
  20. package/dist/es/App.d.ts +2 -0
  21. package/dist/es/components/button/Button.d.ts +24 -0
  22. package/dist/es/components/button/Button.js +83 -0
  23. package/dist/es/components/image-viewer/ImageViewer.d.ts +7 -0
  24. package/dist/es/components/image-viewer/ImageViewer.js +39 -0
  25. package/dist/es/components/image-viewer/index.d.ts +3 -0
  26. package/dist/es/components/pinch-content/PinchContent.d.ts +13 -0
  27. package/dist/es/components/pinch-content/PinchContent.js +61 -0
  28. package/dist/es/components/pinch-content/index.d.ts +4 -0
  29. package/dist/es/components/pinch-content/index.js +5 -0
  30. package/dist/es/components/translate/Translate.d.ts +5 -0
  31. package/dist/es/components/txt-reader/TxtReader.d.ts +14 -0
  32. package/dist/es/components/txt-reader/TxtReader.js +68 -0
  33. package/dist/es/index.d.ts +4 -0
  34. package/dist/es/index.js +11 -0
  35. package/dist/es/main.d.ts +0 -0
  36. package/dist/es/node_modules/.pnpm/react-icons@5.4.0_react@18.3.1/node_modules/react-icons/io5/index.js +8 -0
  37. package/dist/es/node_modules/.pnpm/react-icons@5.4.0_react@18.3.1/node_modules/react-icons/lib/iconBase.js +108 -0
  38. package/dist/es/node_modules/.pnpm/react-icons@5.4.0_react@18.3.1/node_modules/react-icons/lib/iconContext.js +12 -0
  39. package/dist/es/pages/home/Home.d.ts +2 -0
  40. package/dist/es/react-components.css +1 -0
  41. package/dist/es/vite.svg +1 -0
  42. package/package.json +21 -6
  43. package/dist/react-components.css +0 -1
  44. /package/dist/{components → cjs/components}/button/Button.js +0 -0
  45. /package/dist/{components → cjs/components}/txt-reader/TxtReader.js +0 -0
  46. /package/dist/{vite.svg → cjs/vite.svg} +0 -0
@@ -0,0 +1,83 @@
1
+ import { jsxs as a, jsx as r } from "react/jsx-runtime";
2
+ import x from "clsx";
3
+ const w = ({
4
+ variant: l = "primary",
5
+ size: n = "medium",
6
+ className: c,
7
+ children: i,
8
+ leftIcon: t,
9
+ rightIcon: s,
10
+ isLoading: e = !1,
11
+ isDisabled: o = !1,
12
+ fullWidth: m = !1,
13
+ type: u = "button",
14
+ ...g
15
+ }) => {
16
+ const y = "inline-flex items-center justify-center rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2", p = {
17
+ primary: "bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500",
18
+ secondary: "bg-gray-600 text-white hover:bg-gray-700 focus:ring-gray-500",
19
+ outline: "border border-gray-300 bg-transparent hover:bg-gray-50 focus:ring-gray-500",
20
+ ghost: "bg-transparent hover:bg-gray-100 focus:ring-gray-500"
21
+ }, f = {
22
+ small: "px-3 py-1.5 text-sm",
23
+ medium: "px-4 py-2 text-base",
24
+ large: "px-6 py-3 text-lg"
25
+ }, b = x(
26
+ y,
27
+ p[l],
28
+ f[n],
29
+ {
30
+ "opacity-50 cursor-not-allowed": o,
31
+ "w-full": m,
32
+ "cursor-wait": e
33
+ },
34
+ c
35
+ );
36
+ return /* @__PURE__ */ a(
37
+ "button",
38
+ {
39
+ type: u,
40
+ className: b,
41
+ disabled: o || e,
42
+ ...g,
43
+ children: [
44
+ e && /* @__PURE__ */ a(
45
+ "svg",
46
+ {
47
+ className: "animate-spin -ml-1 mr-2 h-4 w-4",
48
+ xmlns: "http://www.w3.org/2000/svg",
49
+ fill: "none",
50
+ viewBox: "0 0 24 24",
51
+ children: [
52
+ /* @__PURE__ */ r(
53
+ "circle",
54
+ {
55
+ className: "opacity-25",
56
+ cx: "12",
57
+ cy: "12",
58
+ r: "10",
59
+ stroke: "currentColor",
60
+ strokeWidth: "4"
61
+ }
62
+ ),
63
+ /* @__PURE__ */ r(
64
+ "path",
65
+ {
66
+ className: "opacity-75",
67
+ fill: "currentColor",
68
+ 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"
69
+ }
70
+ )
71
+ ]
72
+ }
73
+ ),
74
+ !e && t && /* @__PURE__ */ r("span", { className: "mr-2", children: t }),
75
+ i,
76
+ !e && s && /* @__PURE__ */ r("span", { className: "ml-2", children: s })
77
+ ]
78
+ }
79
+ );
80
+ };
81
+ export {
82
+ w as Button
83
+ };
@@ -0,0 +1,7 @@
1
+ interface ImageViewerProps {
2
+ isOpen: boolean;
3
+ imgSrc: string;
4
+ onClose: () => void;
5
+ }
6
+ declare const ImageViewer: (props: ImageViewerProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default ImageViewer;
@@ -0,0 +1,39 @@
1
+ import { jsx as e, jsxs as r } from "react/jsx-runtime";
2
+ import { Modal as s, ModalContent as i, ModalHeader as n, ModalBody as c, ModalFooter as m } from "@nextui-org/modal";
3
+ import { IoCloseSharp as d } from "../../node_modules/.pnpm/react-icons@5.4.0_react@18.3.1/node_modules/react-icons/io5/index.js";
4
+ import p from "../pinch-content/PinchContent.js";
5
+ const x = (o) => {
6
+ const { isOpen: t, onClose: l, imgSrc: a } = o;
7
+ return /* @__PURE__ */ e(
8
+ s,
9
+ {
10
+ isOpen: t,
11
+ size: "full",
12
+ onClose: l,
13
+ className: "pppp bg-black bg-opacity-70",
14
+ hideCloseButton: !0,
15
+ children: /* @__PURE__ */ r(i, { children: [
16
+ /* @__PURE__ */ e(n, { className: "flex flex-col gap-1 relative", children: /* @__PURE__ */ e(
17
+ d,
18
+ {
19
+ className: "absolute top-2 right-2 text-white",
20
+ onClick: l
21
+ }
22
+ ) }),
23
+ /* @__PURE__ */ e(c, { className: "flex items-center justify-center", children: /* @__PURE__ */ e(p, { children: /* @__PURE__ */ e(
24
+ "img",
25
+ {
26
+ draggable: "false",
27
+ src: a,
28
+ alt: "",
29
+ className: "w-full h-full object-contain pointer-events-none"
30
+ }
31
+ ) }) }),
32
+ /* @__PURE__ */ e(m, {})
33
+ ] })
34
+ }
35
+ );
36
+ };
37
+ export {
38
+ x as default
39
+ };
@@ -0,0 +1,3 @@
1
+ import { default as ImageViewer } from './ImageViewer';
2
+ export { ImageViewer };
3
+ export default ImageViewer;
@@ -0,0 +1,13 @@
1
+ import { ReactNode } from 'react';
2
+ export interface PinchContentProps {
3
+ children?: ReactNode;
4
+ canDrag?: boolean;
5
+ canPinch?: boolean;
6
+ canRotate?: boolean;
7
+ scaleBounds?: {
8
+ min: number;
9
+ max: number;
10
+ };
11
+ }
12
+ declare const PinchContent: (props: PinchContentProps) => import("react/jsx-runtime").JSX.Element;
13
+ export default PinchContent;
@@ -0,0 +1,61 @@
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import { useSpring as B, animated as C } from "@react-spring/web";
3
+ import { createUseGesture as G, dragAction as N, pinchAction as U } from "@use-gesture/react";
4
+ import { useRef as j } from "react";
5
+ import { useMount as w, useUnmount as M } from "ahooks";
6
+ const S = G([N, U]), o = (i) => i.preventDefault(), I = (i) => {
7
+ const {
8
+ children: l,
9
+ canPinch: h = !0,
10
+ canDrag: v = !0,
11
+ canRotate: p = !0,
12
+ scaleBounds: m = { min: 0.3, max: 8 }
13
+ } = i, t = j(null);
14
+ w(() => {
15
+ var r, e, n;
16
+ (r = t.current) == null || r.addEventListener("gesturestart", o), (e = t.current) == null || e.addEventListener("gesturechange", o), (n = t.current) == null || n.addEventListener("gestureend", o);
17
+ }), M(() => {
18
+ var r, e, n;
19
+ (r = t.current) == null || r.removeEventListener("gesturestart", o), (e = t.current) == null || e.removeEventListener("gesturechange", o), (n = t.current) == null || n.removeEventListener("gestureend", o);
20
+ });
21
+ const [c, g] = B(() => ({
22
+ x: 0,
23
+ y: 0,
24
+ scale: 1,
25
+ rotateZ: 0
26
+ }));
27
+ return S(
28
+ {
29
+ // onHover: ({ active, event }) => console.log('hover', event, active),
30
+ // onMove: ({ event }) => console.log('move', event),
31
+ onDrag: ({ pinching: r, cancel: e, offset: [n, a], ...u }) => {
32
+ if (console.log(u), !v || r) return e();
33
+ g.start({ x: n, y: a });
34
+ },
35
+ onPinch: ({
36
+ origin: [r, e],
37
+ first: n,
38
+ movement: [a],
39
+ offset: [u, x],
40
+ memo: s,
41
+ cancel: y
42
+ }) => {
43
+ if (!h) return y();
44
+ if (n) {
45
+ const { width: b, height: D, x: P, y: R } = t.current.getBoundingClientRect(), Z = r - (P + b / 2), A = e - (R + D / 2);
46
+ s = [c.x.get(), c.y.get(), Z, A];
47
+ }
48
+ const E = s[0] - (a - 1) * s[2], L = s[1] - (a - 1) * s[3], d = { scale: u, rotateZ: 0, x: E, y: L };
49
+ return p && (d.rotateZ = x), g.start(d), s;
50
+ }
51
+ },
52
+ {
53
+ target: t,
54
+ drag: { from: () => [c.x.get(), c.y.get()] },
55
+ pinch: { scaleBounds: m, rubberband: !0 }
56
+ }
57
+ ), /* @__PURE__ */ f("div", { className: "flex fill center", children: /* @__PURE__ */ f(C.div, { className: "select-none", ref: t, style: c, children: l }) });
58
+ };
59
+ export {
60
+ I as default
61
+ };
@@ -0,0 +1,4 @@
1
+ import { default as PinchContent } from './PinchContent';
2
+ export * from './PinchContent';
3
+ export { PinchContent };
4
+ export default PinchContent;
@@ -0,0 +1,5 @@
1
+ import o from "./PinchContent.js";
2
+ export {
3
+ o as PinchContent,
4
+ o as default
5
+ };
@@ -0,0 +1,5 @@
1
+ interface TranslateProps {
2
+ text: string;
3
+ }
4
+ declare const Translate: (props: TranslateProps) => import("react/jsx-runtime").JSX.Element;
5
+ export default Translate;
@@ -0,0 +1,14 @@
1
+ import { CSSProperties, FC } from 'react';
2
+ interface TxtReaderProps {
3
+ content: string;
4
+ lineHeight?: number;
5
+ fontSize?: number;
6
+ fontWeight?: number | string;
7
+ className?: string;
8
+ style?: CSSProperties;
9
+ onProgressChange?: (progress: number) => void;
10
+ initialScrollPosition?: number;
11
+ cacheKey?: string;
12
+ }
13
+ export declare const TxtReader: FC<TxtReaderProps>;
14
+ export default TxtReader;
@@ -0,0 +1,68 @@
1
+ import { jsxs as a, jsx as H } from "react/jsx-runtime";
2
+ import { useRef as I, useState as L, useCallback as u, useEffect as d } from "react";
3
+ import { debounce as N } from "lodash-es";
4
+ import R from "clsx";
5
+ const _ = 16, F = 1.5, S = "normal", U = ({
6
+ content: f,
7
+ lineHeight: p = F,
8
+ fontSize: m = _,
9
+ fontWeight: x = S,
10
+ className: T = "",
11
+ style: E = {},
12
+ onProgressChange: s,
13
+ initialScrollPosition: c,
14
+ cacheKey: e
15
+ }) => {
16
+ const r = I(null), [b, v] = L(0), l = u(() => {
17
+ if (!r.current) return;
18
+ const t = r.current, o = t.scrollTop, g = t.scrollHeight, w = t.clientHeight, i = Math.min(
19
+ Math.round(o / (g - w) * 100),
20
+ 100
21
+ );
22
+ v(i), s == null || s(i), e && localStorage.setItem(`txtReader-${e}`, o.toString());
23
+ }, [e, s]), n = u(
24
+ N(l, 100),
25
+ [l]
26
+ );
27
+ return d(() => {
28
+ if (!r.current) return;
29
+ let t = c;
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, c, 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__ */ a("div", { className: "relative w-full h-full", children: [
42
+ /* @__PURE__ */ H(
43
+ "div",
44
+ {
45
+ ref: r,
46
+ className: R(
47
+ "w-full overflow-auto whitespace-pre-wrap break-words",
48
+ T
49
+ ),
50
+ style: {
51
+ fontSize: `${m}px`,
52
+ lineHeight: p,
53
+ fontWeight: x,
54
+ ...E
55
+ },
56
+ children: f
57
+ }
58
+ ),
59
+ /* @__PURE__ */ a("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
+ U as TxtReader,
67
+ U as default
68
+ };
@@ -0,0 +1,4 @@
1
+ export * from './components/button/Button';
2
+ export * from './components/txt-reader/TxtReader';
3
+ export * from './components/pinch-content';
4
+ export * from './components/image-viewer';
@@ -0,0 +1,11 @@
1
+ /* empty css */
2
+ import { Button as r } from "./components/button/Button.js";
3
+ import { TxtReader as f } from "./components/txt-reader/TxtReader.js";
4
+ import { default as p } from "./components/pinch-content/PinchContent.js";
5
+ import { default as n } from "./components/image-viewer/ImageViewer.js";
6
+ export {
7
+ r as Button,
8
+ n as ImageViewer,
9
+ p as PinchContent,
10
+ f as TxtReader
11
+ };
File without changes
@@ -0,0 +1,8 @@
1
+ import { GenIcon as o } from "../lib/iconBase.js";
2
+ import "../lib/iconContext.js";
3
+ function i(t) {
4
+ return o({ tag: "svg", attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M400 145.49 366.51 112 256 222.51 145.49 112 112 145.49 222.51 256 112 366.51 145.49 400 256 289.49 366.51 400 400 366.51 289.49 256 400 145.49z" }, child: [] }] })(t);
5
+ }
6
+ export {
7
+ i as IoCloseSharp
8
+ };
@@ -0,0 +1,108 @@
1
+ import l from "react";
2
+ import { IconContext as s, DefaultContext as O } from "./iconContext.js";
3
+ var g = ["attr", "size", "title"];
4
+ function v(t, e) {
5
+ if (t == null) return {};
6
+ var r = y(t, e), n, i;
7
+ if (Object.getOwnPropertySymbols) {
8
+ var o = Object.getOwnPropertySymbols(t);
9
+ for (i = 0; i < o.length; i++)
10
+ n = o[i], !(e.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(t, n) && (r[n] = t[n]);
11
+ }
12
+ return r;
13
+ }
14
+ function y(t, e) {
15
+ if (t == null) return {};
16
+ var r = {};
17
+ for (var n in t)
18
+ if (Object.prototype.hasOwnProperty.call(t, n)) {
19
+ if (e.indexOf(n) >= 0) continue;
20
+ r[n] = t[n];
21
+ }
22
+ return r;
23
+ }
24
+ function c() {
25
+ return c = Object.assign ? Object.assign.bind() : function(t) {
26
+ for (var e = 1; e < arguments.length; e++) {
27
+ var r = arguments[e];
28
+ for (var n in r)
29
+ Object.prototype.hasOwnProperty.call(r, n) && (t[n] = r[n]);
30
+ }
31
+ return t;
32
+ }, c.apply(this, arguments);
33
+ }
34
+ function m(t, e) {
35
+ var r = Object.keys(t);
36
+ if (Object.getOwnPropertySymbols) {
37
+ var n = Object.getOwnPropertySymbols(t);
38
+ e && (n = n.filter(function(i) {
39
+ return Object.getOwnPropertyDescriptor(t, i).enumerable;
40
+ })), r.push.apply(r, n);
41
+ }
42
+ return r;
43
+ }
44
+ function u(t) {
45
+ for (var e = 1; e < arguments.length; e++) {
46
+ var r = arguments[e] != null ? arguments[e] : {};
47
+ e % 2 ? m(Object(r), !0).forEach(function(n) {
48
+ j(t, n, r[n]);
49
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r)) : m(Object(r)).forEach(function(n) {
50
+ Object.defineProperty(t, n, Object.getOwnPropertyDescriptor(r, n));
51
+ });
52
+ }
53
+ return t;
54
+ }
55
+ function j(t, e, r) {
56
+ return e = P(e), e in t ? Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = r, t;
57
+ }
58
+ function P(t) {
59
+ var e = h(t, "string");
60
+ return typeof e == "symbol" ? e : e + "";
61
+ }
62
+ function h(t, e) {
63
+ if (typeof t != "object" || !t) return t;
64
+ var r = t[Symbol.toPrimitive];
65
+ if (r !== void 0) {
66
+ var n = r.call(t, e || "default");
67
+ if (typeof n != "object") return n;
68
+ throw new TypeError("@@toPrimitive must return a primitive value.");
69
+ }
70
+ return (e === "string" ? String : Number)(t);
71
+ }
72
+ function p(t) {
73
+ return t && t.map((e, r) => /* @__PURE__ */ l.createElement(e.tag, u({
74
+ key: r
75
+ }, e.attr), p(e.child)));
76
+ }
77
+ function _(t) {
78
+ return (e) => /* @__PURE__ */ l.createElement(w, c({
79
+ attr: u({}, t.attr)
80
+ }, e), p(t.child));
81
+ }
82
+ function w(t) {
83
+ var e = (r) => {
84
+ var {
85
+ attr: n,
86
+ size: i,
87
+ title: o
88
+ } = t, b = v(t, g), f = i || r.size || "1em", a;
89
+ return r.className && (a = r.className), t.className && (a = (a ? a + " " : "") + t.className), /* @__PURE__ */ l.createElement("svg", c({
90
+ stroke: "currentColor",
91
+ fill: "currentColor",
92
+ strokeWidth: "0"
93
+ }, r.attr, n, b, {
94
+ className: a,
95
+ style: u(u({
96
+ color: t.color || r.color
97
+ }, r.style), t.style),
98
+ height: f,
99
+ width: f,
100
+ xmlns: "http://www.w3.org/2000/svg"
101
+ }), o && /* @__PURE__ */ l.createElement("title", null, o), t.children);
102
+ };
103
+ return s !== void 0 ? /* @__PURE__ */ l.createElement(s.Consumer, null, (r) => e(r)) : e(O);
104
+ }
105
+ export {
106
+ _ as GenIcon,
107
+ w as IconBase
108
+ };
@@ -0,0 +1,12 @@
1
+ import e from "react";
2
+ var t = {
3
+ color: void 0,
4
+ size: void 0,
5
+ className: void 0,
6
+ style: void 0,
7
+ attr: void 0
8
+ }, d = e.createContext && /* @__PURE__ */ e.createContext(t);
9
+ export {
10
+ t as DefaultContext,
11
+ d as IconContext
12
+ };
@@ -0,0 +1,2 @@
1
+ declare const Home: () => import("react/jsx-runtime").JSX.Element;
2
+ export default Home;