-
Notifications
You must be signed in to change notification settings - Fork 122
Expand file tree
/
Copy pathChatComposerContainer.tsx
More file actions
77 lines (71 loc) · 2.28 KB
/
Copy pathChatComposerContainer.tsx
File metadata and controls
77 lines (71 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import type { BoxProps, BoxStyleProps } from "@twilio-paste/box";
import { Box, safelySpreadBoxProps } from "@twilio-paste/box";
import * as React from "react";
import { ChatComposerContext } from "./ChatComposerContext";
const Styles: Record<string, BoxStyleProps> = {
default: {},
contained: {
borderWidth: "borderWidth10",
borderStyle: "solid",
borderRadius: "borderRadius30",
borderColor: "colorBorderWeaker",
boxShadow: "shadowLow",
backgroundColor: "colorBackgroundBody",
},
};
export interface ChatComposerContainerProps {
children?: React.ReactNode;
/**
* Styling of the container
* @default 'default'
* @type {'default' | 'contained'}
* @memberof ChatComposerContainerProps
*/
variant?: "default" | "contained";
/**
* Overrides the default element name to apply unique styles with the Customization Provider
* @default 'CHAT_COMPOSER_CONTAINER'
* @type {BoxProps['element']}
* @memberof ChatComposerContainerProps
*/
element?: BoxProps["element"];
/**
* Sets the maximum height of the composer before scrolling
* @default 'size30'
* @type {BoxProps['maxHeight']}
* @memberof ChatComposerContainerProps
*/
maxHeight?: BoxProps["maxHeight"];
}
export const ChatComposerContainer = React.forwardRef<HTMLDivElement, ChatComposerContainerProps>(
({ variant = "default", element = "CHAT_COMPOSER_CONTAINER", maxHeight = "size40", children, ...props }, ref) => {
const [isDisabled, setIsDisabled] = React.useState(false);
return (
<ChatComposerContext.Provider value={{ isDisabled, setIsDisabled }}>
<Box
{...safelySpreadBoxProps(props)}
element={element}
ref={ref}
display="grid"
gridTemplateRows="auto-fit"
gridAutoColumns="1fr auto"
disabled={isDisabled}
aria-disabled={isDisabled}
_disabled={{
color: "colorTextWeaker",
backgroundColor: "colorBackground",
}}
padding="space30"
maxHeight={maxHeight}
// overflowY="auto"
rowGap="space50"
width="100%"
{...Styles[variant]}
>
{children}
</Box>
</ChatComposerContext.Provider>
);
},
);
ChatComposerContainer.displayName = "ChatComposerContainer";