reachat 2.0.0 → 2.0.1

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/index.css CHANGED
@@ -648,15 +648,6 @@
648
648
  .z-9998 {
649
649
  z-index: 9998;
650
650
  }
651
- .z-\[998\] {
652
- z-index: 998;
653
- }
654
- .z-\[999\] {
655
- z-index: 999;
656
- }
657
- .z-\[1000\] {
658
- z-index: 1000;
659
- }
660
651
  .col-span-2 {
661
652
  grid-column: span 2 / span 2;
662
653
  }
@@ -1085,18 +1076,6 @@
1085
1076
  .border-collapse {
1086
1077
  border-collapse: collapse;
1087
1078
  }
1088
- .origin-bottom {
1089
- transform-origin: bottom;
1090
- }
1091
- .origin-left {
1092
- transform-origin: left;
1093
- }
1094
- .origin-right {
1095
- transform-origin: right;
1096
- }
1097
- .origin-top {
1098
- transform-origin: top;
1099
- }
1100
1079
  .-translate-x-2 {
1101
1080
  --tw-translate-x: calc(var(--spacing) * -2);
1102
1081
  translate: var(--tw-translate-x) var(--tw-translate-y);
@@ -2138,6 +2117,16 @@
2138
2117
  content: var(--tw-content);
2139
2118
  }
2140
2119
  }
2120
+ .hover\:scale-110 {
2121
+ &:hover {
2122
+ @media (hover: hover) {
2123
+ --tw-scale-x: 110%;
2124
+ --tw-scale-y: 110%;
2125
+ --tw-scale-z: 110%;
2126
+ scale: var(--tw-scale-x) var(--tw-scale-y);
2127
+ }
2128
+ }
2129
+ }
2141
2130
  .hover\:border-blue-500 {
2142
2131
  &:hover {
2143
2132
  @media (hover: hover) {
@@ -2716,3 +2705,18 @@ body {
2716
2705
  initial-value: "";
2717
2706
  inherits: false;
2718
2707
  }
2708
+ @property --tw-scale-x {
2709
+ syntax: "*";
2710
+ inherits: false;
2711
+ initial-value: 1;
2712
+ }
2713
+ @property --tw-scale-y {
2714
+ syntax: "*";
2715
+ inherits: false;
2716
+ initial-value: 1;
2717
+ }
2718
+ @property --tw-scale-z {
2719
+ syntax: "*";
2720
+ inherits: false;
2721
+ initial-value: 1;
2722
+ }
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@
10
10
  console.error("vite-plugin-css-injected-by-js", e);
11
11
  }
12
12
  })();
13
- import { A, m, B, z, C, v, F, s, f, g, h, i, j, M, k, N, b, p, o, e, d, l, c, q, n, T, u, t, r, x, y, w } from "./index-B1krf7tH.js";
13
+ import { A, m, B, z, C, v, F, s, f, g, h, i, j, M, k, N, b, p, o, e, d, l, c, q, n, T, u, t, r, x, y, w } from "./index-NuRjkHCl.js";
14
14
  import "react/jsx-runtime";
15
15
  import "react";
16
16
  import "reablocks";
@@ -11,8 +11,8 @@
11
11
  }
12
12
  })();
