@copilotkit/react-ui 0.3.0 → 0.5.0
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/.turbo/turbo-build.log +192 -13
- package/CHANGELOG.md +24 -0
- package/LICENSE +21 -0
- package/dist/chunk-46XC7ODX.mjs +72 -0
- package/dist/chunk-46XC7ODX.mjs.map +1 -0
- package/dist/chunk-4HK6C362.mjs +106 -0
- package/dist/chunk-4HK6C362.mjs.map +1 -0
- package/dist/chunk-6LAC5RA2.mjs +28 -0
- package/dist/chunk-6LAC5RA2.mjs.map +1 -0
- package/dist/chunk-6LRNF2VU.mjs +12 -0
- package/dist/chunk-6LRNF2VU.mjs.map +1 -0
- package/dist/chunk-7NSRDJ5C.mjs +3 -0
- package/dist/chunk-7NSRDJ5C.mjs.map +1 -0
- package/dist/chunk-BB6IP63P.mjs +29 -0
- package/dist/chunk-BB6IP63P.mjs.map +1 -0
- package/dist/chunk-BIPCPNHG.mjs +18 -0
- package/dist/chunk-BIPCPNHG.mjs.map +1 -0
- package/dist/chunk-BS6RR2DJ.mjs +25 -0
- package/dist/chunk-BS6RR2DJ.mjs.map +1 -0
- package/dist/chunk-DOMJCSI6.mjs +26 -0
- package/dist/chunk-DOMJCSI6.mjs.map +1 -0
- package/dist/chunk-E2YBQYWM.mjs +69 -0
- package/dist/chunk-E2YBQYWM.mjs.map +1 -0
- package/dist/chunk-E5BOIXYO.mjs +45 -0
- package/dist/chunk-E5BOIXYO.mjs.map +1 -0
- package/dist/chunk-H4VKQGVU.mjs +3 -0
- package/dist/chunk-H4VKQGVU.mjs.map +1 -0
- package/dist/chunk-I2AB5FK4.mjs +123 -0
- package/dist/chunk-I2AB5FK4.mjs.map +1 -0
- package/dist/chunk-IU3WTXLQ.mjs +3 -0
- package/dist/chunk-IU3WTXLQ.mjs.map +1 -0
- package/dist/chunk-KR7MH7XO.mjs +481 -0
- package/dist/chunk-KR7MH7XO.mjs.map +1 -0
- package/dist/chunk-KXJV37FS.mjs +33 -0
- package/dist/chunk-KXJV37FS.mjs.map +1 -0
- package/dist/chunk-MC6KTH4X.mjs +12 -0
- package/dist/chunk-MC6KTH4X.mjs.map +1 -0
- package/dist/chunk-MRXNTQOX.mjs +55 -0
- package/dist/chunk-MRXNTQOX.mjs.map +1 -0
- package/dist/chunk-N7KB3Z57.mjs +23 -0
- package/dist/chunk-N7KB3Z57.mjs.map +1 -0
- package/dist/chunk-QEXWZWJL.mjs +75 -0
- package/dist/chunk-QEXWZWJL.mjs.map +1 -0
- package/dist/chunk-RSONJDLO.mjs +28 -0
- package/dist/chunk-RSONJDLO.mjs.map +1 -0
- package/dist/chunk-SF56HSZW.mjs +48 -0
- package/dist/chunk-SF56HSZW.mjs.map +1 -0
- package/dist/chunk-TVTG3V4F.mjs +40 -0
- package/dist/chunk-TVTG3V4F.mjs.map +1 -0
- package/dist/chunk-U6NJWGTV.mjs +3 -0
- package/dist/chunk-U6NJWGTV.mjs.map +1 -0
- package/dist/chunk-V6QYUEJR.mjs +47 -0
- package/dist/chunk-V6QYUEJR.mjs.map +1 -0
- package/dist/chunk-VQNV2DHJ.mjs +142 -0
- package/dist/chunk-VQNV2DHJ.mjs.map +1 -0
- package/dist/chunk-VSNDSL6W.mjs +74 -0
- package/dist/chunk-VSNDSL6W.mjs.map +1 -0
- package/dist/chunk-XZFO2YEG.mjs +53 -0
- package/dist/chunk-XZFO2YEG.mjs.map +1 -0
- package/dist/components/chat-components/chat-list.d.ts +8 -0
- package/dist/components/chat-components/chat-list.mjs +13 -0
- package/dist/components/chat-components/chat-list.mjs.map +1 -0
- package/dist/components/chat-components/chat-message-actions.d.ts +8 -0
- package/dist/components/chat-components/chat-message-actions.mjs +8 -0
- package/dist/components/chat-components/chat-message-actions.mjs.map +1 -0
- package/dist/components/chat-components/chat-message.d.ts +8 -0
- package/dist/components/chat-components/chat-message.mjs +11 -0
- package/dist/components/chat-components/chat-message.mjs.map +1 -0
- package/dist/components/chat-components/chat-panel.d.ts +8 -0
- package/dist/components/chat-components/chat-panel.mjs +10 -0
- package/dist/components/chat-components/chat-panel.mjs.map +1 -0
- package/dist/components/chat-components/chat-scroll-anchor.d.ts +6 -0
- package/dist/components/chat-components/chat-scroll-anchor.mjs +5 -0
- package/dist/components/chat-components/chat-scroll-anchor.mjs.map +1 -0
- package/dist/components/chat-components/clear-history.d.ts +9 -0
- package/dist/components/chat-components/clear-history.mjs +81 -0
- package/dist/components/chat-components/clear-history.mjs.map +1 -0
- package/dist/components/chat-components/copilot-chat.d.ts +12 -0
- package/dist/components/chat-components/copilot-chat.mjs +22 -0
- package/dist/components/chat-components/copilot-chat.mjs.map +1 -0
- package/dist/components/chat-components/default-empty-screen.d.ts +8 -0
- package/dist/components/chat-components/default-empty-screen.mjs +8 -0
- package/dist/components/chat-components/default-empty-screen.mjs.map +1 -0
- package/dist/components/chat-components/external-link.d.ts +6 -0
- package/dist/components/chat-components/external-link.mjs +4 -0
- package/dist/components/chat-components/external-link.mjs.map +1 -0
- package/dist/components/chat-components/markdown.d.ts +6 -0
- package/dist/components/chat-components/markdown.mjs +4 -0
- package/dist/components/chat-components/markdown.mjs.map +1 -0
- package/dist/components/chat-components/prompt-form.d.ts +9 -0
- package/dist/components/chat-components/prompt-form.mjs +9 -0
- package/dist/components/chat-components/prompt-form.mjs.map +1 -0
- package/dist/components/chat-components/theme-toggle.d.ts +3 -0
- package/dist/components/chat-components/theme-toggle.mjs +36 -0
- package/dist/components/chat-components/theme-toggle.mjs.map +1 -0
- package/dist/components/chat-components/toaster.d.ts +1 -0
- package/dist/components/chat-components/toaster.mjs +4 -0
- package/dist/components/chat-components/toaster.mjs.map +1 -0
- package/dist/components/chat-components/ui/alert-dialog.d.ts +20 -0
- package/dist/components/chat-components/ui/alert-dialog.mjs +6 -0
- package/dist/components/chat-components/ui/alert-dialog.mjs.map +1 -0
- package/dist/components/chat-components/ui/badge.d.ts +12 -0
- package/dist/components/chat-components/ui/badge.mjs +31 -0
- package/dist/components/chat-components/ui/badge.mjs.map +1 -0
- package/dist/components/chat-components/ui/button.d.ts +14 -0
- package/dist/components/chat-components/ui/button.mjs +5 -0
- package/dist/components/chat-components/ui/button.mjs.map +1 -0
- package/dist/components/chat-components/ui/codeblock.d.ts +14 -0
- package/dist/components/chat-components/ui/codeblock.mjs +8 -0
- package/dist/components/chat-components/ui/codeblock.mjs.map +1 -0
- package/dist/components/chat-components/ui/dialog.d.ts +18 -0
- package/dist/components/chat-components/ui/dialog.mjs +119 -0
- package/dist/components/chat-components/ui/dialog.mjs.map +1 -0
- package/dist/components/chat-components/ui/dropdown-menu.d.ts +24 -0
- package/dist/components/chat-components/ui/dropdown-menu.mjs +84 -0
- package/dist/components/chat-components/ui/dropdown-menu.mjs.map +1 -0
- package/dist/components/chat-components/ui/icons.d.ts +33 -0
- package/dist/components/chat-components/ui/icons.mjs +5 -0
- package/dist/components/chat-components/ui/icons.mjs.map +1 -0
- package/dist/components/chat-components/ui/input.d.ts +7 -0
- package/dist/components/chat-components/ui/input.mjs +23 -0
- package/dist/components/chat-components/ui/input.mjs.map +1 -0
- package/dist/components/chat-components/ui/label.d.ts +8 -0
- package/dist/components/chat-components/ui/label.mjs +22 -0
- package/dist/components/chat-components/ui/label.mjs.map +1 -0
- package/dist/components/chat-components/ui/select.d.ts +13 -0
- package/dist/components/chat-components/ui/select.mjs +99 -0
- package/dist/components/chat-components/ui/select.mjs.map +1 -0
- package/dist/components/chat-components/ui/separator.d.ts +6 -0
- package/dist/components/chat-components/ui/separator.mjs +5 -0
- package/dist/components/chat-components/ui/separator.mjs.map +1 -0
- package/dist/components/chat-components/ui/sheet.d.ts +19 -0
- package/dist/components/chat-components/ui/sheet.mjs +109 -0
- package/dist/components/chat-components/ui/sheet.mjs.map +1 -0
- package/dist/components/chat-components/ui/switch.d.ts +6 -0
- package/dist/components/chat-components/ui/switch.mjs +27 -0
- package/dist/components/chat-components/ui/switch.mjs.map +1 -0
- package/dist/components/chat-components/ui/textarea.d.ts +7 -0
- package/dist/components/chat-components/ui/textarea.mjs +22 -0
- package/dist/components/chat-components/ui/textarea.mjs.map +1 -0
- package/dist/components/chat-components/ui/tooltip.d.ts +9 -0
- package/dist/components/chat-components/ui/tooltip.mjs +5 -0
- package/dist/components/chat-components/ui/tooltip.mjs.map +1 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.mjs +26 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/components/sidebar/copilot-sidebar-ui-provider.d.ts +8 -0
- package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs +25 -0
- package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs.map +1 -0
- package/dist/components/sidebar/copilot-sidebar.d.ts +6 -0
- package/dist/components/sidebar/copilot-sidebar.mjs +23 -0
- package/dist/components/sidebar/copilot-sidebar.mjs.map +1 -0
- package/dist/components/sidebar/sidebar-context.d.ts +9 -0
- package/dist/components/sidebar/sidebar-context.mjs +4 -0
- package/dist/components/sidebar/sidebar-context.mjs.map +1 -0
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.mjs +3 -0
- package/dist/context/index.mjs.map +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.mjs +3 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/hooks/use-at-bottom.d.ts +3 -0
- package/dist/hooks/use-at-bottom.mjs +4 -0
- package/dist/hooks/use-at-bottom.mjs.map +1 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts +9 -0
- package/dist/hooks/use-copy-to-clipboard.mjs +4 -0
- package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -0
- package/dist/hooks/use-enter-submit.d.ts +8 -0
- package/dist/hooks/use-enter-submit.mjs +4 -0
- package/dist/hooks/use-enter-submit.mjs.map +1 -0
- package/dist/index.css +1249 -1
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +9 -36
- package/dist/index.mjs +29 -26
- package/dist/index.mjs.map +1 -0
- package/dist/lib/utils.d.ts +8 -0
- package/dist/lib/utils.mjs +4 -0
- package/dist/lib/utils.mjs.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.mjs +3 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types/types.d.ts +16 -0
- package/dist/types/types.mjs +3 -0
- package/dist/types/types.mjs.map +1 -0
- package/package.json +7 -7
- package/src/components/chat-components/chat-list.tsx +8 -8
- package/src/components/chat-components/chat-message-actions.tsx +14 -14
- package/src/components/chat-components/chat-message.tsx +26 -26
- package/src/components/chat-components/chat-panel.tsx +18 -18
- package/src/components/chat-components/chat-scroll-anchor.tsx +12 -12
- package/src/components/chat-components/clear-history.tsx +22 -22
- package/src/components/chat-components/copilot-chat.tsx +45 -50
- package/src/components/chat-components/default-empty-screen.tsx +24 -22
- package/src/components/chat-components/external-link.tsx +4 -4
- package/src/components/chat-components/markdown.tsx +3 -3
- package/src/components/chat-components/prompt-form.tsx +27 -27
- package/src/components/chat-components/theme-toggle.tsx +11 -11
- package/src/components/chat-components/toaster.tsx +2 -2
- package/src/components/chat-components/ui/alert-dialog.tsx +35 -35
- package/src/components/chat-components/ui/badge.tsx +14 -14
- package/src/components/chat-components/ui/button.tsx +26 -26
- package/src/components/chat-components/ui/codeblock.tsx +70 -70
- package/src/components/chat-components/ui/dialog.tsx +29 -29
- package/src/components/chat-components/ui/dropdown-menu.tsx +35 -35
- package/src/components/chat-components/ui/icons.tsx +96 -96
- package/src/components/chat-components/ui/input.tsx +7 -7
- package/src/components/chat-components/ui/label.tsx +10 -10
- package/src/components/chat-components/ui/select.tsx +30 -30
- package/src/components/chat-components/ui/separator.tsx +10 -10
- package/src/components/chat-components/ui/sheet.tsx +31 -31
- package/src/components/chat-components/ui/switch.tsx +9 -9
- package/src/components/chat-components/ui/textarea.tsx +7 -7
- package/src/components/chat-components/ui/tooltip.tsx +11 -11
- package/src/components/index.ts +6 -6
- package/src/components/sidebar/copilot-sidebar-ui-provider.tsx +34 -31
- package/src/components/sidebar/copilot-sidebar.tsx +9 -9
- package/src/components/sidebar/sidebar-context.tsx +5 -5
- package/src/context/index.ts +1 -1
- package/src/hooks/index.ts +1 -1
- package/src/hooks/use-at-bottom.tsx +10 -10
- package/src/hooks/use-copy-to-clipboard.tsx +14 -14
- package/src/hooks/use-enter-submit.tsx +9 -9
- package/src/index.tsx +4 -4
- package/src/lib/utils.ts +20 -20
- package/src/types/index.ts +1 -1
- package/src/types/types.ts +10 -10
- package/tsup.config.ts +3 -4
- package/dist/index.js +0 -53
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
import * as React from
|
|
4
|
-
import * as SelectPrimitive from
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
5
5
|
|
|
6
|
-
import { cn } from
|
|
7
|
-
import { IconArrowDown, IconCheck, IconChevronUpDown } from
|
|
6
|
+
import { cn } from "../../../lib/utils";
|
|
7
|
+
import { IconArrowDown, IconCheck, IconChevronUpDown } from "./icons";
|
|
8
8
|
|
|
9
|
-
const Select = SelectPrimitive.Root
|
|
9
|
+
const Select = SelectPrimitive.Root;
|
|
10
10
|
|
|
11
|
-
const SelectGroup = SelectPrimitive.Group
|
|
11
|
+
const SelectGroup = SelectPrimitive.Group;
|
|
12
12
|
|
|
13
|
-
const SelectValue = SelectPrimitive.Value
|
|
13
|
+
const SelectValue = SelectPrimitive.Value;
|
|
14
14
|
|
|
15
15
|
const SelectTrigger = React.forwardRef<
|
|
16
16
|
React.ElementRef<typeof SelectPrimitive.Trigger>,
|
|
@@ -19,7 +19,7 @@ const SelectTrigger = React.forwardRef<
|
|
|
19
19
|
<SelectPrimitive.Trigger
|
|
20
20
|
ref={ref}
|
|
21
21
|
className={cn(
|
|
22
|
-
|
|
22
|
+
"flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
23
23
|
className
|
|
24
24
|
)}
|
|
25
25
|
{...props}
|
|
@@ -29,19 +29,19 @@ const SelectTrigger = React.forwardRef<
|
|
|
29
29
|
<IconChevronUpDown className="opacity-50" />
|
|
30
30
|
</SelectPrimitive.Icon>
|
|
31
31
|
</SelectPrimitive.Trigger>
|
|
32
|
-
))
|
|
33
|
-
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName
|
|
32
|
+
));
|
|
33
|
+
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
34
34
|
|
|
35
35
|
const SelectContent = React.forwardRef<
|
|
36
36
|
React.ElementRef<typeof SelectPrimitive.Content>,
|
|
37
37
|
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
|
38
|
-
>(({ className, children, position =
|
|
38
|
+
>(({ className, children, position = "popper", ...props }, ref) => (
|
|
39
39
|
<SelectPrimitive.Portal>
|
|
40
40
|
<SelectPrimitive.Content
|
|
41
41
|
ref={ref}
|
|
42
42
|
className={cn(
|
|
43
|
-
|
|
44
|
-
position ===
|
|
43
|
+
"relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md animate-in fade-in-80",
|
|
44
|
+
position === "popper" && "translate-y-1",
|
|
45
45
|
className
|
|
46
46
|
)}
|
|
47
47
|
position={position}
|
|
@@ -49,17 +49,17 @@ const SelectContent = React.forwardRef<
|
|
|
49
49
|
>
|
|
50
50
|
<SelectPrimitive.Viewport
|
|
51
51
|
className={cn(
|
|
52
|
-
|
|
53
|
-
position ===
|
|
54
|
-
|
|
52
|
+
"p-1",
|
|
53
|
+
position === "popper" &&
|
|
54
|
+
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
|
|
55
55
|
)}
|
|
56
56
|
>
|
|
57
57
|
{children}
|
|
58
58
|
</SelectPrimitive.Viewport>
|
|
59
59
|
</SelectPrimitive.Content>
|
|
60
60
|
</SelectPrimitive.Portal>
|
|
61
|
-
))
|
|
62
|
-
SelectContent.displayName = SelectPrimitive.Content.displayName
|
|
61
|
+
));
|
|
62
|
+
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
63
63
|
|
|
64
64
|
const SelectLabel = React.forwardRef<
|
|
65
65
|
React.ElementRef<typeof SelectPrimitive.Label>,
|
|
@@ -67,11 +67,11 @@ const SelectLabel = React.forwardRef<
|
|
|
67
67
|
>(({ className, ...props }, ref) => (
|
|
68
68
|
<SelectPrimitive.Label
|
|
69
69
|
ref={ref}
|
|
70
|
-
className={cn(
|
|
70
|
+
className={cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className)}
|
|
71
71
|
{...props}
|
|
72
72
|
/>
|
|
73
|
-
))
|
|
74
|
-
SelectLabel.displayName = SelectPrimitive.Label.displayName
|
|
73
|
+
));
|
|
74
|
+
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
75
75
|
|
|
76
76
|
const SelectItem = React.forwardRef<
|
|
77
77
|
React.ElementRef<typeof SelectPrimitive.Item>,
|
|
@@ -80,7 +80,7 @@ const SelectItem = React.forwardRef<
|
|
|
80
80
|
<SelectPrimitive.Item
|
|
81
81
|
ref={ref}
|
|
82
82
|
className={cn(
|
|
83
|
-
|
|
83
|
+
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
84
84
|
className
|
|
85
85
|
)}
|
|
86
86
|
{...props}
|
|
@@ -92,8 +92,8 @@ const SelectItem = React.forwardRef<
|
|
|
92
92
|
</span>
|
|
93
93
|
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
94
94
|
</SelectPrimitive.Item>
|
|
95
|
-
))
|
|
96
|
-
SelectItem.displayName = SelectPrimitive.Item.displayName
|
|
95
|
+
));
|
|
96
|
+
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
97
97
|
|
|
98
98
|
const SelectSeparator = React.forwardRef<
|
|
99
99
|
React.ElementRef<typeof SelectPrimitive.Separator>,
|
|
@@ -101,11 +101,11 @@ const SelectSeparator = React.forwardRef<
|
|
|
101
101
|
>(({ className, ...props }, ref) => (
|
|
102
102
|
<SelectPrimitive.Separator
|
|
103
103
|
ref={ref}
|
|
104
|
-
className={cn(
|
|
104
|
+
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
|
105
105
|
{...props}
|
|
106
106
|
/>
|
|
107
|
-
))
|
|
108
|
-
SelectSeparator.displayName = SelectPrimitive.Separator.displayName
|
|
107
|
+
));
|
|
108
|
+
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
109
109
|
|
|
110
110
|
export {
|
|
111
111
|
Select,
|
|
@@ -115,5 +115,5 @@ export {
|
|
|
115
115
|
SelectContent,
|
|
116
116
|
SelectLabel,
|
|
117
117
|
SelectItem,
|
|
118
|
-
SelectSeparator
|
|
119
|
-
}
|
|
118
|
+
SelectSeparator,
|
|
119
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
import * as React from
|
|
4
|
-
import * as SeparatorPrimitive from
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
5
5
|
|
|
6
|
-
import { cn } from
|
|
6
|
+
import { cn } from "../../../lib/utils";
|
|
7
7
|
|
|
8
8
|
const Separator = React.forwardRef<
|
|
9
9
|
React.ElementRef<typeof SeparatorPrimitive.Root>,
|
|
10
10
|
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
|
|
11
11
|
>(
|
|
12
12
|
(
|
|
13
|
-
{ className, orientation =
|
|
13
|
+
{ className, orientation = "horizontal", decorative = true, ...props },
|
|
14
14
|
ref
|
|
15
15
|
) => (
|
|
16
16
|
<SeparatorPrimitive.Root
|
|
@@ -18,14 +18,14 @@ const Separator = React.forwardRef<
|
|
|
18
18
|
decorative={decorative}
|
|
19
19
|
orientation={orientation}
|
|
20
20
|
className={cn(
|
|
21
|
-
|
|
22
|
-
orientation ===
|
|
21
|
+
"shrink-0 bg-border",
|
|
22
|
+
orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
|
|
23
23
|
className
|
|
24
24
|
)}
|
|
25
25
|
{...props}
|
|
26
26
|
/>
|
|
27
27
|
)
|
|
28
|
-
)
|
|
29
|
-
Separator.displayName = SeparatorPrimitive.Root.displayName
|
|
28
|
+
);
|
|
29
|
+
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
|
30
30
|
|
|
31
|
-
export { Separator }
|
|
31
|
+
export { Separator };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
import * as React from
|
|
4
|
-
import * as SheetPrimitive from
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as SheetPrimitive from "@radix-ui/react-dialog";
|
|
5
5
|
|
|
6
|
-
import { cn } from
|
|
7
|
-
import { IconClose } from
|
|
6
|
+
import { cn } from "../../../lib/utils";
|
|
7
|
+
import { IconClose } from "./icons";
|
|
8
8
|
|
|
9
|
-
const Sheet = SheetPrimitive.Root
|
|
9
|
+
const Sheet = SheetPrimitive.Root;
|
|
10
10
|
|
|
11
|
-
const SheetTrigger = SheetPrimitive.Trigger
|
|
11
|
+
const SheetTrigger = SheetPrimitive.Trigger;
|
|
12
12
|
|
|
13
|
-
const SheetClose = SheetPrimitive.Close
|
|
13
|
+
const SheetClose = SheetPrimitive.Close;
|
|
14
14
|
|
|
15
15
|
const SheetPortal = ({
|
|
16
16
|
className,
|
|
@@ -18,13 +18,13 @@ const SheetPortal = ({
|
|
|
18
18
|
...props
|
|
19
19
|
}: SheetPrimitive.DialogPortalProps) => (
|
|
20
20
|
<SheetPrimitive.Portal
|
|
21
|
-
className={cn(
|
|
21
|
+
className={cn("fixed inset-0 z-50 flex", className)}
|
|
22
22
|
{...props}
|
|
23
23
|
>
|
|
24
24
|
{children}
|
|
25
25
|
</SheetPrimitive.Portal>
|
|
26
|
-
)
|
|
27
|
-
SheetPortal.displayName = SheetPrimitive.Portal.displayName
|
|
26
|
+
);
|
|
27
|
+
SheetPortal.displayName = SheetPrimitive.Portal.displayName;
|
|
28
28
|
|
|
29
29
|
const SheetOverlay = React.forwardRef<
|
|
30
30
|
React.ElementRef<typeof SheetPrimitive.Overlay>,
|
|
@@ -32,14 +32,14 @@ const SheetOverlay = React.forwardRef<
|
|
|
32
32
|
>(({ className, children, ...props }, ref) => (
|
|
33
33
|
<SheetPrimitive.Overlay
|
|
34
34
|
className={cn(
|
|
35
|
-
|
|
35
|
+
"fixed inset-0 z-50 transition-all duration-100 data-[state=closed]:animate-out data-[state=closed]:fade-out data-[state=open]:fade-in",
|
|
36
36
|
className
|
|
37
37
|
)}
|
|
38
38
|
{...props}
|
|
39
39
|
ref={ref}
|
|
40
40
|
/>
|
|
41
|
-
))
|
|
42
|
-
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName
|
|
41
|
+
));
|
|
42
|
+
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
|
|
43
43
|
|
|
44
44
|
const SheetContent = React.forwardRef<
|
|
45
45
|
React.ElementRef<typeof SheetPrimitive.Content>,
|
|
@@ -49,7 +49,7 @@ const SheetContent = React.forwardRef<
|
|
|
49
49
|
<SheetPrimitive.Content
|
|
50
50
|
ref={ref}
|
|
51
51
|
className={cn(
|
|
52
|
-
|
|
52
|
+
"fixed z-50 h-full border-r bg-background p-6 opacity-100 shadow-lg data-[state=closed]:animate-slide-to-left data-[state=open]:animate-slide-from-left",
|
|
53
53
|
className
|
|
54
54
|
)}
|
|
55
55
|
{...props}
|
|
@@ -61,16 +61,16 @@ const SheetContent = React.forwardRef<
|
|
|
61
61
|
</SheetPrimitive.Close>
|
|
62
62
|
</SheetPrimitive.Content>
|
|
63
63
|
</SheetPortal>
|
|
64
|
-
))
|
|
65
|
-
SheetContent.displayName = SheetPrimitive.Content.displayName
|
|
64
|
+
));
|
|
65
|
+
SheetContent.displayName = SheetPrimitive.Content.displayName;
|
|
66
66
|
|
|
67
67
|
const SheetHeader = ({
|
|
68
68
|
className,
|
|
69
69
|
...props
|
|
70
70
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
71
|
-
<div className={cn(
|
|
72
|
-
)
|
|
73
|
-
SheetHeader.displayName =
|
|
71
|
+
<div className={cn("flex flex-col space-y-2", className)} {...props} />
|
|
72
|
+
);
|
|
73
|
+
SheetHeader.displayName = "SheetHeader";
|
|
74
74
|
|
|
75
75
|
const SheetFooter = ({
|
|
76
76
|
className,
|
|
@@ -78,13 +78,13 @@ const SheetFooter = ({
|
|
|
78
78
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
79
79
|
<div
|
|
80
80
|
className={cn(
|
|
81
|
-
|
|
81
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
82
82
|
className
|
|
83
83
|
)}
|
|
84
84
|
{...props}
|
|
85
85
|
/>
|
|
86
|
-
)
|
|
87
|
-
SheetFooter.displayName =
|
|
86
|
+
);
|
|
87
|
+
SheetFooter.displayName = "SheetFooter";
|
|
88
88
|
|
|
89
89
|
const SheetTitle = React.forwardRef<
|
|
90
90
|
React.ElementRef<typeof SheetPrimitive.Title>,
|
|
@@ -92,11 +92,11 @@ const SheetTitle = React.forwardRef<
|
|
|
92
92
|
>(({ className, ...props }, ref) => (
|
|
93
93
|
<SheetPrimitive.Title
|
|
94
94
|
ref={ref}
|
|
95
|
-
className={cn(
|
|
95
|
+
className={cn("text-lg font-semibold text-foreground", className)}
|
|
96
96
|
{...props}
|
|
97
97
|
/>
|
|
98
|
-
))
|
|
99
|
-
SheetTitle.displayName = SheetPrimitive.Title.displayName
|
|
98
|
+
));
|
|
99
|
+
SheetTitle.displayName = SheetPrimitive.Title.displayName;
|
|
100
100
|
|
|
101
101
|
const SheetDescription = React.forwardRef<
|
|
102
102
|
React.ElementRef<typeof SheetPrimitive.Description>,
|
|
@@ -104,11 +104,11 @@ const SheetDescription = React.forwardRef<
|
|
|
104
104
|
>(({ className, ...props }, ref) => (
|
|
105
105
|
<SheetPrimitive.Description
|
|
106
106
|
ref={ref}
|
|
107
|
-
className={cn(
|
|
107
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
108
108
|
{...props}
|
|
109
109
|
/>
|
|
110
|
-
))
|
|
111
|
-
SheetDescription.displayName = SheetPrimitive.Description.displayName
|
|
110
|
+
));
|
|
111
|
+
SheetDescription.displayName = SheetPrimitive.Description.displayName;
|
|
112
112
|
|
|
113
113
|
export {
|
|
114
114
|
Sheet,
|
|
@@ -118,5 +118,5 @@ export {
|
|
|
118
118
|
SheetHeader,
|
|
119
119
|
SheetFooter,
|
|
120
120
|
SheetTitle,
|
|
121
|
-
SheetDescription
|
|
122
|
-
}
|
|
121
|
+
SheetDescription,
|
|
122
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
import * as React from
|
|
4
|
-
import * as SwitchPrimitives from
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as SwitchPrimitives from "@radix-ui/react-switch";
|
|
5
5
|
|
|
6
|
-
import { cn } from
|
|
6
|
+
import { cn } from "../../../lib/utils";
|
|
7
7
|
|
|
8
8
|
const Switch = React.forwardRef<
|
|
9
9
|
React.ElementRef<typeof SwitchPrimitives.Root>,
|
|
@@ -11,7 +11,7 @@ const Switch = React.forwardRef<
|
|
|
11
11
|
>(({ className, ...props }, ref) => (
|
|
12
12
|
<SwitchPrimitives.Root
|
|
13
13
|
className={cn(
|
|
14
|
-
|
|
14
|
+
"peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
|
|
15
15
|
className
|
|
16
16
|
)}
|
|
17
17
|
{...props}
|
|
@@ -19,11 +19,11 @@ const Switch = React.forwardRef<
|
|
|
19
19
|
>
|
|
20
20
|
<SwitchPrimitives.Thumb
|
|
21
21
|
className={cn(
|
|
22
|
-
|
|
22
|
+
"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
|
|
23
23
|
)}
|
|
24
24
|
/>
|
|
25
25
|
</SwitchPrimitives.Root>
|
|
26
|
-
))
|
|
27
|
-
Switch.displayName = SwitchPrimitives.Root.displayName
|
|
26
|
+
));
|
|
27
|
+
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
28
28
|
|
|
29
|
-
export { Switch }
|
|
29
|
+
export { Switch };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as React from
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
|
|
3
|
-
import { cn } from
|
|
3
|
+
import { cn } from "../../../lib/utils";
|
|
4
4
|
|
|
5
5
|
export interface TextareaProps
|
|
6
6
|
extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
|
|
@@ -10,15 +10,15 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
10
10
|
return (
|
|
11
11
|
<textarea
|
|
12
12
|
className={cn(
|
|
13
|
-
|
|
13
|
+
"flex min-h-[80px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
14
14
|
className
|
|
15
15
|
)}
|
|
16
16
|
ref={ref}
|
|
17
17
|
{...props}
|
|
18
18
|
/>
|
|
19
|
-
)
|
|
19
|
+
);
|
|
20
20
|
}
|
|
21
|
-
)
|
|
22
|
-
Textarea.displayName =
|
|
21
|
+
);
|
|
22
|
+
Textarea.displayName = "Textarea";
|
|
23
23
|
|
|
24
|
-
export { Textarea }
|
|
24
|
+
export { Textarea };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
import * as React from
|
|
4
|
-
import * as TooltipPrimitive from
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
5
5
|
|
|
6
|
-
import { cn } from
|
|
6
|
+
import { cn } from "../../../lib/utils";
|
|
7
7
|
|
|
8
|
-
const TooltipProvider = TooltipPrimitive.Provider
|
|
8
|
+
const TooltipProvider = TooltipPrimitive.Provider;
|
|
9
9
|
|
|
10
|
-
const Tooltip = TooltipPrimitive.Root
|
|
10
|
+
const Tooltip = TooltipPrimitive.Root;
|
|
11
11
|
|
|
12
|
-
const TooltipTrigger = TooltipPrimitive.Trigger
|
|
12
|
+
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
13
13
|
|
|
14
14
|
const TooltipContent = React.forwardRef<
|
|
15
15
|
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
@@ -19,12 +19,12 @@ const TooltipContent = React.forwardRef<
|
|
|
19
19
|
ref={ref}
|
|
20
20
|
sideOffset={sideOffset}
|
|
21
21
|
className={cn(
|
|
22
|
-
|
|
22
|
+
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-xs font-medium text-popover-foreground shadow-md animate-in fade-in-50 data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1",
|
|
23
23
|
className
|
|
24
24
|
)}
|
|
25
25
|
{...props}
|
|
26
26
|
/>
|
|
27
|
-
))
|
|
28
|
-
TooltipContent.displayName = TooltipPrimitive.Content.displayName
|
|
27
|
+
));
|
|
28
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
29
29
|
|
|
30
|
-
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
|
|
30
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
package/src/components/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { CopilotChat } from
|
|
2
|
-
export { Tooltip, TooltipProvider } from
|
|
1
|
+
export { CopilotChat } from "./chat-components/copilot-chat";
|
|
2
|
+
export { Tooltip, TooltipProvider } from "./chat-components/ui/tooltip";
|
|
3
3
|
|
|
4
|
-
export { CopilotSidebarUIProvider } from
|
|
5
|
-
export { CopilotSidebar } from
|
|
6
|
-
export { CopilotSidebarContext } from
|
|
7
|
-
export type { CopilotSidebarContextType } from
|
|
4
|
+
export { CopilotSidebarUIProvider } from "./sidebar/copilot-sidebar-ui-provider";
|
|
5
|
+
export { CopilotSidebar } from "./sidebar/copilot-sidebar";
|
|
6
|
+
export { CopilotSidebarContext } from "./sidebar/sidebar-context";
|
|
7
|
+
export type { CopilotSidebarContextType } from "./sidebar/sidebar-context";
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import React, { ReactNode, useCallback } from
|
|
2
|
-
import { useState } from
|
|
3
|
-
import { CopilotSidebar } from
|
|
4
|
-
import { CopilotSidebarContext } from
|
|
1
|
+
import React, { ReactNode, useCallback } from "react";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { CopilotSidebar } from "./copilot-sidebar";
|
|
4
|
+
import { CopilotSidebarContext } from "./sidebar-context";
|
|
5
|
+
import { TooltipProvider } from "../chat-components/ui/tooltip";
|
|
5
6
|
|
|
6
7
|
export interface CopilotSidebarUIProviderProps {
|
|
7
|
-
children: ReactNode
|
|
8
|
+
children: ReactNode;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export function CopilotSidebarUIProvider({
|
|
11
|
-
children
|
|
12
|
+
children,
|
|
12
13
|
}: CopilotSidebarUIProviderProps) {
|
|
13
|
-
const [sidebarOpen, setSidebarOpen] = useState(true)
|
|
14
|
+
const [sidebarOpen, setSidebarOpen] = useState(true);
|
|
14
15
|
|
|
15
16
|
const toggleSidebar = useCallback(() => {
|
|
16
|
-
setSidebarOpen(prev => !prev)
|
|
17
|
-
}, [])
|
|
17
|
+
setSidebarOpen((prev) => !prev);
|
|
18
|
+
}, []);
|
|
18
19
|
|
|
19
20
|
return (
|
|
20
21
|
<CopilotSidebarContext.Provider
|
|
@@ -23,44 +24,46 @@ export function CopilotSidebarUIProvider({
|
|
|
23
24
|
<>
|
|
24
25
|
<div
|
|
25
26
|
style={{
|
|
26
|
-
height:
|
|
27
|
-
width:
|
|
28
|
-
position:
|
|
27
|
+
height: "100vh",
|
|
28
|
+
width: "100vw",
|
|
29
|
+
position: "relative",
|
|
29
30
|
}}
|
|
30
31
|
>
|
|
31
32
|
<div
|
|
32
33
|
style={{
|
|
33
|
-
overflowY:
|
|
34
|
-
overflowX:
|
|
35
|
-
height:
|
|
36
|
-
width: sidebarOpen ?
|
|
37
|
-
position:
|
|
38
|
-
transition:
|
|
34
|
+
overflowY: "auto",
|
|
35
|
+
overflowX: "hidden",
|
|
36
|
+
height: "100%",
|
|
37
|
+
width: sidebarOpen ? "calc(100% - 450px)" : "100%",
|
|
38
|
+
position: "absolute",
|
|
39
|
+
transition: "width 0.5s ease-in-out", // New
|
|
39
40
|
}}
|
|
40
41
|
>
|
|
41
42
|
<main>{children}</main>
|
|
42
43
|
</div>
|
|
43
44
|
<div
|
|
44
45
|
style={{
|
|
45
|
-
overflowY:
|
|
46
|
-
height:
|
|
47
|
-
width:
|
|
48
|
-
position:
|
|
49
|
-
right: sidebarOpen ?
|
|
50
|
-
transition:
|
|
46
|
+
overflowY: "auto",
|
|
47
|
+
height: "100%",
|
|
48
|
+
width: "450px",
|
|
49
|
+
position: "absolute",
|
|
50
|
+
right: sidebarOpen ? "0" : "-450px",
|
|
51
|
+
transition: "right 0.5s ease-in-out",
|
|
51
52
|
}}
|
|
52
53
|
>
|
|
53
|
-
<
|
|
54
|
+
<TooltipProvider>
|
|
55
|
+
<CopilotSidebar setSidebarOpen={setSidebarOpen} />
|
|
56
|
+
</TooltipProvider>
|
|
54
57
|
</div>
|
|
55
58
|
{!sidebarOpen && (
|
|
56
59
|
<button
|
|
57
60
|
onClick={toggleSidebar}
|
|
58
61
|
style={{
|
|
59
|
-
position:
|
|
60
|
-
top:
|
|
61
|
-
right:
|
|
62
|
-
transform:
|
|
63
|
-
transition:
|
|
62
|
+
position: "absolute",
|
|
63
|
+
top: "5%",
|
|
64
|
+
right: "20px",
|
|
65
|
+
transform: "translateY(-50%)",
|
|
66
|
+
transition: "opacity 0.5s ease-in-out",
|
|
64
67
|
}}
|
|
65
68
|
className="bg-slate-100 ring-2 ring-slate-600 font-semibold text-black p-2 rounded-lg shadow-lg"
|
|
66
69
|
>
|
|
@@ -70,5 +73,5 @@ export function CopilotSidebarUIProvider({
|
|
|
70
73
|
</div>
|
|
71
74
|
</>
|
|
72
75
|
</CopilotSidebarContext.Provider>
|
|
73
|
-
)
|
|
76
|
+
);
|
|
74
77
|
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { CopilotChat } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CopilotChat } from "../chat-components/copilot-chat";
|
|
3
3
|
|
|
4
4
|
export interface SidebarProps {
|
|
5
|
-
setSidebarOpen: (open: boolean) => void
|
|
5
|
+
setSidebarOpen: (open: boolean) => void;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export function CopilotSidebar(props: SidebarProps): JSX.Element {
|
|
9
9
|
return (
|
|
10
10
|
<div
|
|
11
|
-
className="shadow-lg bg-
|
|
12
|
-
style={{ width:
|
|
11
|
+
className="shadow-lg bg-gray-50 flex flex-col border-l-2"
|
|
12
|
+
style={{ width: "100%", height: "100%" }}
|
|
13
13
|
>
|
|
14
14
|
<TopBar {...props} />
|
|
15
15
|
<CopilotChat />
|
|
16
16
|
</div>
|
|
17
|
-
)
|
|
17
|
+
);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
import { XMarkIcon } from
|
|
20
|
+
import { XMarkIcon } from "@heroicons/react/24/outline";
|
|
21
21
|
|
|
22
22
|
function TopBar(props: SidebarProps): JSX.Element {
|
|
23
23
|
return (
|
|
24
|
-
<div className="py-6 bg-
|
|
24
|
+
<div className="py-6 flex bg-gray-50 items-center justify-between px-4">
|
|
25
25
|
<h1 className="text-base font-semibold leading-6 text-gray-900">
|
|
26
26
|
Copilot Chat
|
|
27
27
|
</h1>
|
|
@@ -36,5 +36,5 @@ function TopBar(props: SidebarProps): JSX.Element {
|
|
|
36
36
|
</button>
|
|
37
37
|
</div>
|
|
38
38
|
</div>
|
|
39
|
-
)
|
|
39
|
+
);
|
|
40
40
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createContext, ReactNode } from
|
|
1
|
+
import { createContext, ReactNode } from "react";
|
|
2
2
|
|
|
3
3
|
export interface CopilotSidebarContextType {
|
|
4
|
-
isSidebarOpen: boolean
|
|
5
|
-
toggleSidebar: () => void
|
|
4
|
+
isSidebarOpen: boolean;
|
|
5
|
+
toggleSidebar: () => void;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export const CopilotSidebarContext = createContext<CopilotSidebarContextType>({
|
|
9
9
|
isSidebarOpen: false,
|
|
10
|
-
toggleSidebar: () => {}
|
|
11
|
-
})
|
|
10
|
+
toggleSidebar: () => {},
|
|
11
|
+
});
|
package/src/context/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {};
|
package/src/hooks/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import * as React from
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
|
|
3
3
|
export function useAtBottom(offset = 0) {
|
|
4
|
-
const [isAtBottom, setIsAtBottom] = React.useState(false)
|
|
4
|
+
const [isAtBottom, setIsAtBottom] = React.useState(false);
|
|
5
5
|
|
|
6
6
|
React.useEffect(() => {
|
|
7
7
|
const handleScroll = () => {
|
|
8
8
|
setIsAtBottom(
|
|
9
9
|
window.innerHeight + window.scrollY >=
|
|
10
10
|
document.body.offsetHeight - offset
|
|
11
|
-
)
|
|
12
|
-
}
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
13
|
|
|
14
|
-
window.addEventListener(
|
|
15
|
-
handleScroll()
|
|
14
|
+
window.addEventListener("scroll", handleScroll, { passive: true });
|
|
15
|
+
handleScroll();
|
|
16
16
|
|
|
17
17
|
return () => {
|
|
18
|
-
window.removeEventListener(
|
|
19
|
-
}
|
|
20
|
-
}, [offset])
|
|
18
|
+
window.removeEventListener("scroll", handleScroll);
|
|
19
|
+
};
|
|
20
|
+
}, [offset]);
|
|
21
21
|
|
|
22
|
-
return isAtBottom
|
|
22
|
+
return isAtBottom;
|
|
23
23
|
}
|