@forgedevstack/bear 1.0.6 → 1.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.
- package/dist/components/Alert/Alert.cjs +1 -1
- package/dist/components/Alert/Alert.const.cjs +1 -1
- package/dist/components/Alert/Alert.const.d.ts +4 -0
- package/dist/components/Alert/Alert.const.js +9 -15
- package/dist/components/Alert/Alert.js +43 -38
- package/dist/components/AppBar/AppBar.cjs +1 -1
- package/dist/components/AppBar/AppBar.js +20 -16
- package/dist/components/BackTop/BackTop.cjs +1 -0
- package/dist/components/BackTop/BackTop.const.cjs +1 -0
- package/dist/components/BackTop/BackTop.const.d.ts +34 -0
- package/dist/components/BackTop/BackTop.const.js +29 -0
- package/dist/components/BackTop/BackTop.d.ts +21 -0
- package/dist/components/BackTop/BackTop.js +87 -0
- package/dist/components/BackTop/BackTop.types.d.ts +28 -0
- package/dist/components/BackTop/index.d.ts +3 -0
- package/dist/components/Badge/Badge.constants.d.ts +4 -4
- package/dist/components/Badge/Badge.types.d.ts +3 -3
- package/dist/components/BottomSheet/BottomSheet.cjs +1 -0
- package/dist/components/BottomSheet/BottomSheet.d.ts +3 -0
- package/dist/components/BottomSheet/BottomSheet.js +103 -0
- package/dist/components/BottomSheet/BottomSheet.types.d.ts +13 -0
- package/dist/components/BottomSheet/index.d.ts +2 -0
- package/dist/components/Button/Button.cjs +1 -1
- package/dist/components/Button/Button.constants.cjs +38 -48
- package/dist/components/Button/Button.constants.d.ts +22 -3
- package/dist/components/Button/Button.constants.js +51 -50
- package/dist/components/Button/Button.d.ts +14 -7
- package/dist/components/Button/Button.js +123 -43
- package/dist/components/Button/Button.types.d.ts +26 -4
- package/dist/components/Calendar/Calendar.cjs +1 -1
- package/dist/components/Calendar/Calendar.js +3 -2
- package/dist/components/Card/Card.const.d.ts +2 -2
- package/dist/components/Card/Card.types.d.ts +2 -2
- package/dist/components/Chat/Chat.cjs +1 -0
- package/dist/components/Chat/Chat.const.cjs +1 -0
- package/dist/components/Chat/Chat.const.d.ts +26 -0
- package/dist/components/Chat/Chat.const.js +29 -0
- package/dist/components/Chat/Chat.d.ts +21 -0
- package/dist/components/Chat/Chat.js +179 -0
- package/dist/components/Chat/Chat.types.d.ts +55 -0
- package/dist/components/Chat/index.d.ts +2 -0
- package/dist/components/Confetti/Confetti.cjs +1 -0
- package/dist/components/Confetti/Confetti.const.cjs +1 -0
- package/dist/components/Confetti/Confetti.const.d.ts +16 -0
- package/dist/components/Confetti/Confetti.const.js +36 -0
- package/dist/components/Confetti/Confetti.d.ts +23 -0
- package/dist/components/Confetti/Confetti.js +94 -0
- package/dist/components/Confetti/Confetti.types.d.ts +50 -0
- package/dist/components/Confetti/index.d.ts +4 -0
- package/dist/components/Confetti/useConfetti.cjs +1 -0
- package/dist/components/Confetti/useConfetti.d.ts +13 -0
- package/dist/components/Confetti/useConfetti.js +12 -0
- package/dist/components/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/DatePicker/DatePicker.js +3 -2
- package/dist/components/DiffViewer/DiffViewer.cjs +1 -0
- package/dist/components/DiffViewer/DiffViewer.const.cjs +1 -0
- package/dist/components/DiffViewer/DiffViewer.const.d.ts +18 -0
- package/dist/components/DiffViewer/DiffViewer.const.js +21 -0
- package/dist/components/DiffViewer/DiffViewer.d.ts +18 -0
- package/dist/components/DiffViewer/DiffViewer.js +127 -0
- package/dist/components/DiffViewer/DiffViewer.types.d.ts +40 -0
- package/dist/components/DiffViewer/DiffViewer.utils.cjs +3 -0
- package/dist/components/DiffViewer/DiffViewer.utils.d.ts +9 -0
- package/dist/components/DiffViewer/DiffViewer.utils.js +39 -0
- package/dist/components/DiffViewer/index.d.ts +2 -0
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +35 -35
- package/dist/components/EmojiPicker/EmojiPicker.cjs +1 -0
- package/dist/components/EmojiPicker/EmojiPicker.const.cjs +1 -0
- package/dist/components/EmojiPicker/EmojiPicker.const.d.ts +5 -0
- package/dist/components/EmojiPicker/EmojiPicker.const.js +10 -0
- package/dist/components/EmojiPicker/EmojiPicker.d.ts +3 -0
- package/dist/components/EmojiPicker/EmojiPicker.js +63 -0
- package/dist/components/EmojiPicker/EmojiPicker.types.d.ts +6 -0
- package/dist/components/EmojiPicker/index.d.ts +3 -0
- package/dist/components/FloatingChat/FloatingChat.cjs +1 -0
- package/dist/components/FloatingChat/FloatingChat.const.cjs +1 -0
- package/dist/components/FloatingChat/FloatingChat.const.d.ts +12 -0
- package/dist/components/FloatingChat/FloatingChat.const.js +15 -0
- package/dist/components/FloatingChat/FloatingChat.d.ts +19 -0
- package/dist/components/FloatingChat/FloatingChat.js +144 -0
- package/dist/components/FloatingChat/FloatingChat.types.d.ts +44 -0
- package/dist/components/FloatingChat/index.d.ts +2 -0
- package/dist/components/JsonViewer/JsonViewer.cjs +1 -0
- package/dist/components/JsonViewer/JsonViewer.const.cjs +1 -0
- package/dist/components/JsonViewer/JsonViewer.const.d.ts +4 -0
- package/dist/components/JsonViewer/JsonViewer.const.js +24 -0
- package/dist/components/JsonViewer/JsonViewer.d.ts +17 -0
- package/dist/components/JsonViewer/JsonViewer.js +195 -0
- package/dist/components/JsonViewer/JsonViewer.types.d.ts +54 -0
- package/dist/components/JsonViewer/index.d.ts +2 -0
- package/dist/components/Kanban/Kanban.cjs +1 -0
- package/dist/components/Kanban/Kanban.d.ts +3 -0
- package/dist/components/Kanban/Kanban.js +91 -0
- package/dist/components/Kanban/Kanban.types.d.ts +21 -0
- package/dist/components/Kanban/index.d.ts +2 -0
- package/dist/components/MentionsInput/MentionsInput.cjs +1 -0
- package/dist/components/MentionsInput/MentionsInput.d.ts +3 -0
- package/dist/components/MentionsInput/MentionsInput.js +140 -0
- package/dist/components/MentionsInput/MentionsInput.types.d.ts +21 -0
- package/dist/components/MentionsInput/index.d.ts +2 -0
- package/dist/components/QRCode/QRCode.cjs +1 -0
- package/dist/components/QRCode/QRCode.const.cjs +1 -0
- package/dist/components/QRCode/QRCode.const.d.ts +21 -0
- package/dist/components/QRCode/QRCode.const.js +11 -0
- package/dist/components/QRCode/QRCode.d.ts +29 -0
- package/dist/components/QRCode/QRCode.js +68 -0
- package/dist/components/QRCode/QRCode.types.d.ts +32 -0
- package/dist/components/QRCode/QRCode.utils.cjs +1 -0
- package/dist/components/QRCode/QRCode.utils.d.ts +12 -0
- package/dist/components/QRCode/QRCode.utils.js +74 -0
- package/dist/components/QRCode/index.d.ts +3 -0
- package/dist/components/RichEditor/RichEditor.cjs +1 -1
- package/dist/components/RichEditor/RichEditor.const.cjs +2 -2
- package/dist/components/RichEditor/RichEditor.const.d.ts +4 -1
- package/dist/components/RichEditor/RichEditor.const.js +51 -18
- package/dist/components/RichEditor/RichEditor.js +106 -105
- package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.cjs +1 -1
- package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.js +105 -95
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.cjs +1 -1
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.d.ts +2 -0
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.js +47 -29
- package/dist/components/SegmentedControl/SegmentedControl.cjs +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +3 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +58 -0
- package/dist/components/SegmentedControl/SegmentedControl.types.d.ts +16 -0
- package/dist/components/SegmentedControl/index.d.ts +2 -0
- package/dist/components/SignPad/SignPad.cjs +1 -1
- package/dist/components/SignPad/SignPad.js +98 -90
- package/dist/components/SliderRange/SliderRange.cjs +1 -0
- package/dist/components/SliderRange/SliderRange.d.ts +3 -0
- package/dist/components/SliderRange/SliderRange.js +142 -0
- package/dist/components/SliderRange/SliderRange.types.d.ts +17 -0
- package/dist/components/SliderRange/index.d.ts +2 -0
- package/dist/components/Spinner/Spinner.types.d.ts +2 -2
- package/dist/components/TagsInput/TagsInput.cjs +1 -0
- package/dist/components/TagsInput/TagsInput.d.ts +3 -0
- package/dist/components/TagsInput/TagsInput.js +100 -0
- package/dist/components/TagsInput/TagsInput.types.d.ts +16 -0
- package/dist/components/TagsInput/index.d.ts +2 -0
- package/dist/components/Terminal/Terminal.cjs +1 -0
- package/dist/components/Terminal/Terminal.const.cjs +1 -0
- package/dist/components/Terminal/Terminal.const.d.ts +32 -0
- package/dist/components/Terminal/Terminal.const.js +42 -0
- package/dist/components/Terminal/Terminal.d.ts +27 -0
- package/dist/components/Terminal/Terminal.js +155 -0
- package/dist/components/Terminal/Terminal.types.d.ts +49 -0
- package/dist/components/Terminal/index.d.ts +2 -0
- package/dist/components/Tour/Tour.cjs +1 -0
- package/dist/components/Tour/Tour.const.cjs +1 -0
- package/dist/components/Tour/Tour.const.d.ts +25 -0
- package/dist/components/Tour/Tour.const.js +38 -0
- package/dist/components/Tour/Tour.d.ts +17 -0
- package/dist/components/Tour/Tour.js +179 -0
- package/dist/components/Tour/Tour.types.d.ts +80 -0
- package/dist/components/Tour/index.d.ts +4 -0
- package/dist/components/Tour/useTour.cjs +1 -0
- package/dist/components/Tour/useTour.d.ts +14 -0
- package/dist/components/Tour/useTour.js +27 -0
- package/dist/components/Typography/Typography.cjs +1 -1
- package/dist/components/Typography/Typography.d.ts +5 -1
- package/dist/components/Typography/Typography.js +93 -57
- package/dist/components/Typography/Typography.types.d.ts +29 -2
- package/dist/components/VirtualList/VirtualList.cjs +1 -0
- package/dist/components/VirtualList/VirtualList.d.ts +3 -0
- package/dist/components/VirtualList/VirtualList.js +68 -0
- package/dist/components/VirtualList/VirtualList.types.d.ts +10 -0
- package/dist/components/VirtualList/index.d.ts +2 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +35 -1
- package/dist/components/index.js +240 -198
- package/dist/context/BearProvider.cjs +1 -1
- package/dist/context/BearProvider.d.ts +110 -5
- package/dist/context/BearProvider.js +198 -53
- package/dist/context/defaultTheme.cjs +1 -1
- package/dist/context/defaultTheme.js +11 -11
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +18 -0
- package/dist/hooks/index.js +56 -35
- package/dist/hooks/useBearComponent/index.d.ts +2 -0
- package/dist/hooks/useBearComponent/useBearComponent.cjs +1 -0
- package/dist/hooks/useBearComponent/useBearComponent.d.ts +71 -0
- package/dist/hooks/useBearComponent/useBearComponent.js +54 -0
- package/dist/hooks/useBearComponent/useBearComponent.types.d.ts +40 -0
- package/dist/hooks/useDragDrop/index.d.ts +2 -0
- package/dist/hooks/useDragDrop/useDragDrop.cjs +1 -0
- package/dist/hooks/useDragDrop/useDragDrop.d.ts +22 -0
- package/dist/hooks/useDragDrop/useDragDrop.js +56 -0
- package/dist/hooks/useDragDrop/useDragDrop.types.d.ts +55 -0
- package/dist/hooks/useIdle/index.d.ts +2 -0
- package/dist/hooks/useIdle/useIdle.cjs +1 -0
- package/dist/hooks/useIdle/useIdle.d.ts +22 -0
- package/dist/hooks/useIdle/useIdle.js +66 -0
- package/dist/hooks/useIdle/useIdle.types.d.ts +29 -0
- package/dist/hooks/useLazyLoad/index.d.ts +2 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.cjs +1 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.d.ts +26 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.js +27 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.types.d.ts +25 -0
- package/dist/hooks/useLongPress/index.d.ts +2 -0
- package/dist/hooks/useLongPress/useLongPress.cjs +1 -0
- package/dist/hooks/useLongPress/useLongPress.d.ts +17 -0
- package/dist/hooks/useLongPress/useLongPress.js +44 -0
- package/dist/hooks/useLongPress/useLongPress.types.d.ts +26 -0
- package/dist/hooks/useOnline/index.d.ts +2 -0
- package/dist/hooks/useOnline/useOnline.cjs +1 -0
- package/dist/hooks/useOnline/useOnline.d.ts +16 -0
- package/dist/hooks/useOnline/useOnline.js +25 -0
- package/dist/hooks/useOnline/useOnline.types.d.ts +15 -0
- package/dist/hooks/usePageVisibility/index.d.ts +2 -0
- package/dist/hooks/usePageVisibility/usePageVisibility.cjs +1 -0
- package/dist/hooks/usePageVisibility/usePageVisibility.d.ts +19 -0
- package/dist/hooks/usePageVisibility/usePageVisibility.js +26 -0
- package/dist/hooks/usePageVisibility/usePageVisibility.types.d.ts +15 -0
- package/dist/hooks/useSpotlight/index.d.ts +2 -0
- package/dist/hooks/useSpotlight/useSpotlight.cjs +1 -0
- package/dist/hooks/useSpotlight/useSpotlight.d.ts +24 -0
- package/dist/hooks/useSpotlight/useSpotlight.js +49 -0
- package/dist/hooks/useSpotlight/useSpotlight.types.d.ts +23 -0
- package/dist/hooks/useWebSocket/index.d.ts +2 -0
- package/dist/hooks/useWebSocket/useWebSocket.cjs +1 -0
- package/dist/hooks/useWebSocket/useWebSocket.d.ts +22 -0
- package/dist/hooks/useWebSocket/useWebSocket.js +75 -0
- package/dist/hooks/useWebSocket/useWebSocket.types.d.ts +44 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +327 -264
- package/dist/styles.css +1 -1
- package/dist/types/component.types.d.ts +125 -42
- package/dist/types/theme.types.d.ts +82 -0
- package/package.json +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsxs as m, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useState as x } from "react";
|
|
3
|
+
import { cn as t } from "../../utils/cn.js";
|
|
4
|
+
import { BEAR_EMOJIS as d } from "./EmojiPicker.const.js";
|
|
5
|
+
const h = {
|
|
6
|
+
sm: "bear-w-8 bear-h-8 bear-text-lg",
|
|
7
|
+
md: "bear-w-10 bear-h-10 bear-text-xl",
|
|
8
|
+
lg: "bear-w-12 bear-h-12 bear-text-2xl"
|
|
9
|
+
}, i = Object.keys(d), u = ({
|
|
10
|
+
onSelect: a,
|
|
11
|
+
size: s = "md",
|
|
12
|
+
maxHeight: b = 280,
|
|
13
|
+
className: n
|
|
14
|
+
}) => {
|
|
15
|
+
const [o, c] = x(i[0]), g = d[o] ?? [];
|
|
16
|
+
return /* @__PURE__ */ m(
|
|
17
|
+
"div",
|
|
18
|
+
{
|
|
19
|
+
className: t(
|
|
20
|
+
"Bear-EmojiPicker bear-flex bear-flex-col bear-rounded-lg bear-bg-white dark:bear-bg-zinc-800 bear-border bear-border-gray-200 dark:bear-border-zinc-700 bear-shadow-lg bear-overflow-hidden",
|
|
21
|
+
n
|
|
22
|
+
),
|
|
23
|
+
children: [
|
|
24
|
+
/* @__PURE__ */ e("div", { className: "bear-flex bear-gap-1 bear-p-2 bear-border-b bear-border-gray-200 dark:bear-border-zinc-700 bear-overflow-x-auto", children: i.map((r) => /* @__PURE__ */ e(
|
|
25
|
+
"button",
|
|
26
|
+
{
|
|
27
|
+
type: "button",
|
|
28
|
+
onClick: () => c(r),
|
|
29
|
+
className: t(
|
|
30
|
+
"bear-px-3 bear-py-1.5 bear-rounded-md bear-text-sm bear-font-medium bear-transition-colors bear-shrink-0",
|
|
31
|
+
o === r ? "bear-bg-gray-200 dark:bear-bg-zinc-700 bear-text-gray-900 dark:bear-text-white" : "bear-text-gray-600 dark:bear-text-zinc-400 hover:bear-text-gray-900 dark:hover:bear-text-white hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700/50"
|
|
32
|
+
),
|
|
33
|
+
children: r
|
|
34
|
+
},
|
|
35
|
+
r
|
|
36
|
+
)) }),
|
|
37
|
+
/* @__PURE__ */ e(
|
|
38
|
+
"div",
|
|
39
|
+
{
|
|
40
|
+
className: "bear-p-2 bear-overflow-y-auto bear-grid bear-grid-cols-8 bear-gap-1 bear-bg-gray-50 dark:bear-bg-zinc-900/50",
|
|
41
|
+
style: { maxHeight: typeof b == "number" ? `${b}px` : b },
|
|
42
|
+
children: g.map((r, l) => /* @__PURE__ */ e(
|
|
43
|
+
"button",
|
|
44
|
+
{
|
|
45
|
+
type: "button",
|
|
46
|
+
onClick: () => a == null ? void 0 : a(r),
|
|
47
|
+
className: t(
|
|
48
|
+
"bear-flex bear-items-center bear-justify-center bear-rounded-lg bear-transition-colors hover:bear-bg-gray-200 dark:hover:bear-bg-zinc-700",
|
|
49
|
+
h[s]
|
|
50
|
+
),
|
|
51
|
+
children: r
|
|
52
|
+
},
|
|
53
|
+
`${r}-${l}`
|
|
54
|
+
))
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
u as EmojiPicker
|
|
63
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),G=require("react-dom"),r=require("../../utils/cn.cjs"),U=require("../../context/BearProvider.cjs"),g=require("../Button/Button.cjs"),P=require("../Avatar/Avatar.cjs"),o=require("../Typography/Typography.cjs"),M=require("../Badge/Badge.cjs"),l=require("../Icon/index.cjs"),$=require("../Chat/Chat.cjs"),t=require("./FloatingChat.const.cjs"),Z=({messages:d,onSend:j,isLoading:b=!1,isTyping:S=!1,title:h=t.FLOATING_CHAT_DEFAULTS.TITLE,subtitle:_=t.FLOATING_CHAT_DEFAULTS.SUBTITLE,avatar:w,position:m=t.FLOATING_CHAT_DEFAULTS.POSITION,bottom:x=t.FLOATING_CHAT_DEFAULTS.BOTTOM,side:u=t.FLOATING_CHAT_DEFAULTS.SIDE,defaultOpen:E=!1,open:F,onOpenChange:s,trigger:T,badgeCount:i,header:y,welcomeMessage:p=t.FLOATING_CHAT_DEFAULTS.WELCOME_MESSAGE,poweredBy:A,className:L,testId:D})=>{const{mode:q}=U.useBear(),B=q==="dark",[C,v]=c.useState(E),[N,n]=c.useState(!1),a=F??C,I=c.useCallback(()=>{const f=!a;n(!0),v(f),s==null||s(f),setTimeout(()=>n(!1),300)},[a,s]),H=c.useCallback(()=>{n(!0),v(!1),s==null||s(!1),setTimeout(()=>n(!1),300)},[s]),k=d.length===0&&p?[{id:"welcome",content:p,sender:"bot",timestamp:new Date}]:d,z={bottom:`${x}px`,[m==="bottom-right"?"right":"left"]:`${u}px`},O={bottom:`${x+70}px`,[m==="bottom-right"?"right":"left"]:`${u}px`,width:t.CHAT_WINDOW_SIZE.width,height:t.CHAT_WINDOW_SIZE.height},W=e.jsxs("div",{className:r.cn("Bear-FloatingChat",L),"data-testid":D,children:[(a||N)&&e.jsxs("div",{className:r.cn("fixed z-50 rounded-2xl overflow-hidden shadow-2xl","transition-all duration-300 ease-out",a&&!N?"opacity-100 translate-y-0 scale-100":"opacity-0 translate-y-4 scale-95 pointer-events-none"),style:O,children:[y?e.jsx("div",{className:r.cn("px-4 py-3",B?"bg-gray-800":"bg-[var(--bear-primary-500)]"),children:y}):e.jsxs("div",{className:r.cn("px-4 py-3 flex items-center gap-3","bg-[var(--bear-primary-500)] text-white"),children:[e.jsx(P.Avatar,{src:w,initials:h[0],size:"sm",className:"ring-2 ring-white/20"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(o.Typography,{variant:"subtitle2",className:"text-white font-semibold",children:h}),e.jsx(o.Typography,{variant:"caption",className:"text-white/70",children:_})]}),e.jsx(g.Button,{variant:"ghost",size:"sm",onClick:H,className:"!text-white hover:!bg-white/10",children:e.jsx(l.BearIcons.XIcon,{size:18})})]}),e.jsx($.Chat,{messages:k,onSend:j,isLoading:b,isTyping:S,showAvatars:!1,height:t.CHAT_WINDOW_SIZE.height-140,className:"!rounded-none !border-0"}),A&&e.jsx("div",{className:"px-3 py-2 text-center border-t border-gray-200 dark:border-gray-700",children:e.jsxs(o.Typography,{variant:"caption",className:"opacity-50",children:["Powered by ",A]})})]}),e.jsx("div",{className:"fixed z-50",style:z,children:T?e.jsx("div",{onClick:I,children:T}):e.jsxs("div",{className:"relative",children:[e.jsx(g.Button,{variant:"primary",onClick:I,className:r.cn("!w-14 !h-14 !rounded-full !p-0 shadow-lg","transition-transform duration-200",a&&"rotate-180"),children:a?e.jsx(l.BearIcons.XIcon,{size:24}):e.jsx(l.BearIcons.ChatIcon,{size:24})}),!a&&i&&i>0&&e.jsx(M.Badge,{variant:"danger",size:"sm",className:"absolute -top-1 -right-1 !min-w-[20px] !h-5",children:i>99?"99+":i})]})})]});return typeof document>"u"?null:G.createPortal(W,document.body)};exports.FloatingChat=Z;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t={POSITION:"bottom-right",BOTTOM:20,SIDE:20,TITLE:"Chat",SUBTITLE:"We typically reply in a few minutes",WELCOME_MESSAGE:"Hi! How can we help you today?"},T={width:380,height:520};exports.CHAT_WINDOW_SIZE=T;exports.FLOATING_CHAT_DEFAULTS=t;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const FLOATING_CHAT_DEFAULTS: {
|
|
2
|
+
readonly POSITION: "bottom-right";
|
|
3
|
+
readonly BOTTOM: 20;
|
|
4
|
+
readonly SIDE: 20;
|
|
5
|
+
readonly TITLE: "Chat";
|
|
6
|
+
readonly SUBTITLE: "We typically reply in a few minutes";
|
|
7
|
+
readonly WELCOME_MESSAGE: "Hi! How can we help you today?";
|
|
8
|
+
};
|
|
9
|
+
export declare const CHAT_WINDOW_SIZE: {
|
|
10
|
+
readonly width: 380;
|
|
11
|
+
readonly height: 520;
|
|
12
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const t = {
|
|
2
|
+
POSITION: "bottom-right",
|
|
3
|
+
BOTTOM: 20,
|
|
4
|
+
SIDE: 20,
|
|
5
|
+
TITLE: "Chat",
|
|
6
|
+
SUBTITLE: "We typically reply in a few minutes",
|
|
7
|
+
WELCOME_MESSAGE: "Hi! How can we help you today?"
|
|
8
|
+
}, T = {
|
|
9
|
+
width: 380,
|
|
10
|
+
height: 520
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
T as CHAT_WINDOW_SIZE,
|
|
14
|
+
t as FLOATING_CHAT_DEFAULTS
|
|
15
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FloatingChatProps } from './FloatingChat.types';
|
|
3
|
+
/**
|
|
4
|
+
* FloatingChat - Floating chat widget bubble
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <FloatingChat
|
|
9
|
+
* messages={messages}
|
|
10
|
+
* onSend={handleSend}
|
|
11
|
+
* title="Support"
|
|
12
|
+
* subtitle="We're here to help!"
|
|
13
|
+
* position="bottom-right"
|
|
14
|
+
* badgeCount={2}
|
|
15
|
+
* />
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const FloatingChat: FC<FloatingChatProps>;
|
|
19
|
+
export default FloatingChat;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { jsxs as r, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as I, useCallback as S } from "react";
|
|
3
|
+
import { createPortal as Z } from "react-dom";
|
|
4
|
+
import { cn as s } from "../../utils/cn.js";
|
|
5
|
+
import { useBear as q } from "../../context/BearProvider.js";
|
|
6
|
+
import { Button as A } from "../Button/Button.js";
|
|
7
|
+
import { Avatar as J } from "../Avatar/Avatar.js";
|
|
8
|
+
import { Typography as c } from "../Typography/Typography.js";
|
|
9
|
+
import { Badge as K } from "../Badge/Badge.js";
|
|
10
|
+
import { BearIcons as n } from "../Icon/index.js";
|
|
11
|
+
import { Chat as O } from "../Chat/Chat.js";
|
|
12
|
+
import { FLOATING_CHAT_DEFAULTS as a, CHAT_WINDOW_SIZE as m } from "./FloatingChat.const.js";
|
|
13
|
+
const lt = ({
|
|
14
|
+
messages: d,
|
|
15
|
+
onSend: E,
|
|
16
|
+
isLoading: z = !1,
|
|
17
|
+
isTyping: k = !1,
|
|
18
|
+
title: h = a.TITLE,
|
|
19
|
+
subtitle: B = a.SUBTITLE,
|
|
20
|
+
avatar: D,
|
|
21
|
+
position: f = a.POSITION,
|
|
22
|
+
bottom: p = a.BOTTOM,
|
|
23
|
+
side: v = a.SIDE,
|
|
24
|
+
defaultOpen: L = !1,
|
|
25
|
+
open: _,
|
|
26
|
+
onOpenChange: e,
|
|
27
|
+
trigger: y,
|
|
28
|
+
badgeCount: o,
|
|
29
|
+
header: x,
|
|
30
|
+
welcomeMessage: u = a.WELCOME_MESSAGE,
|
|
31
|
+
poweredBy: N,
|
|
32
|
+
className: F,
|
|
33
|
+
testId: W
|
|
34
|
+
}) => {
|
|
35
|
+
const { mode: $ } = q(), M = $ === "dark", [P, b] = I(L), [w, l] = I(!1), i = _ ?? P, g = S(() => {
|
|
36
|
+
const T = !i;
|
|
37
|
+
l(!0), b(T), e == null || e(T), setTimeout(() => l(!1), 300);
|
|
38
|
+
}, [i, e]), j = S(() => {
|
|
39
|
+
l(!0), b(!1), e == null || e(!1), setTimeout(() => l(!1), 300);
|
|
40
|
+
}, [e]), G = d.length === 0 && u ? [{ id: "welcome", content: u, sender: "bot", timestamp: /* @__PURE__ */ new Date() }] : d, H = {
|
|
41
|
+
bottom: `${p}px`,
|
|
42
|
+
[f === "bottom-right" ? "right" : "left"]: `${v}px`
|
|
43
|
+
}, U = {
|
|
44
|
+
bottom: `${p + 70}px`,
|
|
45
|
+
[f === "bottom-right" ? "right" : "left"]: `${v}px`,
|
|
46
|
+
width: m.width,
|
|
47
|
+
height: m.height
|
|
48
|
+
}, X = /* @__PURE__ */ r("div", { className: s("Bear-FloatingChat", F), "data-testid": W, children: [
|
|
49
|
+
(i || w) && /* @__PURE__ */ r(
|
|
50
|
+
"div",
|
|
51
|
+
{
|
|
52
|
+
className: s(
|
|
53
|
+
"fixed z-50 rounded-2xl overflow-hidden shadow-2xl",
|
|
54
|
+
"transition-all duration-300 ease-out",
|
|
55
|
+
i && !w ? "opacity-100 translate-y-0 scale-100" : "opacity-0 translate-y-4 scale-95 pointer-events-none"
|
|
56
|
+
),
|
|
57
|
+
style: U,
|
|
58
|
+
children: [
|
|
59
|
+
x ? /* @__PURE__ */ t("div", { className: s(
|
|
60
|
+
"px-4 py-3",
|
|
61
|
+
M ? "bg-gray-800" : "bg-[var(--bear-primary-500)]"
|
|
62
|
+
), children: x }) : /* @__PURE__ */ r(
|
|
63
|
+
"div",
|
|
64
|
+
{
|
|
65
|
+
className: s(
|
|
66
|
+
"px-4 py-3 flex items-center gap-3",
|
|
67
|
+
"bg-[var(--bear-primary-500)] text-white"
|
|
68
|
+
),
|
|
69
|
+
children: [
|
|
70
|
+
/* @__PURE__ */ t(
|
|
71
|
+
J,
|
|
72
|
+
{
|
|
73
|
+
src: D,
|
|
74
|
+
initials: h[0],
|
|
75
|
+
size: "sm",
|
|
76
|
+
className: "ring-2 ring-white/20"
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
/* @__PURE__ */ r("div", { className: "flex-1", children: [
|
|
80
|
+
/* @__PURE__ */ t(c, { variant: "subtitle2", className: "text-white font-semibold", children: h }),
|
|
81
|
+
/* @__PURE__ */ t(c, { variant: "caption", className: "text-white/70", children: B })
|
|
82
|
+
] }),
|
|
83
|
+
/* @__PURE__ */ t(
|
|
84
|
+
A,
|
|
85
|
+
{
|
|
86
|
+
variant: "ghost",
|
|
87
|
+
size: "sm",
|
|
88
|
+
onClick: j,
|
|
89
|
+
className: "!text-white hover:!bg-white/10",
|
|
90
|
+
children: /* @__PURE__ */ t(n.XIcon, { size: 18 })
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
),
|
|
96
|
+
/* @__PURE__ */ t(
|
|
97
|
+
O,
|
|
98
|
+
{
|
|
99
|
+
messages: G,
|
|
100
|
+
onSend: E,
|
|
101
|
+
isLoading: z,
|
|
102
|
+
isTyping: k,
|
|
103
|
+
showAvatars: !1,
|
|
104
|
+
height: m.height - 140,
|
|
105
|
+
className: "!rounded-none !border-0"
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
N && /* @__PURE__ */ t("div", { className: "px-3 py-2 text-center border-t border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ r(c, { variant: "caption", className: "opacity-50", children: [
|
|
109
|
+
"Powered by ",
|
|
110
|
+
N
|
|
111
|
+
] }) })
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
/* @__PURE__ */ t("div", { className: "fixed z-50", style: H, children: y ? /* @__PURE__ */ t("div", { onClick: g, children: y }) : /* @__PURE__ */ r("div", { className: "relative", children: [
|
|
116
|
+
/* @__PURE__ */ t(
|
|
117
|
+
A,
|
|
118
|
+
{
|
|
119
|
+
variant: "primary",
|
|
120
|
+
onClick: g,
|
|
121
|
+
className: s(
|
|
122
|
+
"!w-14 !h-14 !rounded-full !p-0 shadow-lg",
|
|
123
|
+
"transition-transform duration-200",
|
|
124
|
+
i && "rotate-180"
|
|
125
|
+
),
|
|
126
|
+
children: i ? /* @__PURE__ */ t(n.XIcon, { size: 24 }) : /* @__PURE__ */ t(n.ChatIcon, { size: 24 })
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
!i && o && o > 0 && /* @__PURE__ */ t(
|
|
130
|
+
K,
|
|
131
|
+
{
|
|
132
|
+
variant: "danger",
|
|
133
|
+
size: "sm",
|
|
134
|
+
className: "absolute -top-1 -right-1 !min-w-[20px] !h-5",
|
|
135
|
+
children: o > 99 ? "99+" : o
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
] }) })
|
|
139
|
+
] });
|
|
140
|
+
return typeof document > "u" ? null : Z(X, document.body);
|
|
141
|
+
};
|
|
142
|
+
export {
|
|
143
|
+
lt as FloatingChat
|
|
144
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ChatMessage } from '../Chat/Chat.types';
|
|
3
|
+
export interface FloatingChatProps {
|
|
4
|
+
/** Chat messages */
|
|
5
|
+
messages: ChatMessage[];
|
|
6
|
+
/** Callback when user sends a message */
|
|
7
|
+
onSend?: (message: string) => void;
|
|
8
|
+
/** Loading state */
|
|
9
|
+
isLoading?: boolean;
|
|
10
|
+
/** Typing indicator */
|
|
11
|
+
isTyping?: boolean;
|
|
12
|
+
/** Chat title */
|
|
13
|
+
title?: string;
|
|
14
|
+
/** Chat subtitle */
|
|
15
|
+
subtitle?: string;
|
|
16
|
+
/** Avatar URL */
|
|
17
|
+
avatar?: string;
|
|
18
|
+
/** Position on screen */
|
|
19
|
+
position?: 'bottom-right' | 'bottom-left';
|
|
20
|
+
/** Distance from bottom */
|
|
21
|
+
bottom?: number;
|
|
22
|
+
/** Distance from side */
|
|
23
|
+
side?: number;
|
|
24
|
+
/** Initial open state */
|
|
25
|
+
defaultOpen?: boolean;
|
|
26
|
+
/** Controlled open state */
|
|
27
|
+
open?: boolean;
|
|
28
|
+
/** Callback when open state changes */
|
|
29
|
+
onOpenChange?: (open: boolean) => void;
|
|
30
|
+
/** Custom trigger button */
|
|
31
|
+
trigger?: ReactNode;
|
|
32
|
+
/** Badge count (e.g., unread messages) */
|
|
33
|
+
badgeCount?: number;
|
|
34
|
+
/** Header content */
|
|
35
|
+
header?: ReactNode;
|
|
36
|
+
/** Welcome message */
|
|
37
|
+
welcomeMessage?: string;
|
|
38
|
+
/** Show powered by */
|
|
39
|
+
poweredBy?: string;
|
|
40
|
+
/** Custom class name */
|
|
41
|
+
className?: string;
|
|
42
|
+
/** Test ID */
|
|
43
|
+
testId?: string;
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),S=require("../../utils/cn.cjs"),v=require("../../context/BearProvider.cjs"),A=require("../Typography/Typography.cjs"),I=require("../Button/Button.cjs"),g=require("../Icon/index.cjs"),u=require("./JsonViewer.const.cjs"),T=({name:r,value:s,path:d,depth:h,defaultExpandDepth:y,showDataTypes:j,showArrayIndices:x,onValueClick:c})=>{const[o,b]=i.useState(h<y),{mode:N}=v.useBear(),n=N==="dark"?u.DARK_THEME:u.DEFAULT_THEME,t=i.useMemo(()=>s===null?"null":Array.isArray(s)?"array":typeof s,[s]),p=t==="object"||t==="array",a=p&&Object.keys(s).length===0,f=i.useCallback(()=>{b(l=>!l)},[]),m=i.useCallback(()=>{c==null||c(d,s)},[d,s,c]),w=()=>{switch(t){case"string":return e.jsxs("span",{style:{color:n.string},className:"cursor-pointer hover:underline",onClick:m,children:['"',s,'"']});case"number":return e.jsx("span",{style:{color:n.number},className:"cursor-pointer hover:underline",onClick:m,children:String(s)});case"boolean":return e.jsx("span",{style:{color:n.boolean},className:"cursor-pointer hover:underline",onClick:m,children:String(s)});case"null":return e.jsx("span",{style:{color:n.null},className:"cursor-pointer hover:underline",onClick:m,children:"null"});default:return null}},k=()=>{if(!j)return null;const l=t==="array"?`Array(${s.length})`:t==="object"?"Object":t;return e.jsx("span",{className:"text-[10px] opacity-50 ml-1",children:l})};if(!p)return e.jsxs("div",{className:"flex items-center gap-1 py-0.5",children:[e.jsx("span",{className:"w-4"})," ",(x||typeof r=="string")&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:n.key},children:typeof r=="string"?`"${r}"`:r}),e.jsx("span",{style:{color:n.punctuation},children:":"})]}),w(),k()]});const B=Object.entries(s),q=t==="array"?"[":"{",E=t==="array"?"]":"}";return e.jsxs("div",{className:"py-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1 cursor-pointer hover:bg-black/5 dark:hover:bg-white/5 rounded px-1 -mx-1",onClick:f,children:[e.jsx("span",{className:"w-4 flex items-center justify-center text-gray-400",children:a?null:o?e.jsx(g.BearIcons.ChevronDownIcon,{size:12}):e.jsx(g.BearIcons.ChevronRightIcon,{size:12})}),(x||typeof r=="string")&&r!==""&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:n.key},children:typeof r=="string"?`"${r}"`:r}),e.jsx("span",{style:{color:n.punctuation},children:":"})]}),e.jsx("span",{style:{color:n.bracket},children:q}),!o&&!a&&e.jsx("span",{className:"text-gray-400 text-xs",children:"..."}),(!o||a)&&e.jsx("span",{style:{color:n.bracket},children:E}),k()]}),o&&!a&&e.jsx("div",{className:"ml-4 border-l border-gray-200 dark:border-gray-700 pl-2",children:B.map(([l,C],F)=>e.jsx(T,{name:t==="array"?F:l,value:C,path:[...d,l],depth:h+1,defaultExpandDepth:y,showDataTypes:j,showArrayIndices:x,onValueClick:c},l))}),o&&!a&&e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"w-4"}),e.jsx("span",{style:{color:n.bracket},children:E})]})]})},J=({data:r,defaultExpandDepth:s=u.DEFAULT_EXPAND_DEPTH,showDataTypes:d=!1,showArrayIndices:h=!0,showCopyButton:y=!0,rootName:j="root",onValueClick:x,onCopy:c,className:o,testId:b})=>{const{mode:N}=v.useBear(),n=N==="dark"?u.DARK_THEME:u.DEFAULT_THEME,[t,p]=i.useState(!1),a=i.useCallback(async()=>{try{await navigator.clipboard.writeText(JSON.stringify(r,null,2)),p(!0),c==null||c(r),setTimeout(()=>p(!1),2e3)}catch(f){console.error("Failed to copy:",f)}},[r,c]);return e.jsxs("div",{className:S.cn("Bear-JsonViewer","rounded-lg overflow-hidden font-mono text-sm",o),style:{backgroundColor:n.background},"data-testid":b,children:[y&&e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-gray-200 dark:border-gray-700",children:[e.jsx(A.Typography,{variant:"caption",className:"opacity-60",children:"JSON"}),e.jsx(I.Button,{variant:"ghost",size:"sm",onClick:a,className:"!py-1 !px-2 !text-xs",children:t?e.jsxs(e.Fragment,{children:[e.jsx(g.BearIcons.CheckIcon,{size:12,className:"mr-1"}),"Copied!"]}):e.jsxs(e.Fragment,{children:[e.jsx(g.BearIcons.CopyIcon,{size:12,className:"mr-1"}),"Copy"]})})]}),e.jsx("div",{className:"p-3 overflow-x-auto",children:e.jsx(T,{name:j||"",value:r,path:[],depth:0,defaultExpandDepth:s,showDataTypes:d,showArrayIndices:h,onValueClick:x})})]})};exports.JsonViewer=J;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=2,e={background:"var(--bear-bg-secondary, #f5f5f5)",string:"#22c55e",number:"#3b82f6",boolean:"#f59e0b",null:"#ef4444",key:"#ec4899",bracket:"var(--bear-text-secondary, #737373)",punctuation:"var(--bear-text-tertiary, #a3a3a3)"},r={background:"var(--bear-bg-secondary, #262626)",string:"#4ade80",number:"#60a5fa",boolean:"#fbbf24",null:"#f87171",key:"#f472b6",bracket:"var(--bear-text-secondary, #a3a3a3)",punctuation:"var(--bear-text-tertiary, #737373)"};exports.DARK_THEME=r;exports.DEFAULT_EXPAND_DEPTH=a;exports.DEFAULT_THEME=e;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const a = 2, e = {
|
|
2
|
+
background: "var(--bear-bg-secondary, #f5f5f5)",
|
|
3
|
+
string: "#22c55e",
|
|
4
|
+
number: "#3b82f6",
|
|
5
|
+
boolean: "#f59e0b",
|
|
6
|
+
null: "#ef4444",
|
|
7
|
+
key: "#ec4899",
|
|
8
|
+
bracket: "var(--bear-text-secondary, #737373)",
|
|
9
|
+
punctuation: "var(--bear-text-tertiary, #a3a3a3)"
|
|
10
|
+
}, r = {
|
|
11
|
+
background: "var(--bear-bg-secondary, #262626)",
|
|
12
|
+
string: "#4ade80",
|
|
13
|
+
number: "#60a5fa",
|
|
14
|
+
boolean: "#fbbf24",
|
|
15
|
+
null: "#f87171",
|
|
16
|
+
key: "#f472b6",
|
|
17
|
+
bracket: "var(--bear-text-secondary, #a3a3a3)",
|
|
18
|
+
punctuation: "var(--bear-text-tertiary, #737373)"
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
r as DARK_THEME,
|
|
22
|
+
a as DEFAULT_EXPAND_DEPTH,
|
|
23
|
+
e as DEFAULT_THEME
|
|
24
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { JsonViewerProps } from './JsonViewer.types';
|
|
3
|
+
/**
|
|
4
|
+
* JsonViewer - Pretty-print and explore JSON data
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <JsonViewer
|
|
9
|
+
* data={{ name: 'John', age: 30, active: true }}
|
|
10
|
+
* defaultExpandDepth={3}
|
|
11
|
+
* showDataTypes
|
|
12
|
+
* showCopyButton
|
|
13
|
+
* />
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const JsonViewer: FC<JsonViewerProps>;
|
|
17
|
+
export default JsonViewer;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { jsxs as o, jsx as e, Fragment as g } from "react/jsx-runtime";
|
|
2
|
+
import { useState as j, useCallback as v, useMemo as F } from "react";
|
|
3
|
+
import { cn as I } from "../../utils/cn.js";
|
|
4
|
+
import { useBear as T } from "../../context/BearProvider.js";
|
|
5
|
+
import { Typography as _ } from "../Typography/Typography.js";
|
|
6
|
+
import { Button as H } from "../Button/Button.js";
|
|
7
|
+
import { BearIcons as b } from "../Icon/index.js";
|
|
8
|
+
import { DARK_THEME as B, DEFAULT_THEME as C, DEFAULT_EXPAND_DEPTH as L } from "./JsonViewer.const.js";
|
|
9
|
+
const z = ({
|
|
10
|
+
name: r,
|
|
11
|
+
value: t,
|
|
12
|
+
path: d,
|
|
13
|
+
depth: h,
|
|
14
|
+
defaultExpandDepth: y,
|
|
15
|
+
showDataTypes: u,
|
|
16
|
+
showArrayIndices: p,
|
|
17
|
+
onValueClick: c
|
|
18
|
+
}) => {
|
|
19
|
+
const [l, x] = j(h < y), { mode: N } = T(), n = N === "dark" ? B : C, s = F(() => t === null ? "null" : Array.isArray(t) ? "array" : typeof t, [t]), m = s === "object" || s === "array", a = m && Object.keys(t).length === 0, k = v(() => {
|
|
20
|
+
x((i) => !i);
|
|
21
|
+
}, []), f = v(() => {
|
|
22
|
+
c == null || c(d, t);
|
|
23
|
+
}, [d, t, c]), A = () => {
|
|
24
|
+
switch (s) {
|
|
25
|
+
case "string":
|
|
26
|
+
return /* @__PURE__ */ o(
|
|
27
|
+
"span",
|
|
28
|
+
{
|
|
29
|
+
style: { color: n.string },
|
|
30
|
+
className: "cursor-pointer hover:underline",
|
|
31
|
+
onClick: f,
|
|
32
|
+
children: [
|
|
33
|
+
'"',
|
|
34
|
+
t,
|
|
35
|
+
'"'
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
case "number":
|
|
40
|
+
return /* @__PURE__ */ e(
|
|
41
|
+
"span",
|
|
42
|
+
{
|
|
43
|
+
style: { color: n.number },
|
|
44
|
+
className: "cursor-pointer hover:underline",
|
|
45
|
+
onClick: f,
|
|
46
|
+
children: String(t)
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
case "boolean":
|
|
50
|
+
return /* @__PURE__ */ e(
|
|
51
|
+
"span",
|
|
52
|
+
{
|
|
53
|
+
style: { color: n.boolean },
|
|
54
|
+
className: "cursor-pointer hover:underline",
|
|
55
|
+
onClick: f,
|
|
56
|
+
children: String(t)
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
case "null":
|
|
60
|
+
return /* @__PURE__ */ e(
|
|
61
|
+
"span",
|
|
62
|
+
{
|
|
63
|
+
style: { color: n.null },
|
|
64
|
+
className: "cursor-pointer hover:underline",
|
|
65
|
+
onClick: f,
|
|
66
|
+
children: "null"
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
default:
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}, E = () => {
|
|
73
|
+
if (!u) return null;
|
|
74
|
+
const i = s === "array" ? `Array(${t.length})` : s === "object" ? "Object" : s;
|
|
75
|
+
return /* @__PURE__ */ e("span", { className: "text-[10px] opacity-50 ml-1", children: i });
|
|
76
|
+
};
|
|
77
|
+
if (!m)
|
|
78
|
+
return /* @__PURE__ */ o("div", { className: "flex items-center gap-1 py-0.5", children: [
|
|
79
|
+
/* @__PURE__ */ e("span", { className: "w-4" }),
|
|
80
|
+
" ",
|
|
81
|
+
(p || typeof r == "string") && /* @__PURE__ */ o(g, { children: [
|
|
82
|
+
/* @__PURE__ */ e("span", { style: { color: n.key }, children: typeof r == "string" ? `"${r}"` : r }),
|
|
83
|
+
/* @__PURE__ */ e("span", { style: { color: n.punctuation }, children: ":" })
|
|
84
|
+
] }),
|
|
85
|
+
A(),
|
|
86
|
+
E()
|
|
87
|
+
] });
|
|
88
|
+
const J = Object.entries(t), O = s === "array" ? "[" : "{", w = s === "array" ? "]" : "}";
|
|
89
|
+
return /* @__PURE__ */ o("div", { className: "py-0.5", children: [
|
|
90
|
+
/* @__PURE__ */ o(
|
|
91
|
+
"div",
|
|
92
|
+
{
|
|
93
|
+
className: "flex items-center gap-1 cursor-pointer hover:bg-black/5 dark:hover:bg-white/5 rounded px-1 -mx-1",
|
|
94
|
+
onClick: k,
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ e("span", { className: "w-4 flex items-center justify-center text-gray-400", children: a ? null : l ? /* @__PURE__ */ e(b.ChevronDownIcon, { size: 12 }) : /* @__PURE__ */ e(b.ChevronRightIcon, { size: 12 }) }),
|
|
97
|
+
(p || typeof r == "string") && r !== "" && /* @__PURE__ */ o(g, { children: [
|
|
98
|
+
/* @__PURE__ */ e("span", { style: { color: n.key }, children: typeof r == "string" ? `"${r}"` : r }),
|
|
99
|
+
/* @__PURE__ */ e("span", { style: { color: n.punctuation }, children: ":" })
|
|
100
|
+
] }),
|
|
101
|
+
/* @__PURE__ */ e("span", { style: { color: n.bracket }, children: O }),
|
|
102
|
+
!l && !a && /* @__PURE__ */ e("span", { className: "text-gray-400 text-xs", children: "..." }),
|
|
103
|
+
(!l || a) && /* @__PURE__ */ e("span", { style: { color: n.bracket }, children: w }),
|
|
104
|
+
E()
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
l && !a && /* @__PURE__ */ e("div", { className: "ml-4 border-l border-gray-200 dark:border-gray-700 pl-2", children: J.map(([i, S], D) => /* @__PURE__ */ e(
|
|
109
|
+
z,
|
|
110
|
+
{
|
|
111
|
+
name: s === "array" ? D : i,
|
|
112
|
+
value: S,
|
|
113
|
+
path: [...d, i],
|
|
114
|
+
depth: h + 1,
|
|
115
|
+
defaultExpandDepth: y,
|
|
116
|
+
showDataTypes: u,
|
|
117
|
+
showArrayIndices: p,
|
|
118
|
+
onValueClick: c
|
|
119
|
+
},
|
|
120
|
+
i
|
|
121
|
+
)) }),
|
|
122
|
+
l && !a && /* @__PURE__ */ o("div", { className: "flex items-center", children: [
|
|
123
|
+
/* @__PURE__ */ e("span", { className: "w-4" }),
|
|
124
|
+
/* @__PURE__ */ e("span", { style: { color: n.bracket }, children: w })
|
|
125
|
+
] })
|
|
126
|
+
] });
|
|
127
|
+
}, G = ({
|
|
128
|
+
data: r,
|
|
129
|
+
defaultExpandDepth: t = L,
|
|
130
|
+
showDataTypes: d = !1,
|
|
131
|
+
showArrayIndices: h = !0,
|
|
132
|
+
showCopyButton: y = !0,
|
|
133
|
+
rootName: u = "root",
|
|
134
|
+
onValueClick: p,
|
|
135
|
+
onCopy: c,
|
|
136
|
+
className: l,
|
|
137
|
+
testId: x
|
|
138
|
+
}) => {
|
|
139
|
+
const { mode: N } = T(), n = N === "dark" ? B : C, [s, m] = j(!1), a = v(async () => {
|
|
140
|
+
try {
|
|
141
|
+
await navigator.clipboard.writeText(JSON.stringify(r, null, 2)), m(!0), c == null || c(r), setTimeout(() => m(!1), 2e3);
|
|
142
|
+
} catch (k) {
|
|
143
|
+
console.error("Failed to copy:", k);
|
|
144
|
+
}
|
|
145
|
+
}, [r, c]);
|
|
146
|
+
return /* @__PURE__ */ o(
|
|
147
|
+
"div",
|
|
148
|
+
{
|
|
149
|
+
className: I(
|
|
150
|
+
"Bear-JsonViewer",
|
|
151
|
+
"rounded-lg overflow-hidden font-mono text-sm",
|
|
152
|
+
l
|
|
153
|
+
),
|
|
154
|
+
style: { backgroundColor: n.background },
|
|
155
|
+
"data-testid": x,
|
|
156
|
+
children: [
|
|
157
|
+
y && /* @__PURE__ */ o("div", { className: "flex items-center justify-between px-3 py-2 border-b border-gray-200 dark:border-gray-700", children: [
|
|
158
|
+
/* @__PURE__ */ e(_, { variant: "caption", className: "opacity-60", children: "JSON" }),
|
|
159
|
+
/* @__PURE__ */ e(
|
|
160
|
+
H,
|
|
161
|
+
{
|
|
162
|
+
variant: "ghost",
|
|
163
|
+
size: "sm",
|
|
164
|
+
onClick: a,
|
|
165
|
+
className: "!py-1 !px-2 !text-xs",
|
|
166
|
+
children: s ? /* @__PURE__ */ o(g, { children: [
|
|
167
|
+
/* @__PURE__ */ e(b.CheckIcon, { size: 12, className: "mr-1" }),
|
|
168
|
+
"Copied!"
|
|
169
|
+
] }) : /* @__PURE__ */ o(g, { children: [
|
|
170
|
+
/* @__PURE__ */ e(b.CopyIcon, { size: 12, className: "mr-1" }),
|
|
171
|
+
"Copy"
|
|
172
|
+
] })
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
] }),
|
|
176
|
+
/* @__PURE__ */ e("div", { className: "p-3 overflow-x-auto", children: /* @__PURE__ */ e(
|
|
177
|
+
z,
|
|
178
|
+
{
|
|
179
|
+
name: u || "",
|
|
180
|
+
value: r,
|
|
181
|
+
path: [],
|
|
182
|
+
depth: 0,
|
|
183
|
+
defaultExpandDepth: t,
|
|
184
|
+
showDataTypes: d,
|
|
185
|
+
showArrayIndices: h,
|
|
186
|
+
onValueClick: p
|
|
187
|
+
}
|
|
188
|
+
) })
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
};
|
|
193
|
+
export {
|
|
194
|
+
G as JsonViewer
|
|
195
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JsonViewer component types
|
|
3
|
+
*/
|
|
4
|
+
export interface JsonViewerProps {
|
|
5
|
+
/** JSON data to display */
|
|
6
|
+
data: unknown;
|
|
7
|
+
/** Number of levels to expand by default (default: 2) */
|
|
8
|
+
defaultExpandDepth?: number;
|
|
9
|
+
/** Expand all nodes */
|
|
10
|
+
expandAll?: boolean;
|
|
11
|
+
/** Collapse all nodes */
|
|
12
|
+
collapseAll?: boolean;
|
|
13
|
+
/** Show data types */
|
|
14
|
+
showDataTypes?: boolean;
|
|
15
|
+
/** Show array indices */
|
|
16
|
+
showArrayIndices?: boolean;
|
|
17
|
+
/** Show copy button */
|
|
18
|
+
showCopyButton?: boolean;
|
|
19
|
+
/** Enable search */
|
|
20
|
+
enableSearch?: boolean;
|
|
21
|
+
/** Custom theme colors */
|
|
22
|
+
theme?: JsonViewerTheme;
|
|
23
|
+
/** Root name (default: 'root') */
|
|
24
|
+
rootName?: string | false;
|
|
25
|
+
/** Callback when a value is clicked */
|
|
26
|
+
onValueClick?: (path: string[], value: unknown) => void;
|
|
27
|
+
/** Callback when copied */
|
|
28
|
+
onCopy?: (value: unknown) => void;
|
|
29
|
+
/** Custom class name */
|
|
30
|
+
className?: string;
|
|
31
|
+
/** Test ID */
|
|
32
|
+
testId?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface JsonViewerTheme {
|
|
35
|
+
background?: string;
|
|
36
|
+
text?: string;
|
|
37
|
+
string?: string;
|
|
38
|
+
number?: string;
|
|
39
|
+
boolean?: string;
|
|
40
|
+
null?: string;
|
|
41
|
+
key?: string;
|
|
42
|
+
bracket?: string;
|
|
43
|
+
punctuation?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface JsonNodeProps {
|
|
46
|
+
name: string | number;
|
|
47
|
+
value: unknown;
|
|
48
|
+
path: string[];
|
|
49
|
+
depth: number;
|
|
50
|
+
defaultExpandDepth: number;
|
|
51
|
+
showDataTypes: boolean;
|
|
52
|
+
showArrayIndices: boolean;
|
|
53
|
+
onValueClick?: (path: string[], value: unknown) => void;
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),K=require("react"),m=require("../../utils/cn.cjs");require("../../context/BearProvider.cjs");const P=require("../../hooks/useDragDrop/useDragDrop.cjs");require("../../hooks/useBearComponent/useBearComponent.cjs");const S="bear-kanban",$=({columns:n,onColumnsChange:o,onCardMove:p,renderCard:h,renderColumnHeader:u,disabled:y=!1,className:v})=>{const w=K.useCallback((r,e,i,b,d)=>{const l=n.find(a=>a.id===r),s=n.find(a=>a.id===e);if(!l||!s)return;const f=n.map(a=>{if(a.id===r){const c=a.cards.filter((x,g)=>g!==i);return{...a,cards:c}}if(a.id===e){const c=r===e&&i<b?b-1:b,x=[...a.cards];return x.splice(Math.max(0,c),0,d),{...a,cards:x}}return a});o==null||o(f),p==null||p(d.id,r,e,i,b)},[n,o,p]),{getDragProps:N,getDropProps:j,isDragging:_,draggedId:z,dragOverId:k}=P.useDragDrop({disabled:y,dragType:S,onDrop:(r,e,i,b,d)=>{var D;const l=String(r),s=String(e),f=l.split("-")[0],a=parseInt(l.split("-")[1],10)||0,c=s.endsWith("-col")?s.replace("-col",""):s.split("-")[0],x=s.endsWith("-col")?((D=n.find(q=>q.id===c))==null?void 0:D.cards.length)??0:parseInt(s.split("-")[1],10),g=d;g!=null&&g.id&&w(f,c,a,x,g)}});return t.jsx("div",{className:m.cn("Bear-Kanban bear-flex bear-gap-4 bear-overflow-x-auto bear-pb-4",y&&"bear-opacity-50 bear-pointer-events-none",v),children:n.map(r=>t.jsxs("div",{...j(`${r.id}-col`,r,0),className:m.cn("Bear-Kanban__column bear-flex-shrink-0 bear-w-72 bear-flex bear-flex-col bear-rounded-lg bear-bg-gray-100 dark:bear-bg-zinc-800/80 bear-border bear-border-gray-200 dark:bear-border-zinc-700 bear-transition-colors",k===`${r.id}-col`&&"bear-border-bear-500 bear-bg-bear-500/5"),children:[t.jsx("div",{className:"bear-px-4 bear-py-3 bear-border-b bear-border-gray-200 dark:bear-border-zinc-700",children:u?u(r):t.jsx("h3",{className:"bear-text-sm bear-font-semibold bear-text-gray-900 dark:bear-text-white",children:r.title})}),t.jsx("div",{className:"bear-flex-1 bear-flex bear-flex-col bear-gap-2 bear-p-3 bear-min-h-[120px]",children:r.cards.map((e,i)=>{const b=`${r.id}-${i}`,d=_&&z===b;return t.jsx("div",{...j(b,e,i),...N(b,e,i),className:m.cn("Bear-Kanban__card bear-rounded-lg bear-bg-white dark:bear-bg-zinc-700/80 bear-border bear-border-gray-200 dark:bear-border-zinc-600 bear-p-3 bear-cursor-grab active:bear-cursor-grabbing bear-transition-all bear-shadow-sm",d&&"bear-opacity-50 bear-scale-95",k===b&&"bear-border-bear-500 bear-bg-bear-500/10"),children:h?h(e,r.id):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bear-font-medium bear-text-gray-900 dark:bear-text-white",children:e.title}),e.description&&t.jsx("div",{className:"bear-text-sm bear-text-gray-600 dark:bear-text-zinc-400 bear-mt-1",children:e.description}),e.meta&&t.jsx("div",{className:"bear-text-xs bear-text-gray-500 dark:bear-text-zinc-500 bear-mt-2",children:e.meta})]})},e.id)})})]},r.id))})};exports.Kanban=$;
|