13
13
  (function(global, factory) {
14
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("reablocks"), require("react"), require("motion/react"), require("@radix-ui/react-slot"), require("react-markdown"), require("react-syntax-highlighter"), require("rehype-katex"), require("mdast-util-find-and-replace"), require("reakeys"), require("remark-gfm"), require("remark-youtube"), require("remark-math"), require("date-fns"), require("react-dom")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "reablocks", "react", "motion/react", "@radix-ui/react-slot", "react-markdown", "react-syntax-highlighter", "rehype-katex", "mdast-util-find-and-replace", "reakeys", "remark-gfm", "remark-youtube", "remark-math", "date-fns", "react-dom"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.reachat = {}, global.jsxRuntime, global.reablocks, global.React, global.react, global.reactSlot, global.ReactMarkdown, global.reactSyntaxHighlighter, global.rehypeKatex, global.mdastUtilFindAndReplace, global.reakeys, global.remarkGfm, global.remarkYoutube, global.remarkMath, global.dateFns, global.reactDom));
15
- })(this, function(exports2, jsxRuntime, reablocks, React, react, reactSlot, ReactMarkdown, reactSyntaxHighlighter, rehypeKatex, mdastUtilFindAndReplace, reakeys, remarkGfm, remarkYoutube, remarkMath, dateFns, reactDom) {
14
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("reablocks"), require("react"), require("motion/react"), require("@radix-ui/react-slot"), require("react-markdown"), require("react-syntax-highlighter"), require("rehype-katex"), require("mdast-util-find-and-replace"), require("reakeys"), require("remark-gfm"), require("remark-youtube"), require("remark-math"), require("date-fns"), require("@floating-ui/react")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "reablocks", "react", "motion/react", "@radix-ui/react-slot", "react-markdown", "react-syntax-highlighter", "rehype-katex", "mdast-util-find-and-replace", "reakeys", "remark-gfm", "remark-youtube", "remark-math", "date-fns", "@floating-ui/react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.reachat = {}, global.jsxRuntime, global.reablocks, global.React, global.react, global.reactSlot, global.ReactMarkdown, global.reactSyntaxHighlighter, global.rehypeKatex, global.mdastUtilFindAndReplace, global.reakeys, global.remarkGfm, global.remarkYoutube, global.remarkMath, global.dateFns, global.react$1));
15
+ })(this, function(exports2, jsxRuntime, reablocks, React, react, reactSlot, ReactMarkdown, reactSyntaxHighlighter, rehypeKatex, mdastUtilFindAndReplace, reakeys, remarkGfm, remarkYoutube, remarkMath, dateFns, react$1) {
16
16
  "use strict";
17
17
  function _interopNamespaceDefault(e) {
18
18
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -2339,144 +2339,39 @@ ${response}`),
2339
2339
  const theme = reablocks.useComponentTheme("chat", customTheme);
2340
2340
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: reablocks.cn(theme.appbar), children: content });
2341
2341
  };
2342
- const defaultPositions = {
2343
- "bottom-left": "bottom-5 left-5",
2344
- "bottom-right": "bottom-5 right-5",
2345
- "top-left": "top-5 left-5",
2346
- "top-right": "top-5 right-5"
2347
- };
2348
2342
  const ChatBubble = React.memo(
2349
2343
  ({
2350
2344
  children,
2351
2345
  bubbleContent,
2352
- position = "bottom-left",
2353
- customPosition,
2354
- portalTarget = typeof document !== "undefined" ? document.body : null,
2346
+ position = "right-end",
2347
+ modifiers = [react$1.offset({ mainAxis: 0, crossAxis: -40 })],
2355
2348
  className
2356
2349
  }) => {
2357
2350
  const [isOpen, setIsOpen] = React.useState(false);
2358
- const bubbleRef = React.useRef(null);
2359
- const contentRef = React.useRef(null);
2360
- const [bubbleRect, setBubbleRect] = React.useState(null);
2361
- React.useEffect(() => {
2362
- if (bubbleRef.current) {
2363
- setBubbleRect(bubbleRef.current.getBoundingClientRect());
2364
- }
2365
- }, [isOpen]);
2366
- const handleClose = React.useCallback(() => {
2367
- setIsOpen(false);
2368
- }, []);
2369
- const handleToggle = React.useCallback(() => {
2370
- setIsOpen((prev) => !prev);
2371
- }, []);
2372
- const getContentPosition = () => {
2373
- if (!bubbleRect) return {};
2374
- const positions = {
2375
- "bottom-left": {
2376
- bottom: `calc(100vh - ${bubbleRect.top}px)`,
2377
- left: `${bubbleRect.right}px`
2378
- },
2379
- "bottom-right": {
2380
- bottom: `calc(100vh - ${bubbleRect.top}px)`,
2381
- right: `calc(100vw - ${bubbleRect.left}px)`
2382
- },
2383
- "top-left": {
2384
- top: `${bubbleRect.bottom}px`,
2385
- left: `${bubbleRect.right}px`
2386
- },
2387
- "top-right": {
2388
- top: `${bubbleRect.bottom}px`,
2389
- right: `calc(100vw - ${bubbleRect.left}px)`
2351
+ const ref = React.useRef(null);
2352
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2353
+ /* @__PURE__ */ jsxRuntime.jsx(
2354
+ reablocks.ConnectedOverlay,
2355
+ {
2356
+ placement: position,
2357
+ modifiers,
2358
+ reference: ref.current,
2359
+ open: isOpen,
2360
+ onOpen: () => setIsOpen(true),
2361
+ onClose: () => setIsOpen(false),
2362
+ content: () => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children })
2390
2363
  }
2391
- };
2392
- return positions[position];
2393
- };
2394
- const content = React.useMemo(
2395
- () => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2396
- /* @__PURE__ */ jsxRuntime.jsx(
2397
- "div",
2398
- {
2399
- ref: bubbleRef,
2400
- style: {
2401
- ...customPosition,
2402
- ...portalTarget ? { position: "absolute" } : {}
2403
- },
2404
- onClick: handleToggle,
2405
- className: reablocks.cn(
2406
- "z-[1000]",
2407
- !portalTarget && "fixed",
2408
- defaultPositions[position],
2409
- "cursor-pointer",
2410
- className
2411
- ),
2412
- role: "button",
2413
- tabIndex: 0,
2414
- "aria-label": "Open chat",
2415
- children: bubbleContent
2416
- }
2417
- ),
2418
- /* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { children: children && isOpen && bubbleRect && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2419
- /* @__PURE__ */ jsxRuntime.jsx(
2420
- react.motion.div,
2421
- {
2422
- initial: { opacity: 0 },
2423
- animate: { opacity: 0.5 },
2424
- exit: { opacity: 0 },
2425
- className: "fixed inset-0 z-[998]",
2426
- onClick: handleClose
2427
- }
2428
- ),
2429
- /* @__PURE__ */ jsxRuntime.jsx(
2430
- react.motion.div,
2431
- {
2432
- ref: contentRef,
2433
- initial: false,
2434
- animate: {
2435
- opacity: 1,
2436
- scale: 1,
2437
- x: 0,
2438
- pointerEvents: "auto"
2439
- },
2440
- exit: {
2441
- opacity: 0,
2442
- scale: 0.8,
2443
- x: position.includes("right") ? 20 : -20,
2444
- pointerEvents: "none"
2445
- },
2446
- transition: { type: "spring", duration: 0.5 },
2447
- className: reablocks.cn(
2448
- "fixed z-[999]",
2449
- position.includes("right") ? "origin-right" : "origin-left",
2450
- position.includes("top") ? "origin-top" : "origin-bottom"
2451
- ),
2452
- style: getContentPosition(),
2453
- children
2454
- }
2455
- )
2456
- ] }) })
2457
- ] }),
2458
- [
2459
- children,
2460
- customPosition,
2461
- portalTarget,
2462
- position,
2463
- className,
2464
- bubbleContent,
2465
- isOpen,
2466
- handleClose,
2467
- handleToggle,
2468
- bubbleRect
2469
- ]
2470
- );
2471
- if (!portalTarget) {
2472
- return content;
2473
- }
2474
- try {
2475
- return reactDom.createPortal(content, portalTarget);
2476
- } catch (error) {
2477
- console.error("Failed to create portal for ChatBubble:", error);
2478
- return content;
2479
- }
2364
+ ),
2365
+ /* @__PURE__ */ jsxRuntime.jsx(
2366
+ "div",
2367
+ {
2368
+ ref,
2369
+ className,
2370
+ onClick: () => setIsOpen((prev) => !prev),
2371
+ children: bubbleContent
2372
+ }
2373
+ )
2374
+ ] });
2480
2375
  }
2481
2376
  );
2482
2377
  exports2.AppBar = AppBar;