-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add components to ChatComposer (#3964)
* chore(chat-composer): add fontSize and lineHeight to props * feat(composer): wip base elements * feat(composer): addition of all attatchment components * feat(composer): lint fix * feat(composer): fix disabled styling * feat(composer): customization stories * feat(composer): testing * feat(composer): import cleanup * feat(composer): build changes * feat(composer): responsive columns and JS doc * feat(anchor): border radius * feat(composer): changesets * chore(composer): update typedocs * chore(composer): fix lint * chore(composer): missing codemod * feat(composer): add new plugin to access state * feat(composer): fix lint issues * chore(chat-composer): fix spellings * chore(chat-composer): styling updates from PR comments * chore(chat-composer): udpate typedocs * chore(lexical-library): added changeset for export * chore(lexical-library): update changeset * chore(chat-composer): naming updates * chore(chat-composer): chnage stlying types * chore(ai-chatl-log): added changeset * chore(ai-chatl-log): updated changeset * chore(chat-composer): pr cleanup * chore(chat-composer): refactor ChatCompaserAttachment * chore(chat-composer): add fontSize and lineHeight to props * feat(composer): wip base elements * feat(composer): addition of all attatchment components * feat(composer): lint fix * feat(composer): fix disabled styling * feat(composer): customization stories * feat(composer): testing * feat(composer): import cleanup * feat(composer): build changes * feat(composer): responsive columns and JS doc * feat(anchor): border radius * feat(composer): changesets * chore(composer): update typedocs * chore(composer): fix lint * chore(composer): missing codemod * feat(composer): add new plugin to access state * feat(composer): fix lint issues * chore(chat-composer): fix spellings * chore(chat-composer): styling updates from PR comments * chore(chat-composer): udpate typedocs * chore(lexical-library): added changeset for export * chore(lexical-library): update changeset * chore(chat-composer): naming updates * chore(chat-composer): chnage stlying types * chore(ai-chatl-log): added changeset * chore(ai-chatl-log): updated changeset * chore(chat-composer): pr cleanup * chore(chat-composer): refactor ChatCompaserAttachment * chore(chat-composer): rename editorRef in stories * chore(chat-composer): change CSS grid so rowGap conditionally applied if attachemnt group present * chore(chat-composer): add fontSize and lineHeight to props * feat(composer): wip base elements * feat(composer): addition of all attatchment components * feat(composer): lint fix * feat(composer): fix disabled styling * feat(composer): responsive columns and JS doc * feat(composer): add new plugin to access state * feat(composer): fix lint issues * chore(chat-composer): fix spellings * chore(chat-composer): styling updates from PR comments * chore(chat-composer): chnage stlying types * chore(chat-composer): pr cleanup * chore(chat-composer): refactor ChatCompaserAttachment * chore(chat-composer): change CSS grid so rowGap conditionally applied if attachemnt group present * chore(chat-composer): changeset update * chore(chat-composer): codemods& lint * chore(lexical): changeset * chore(chat-composer): flex attachments group to full width --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
d3aefd3
commit 7779a24
Showing
28 changed files
with
6,633 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@twilio-paste/codemods": minor | ||
--- | ||
|
||
[ChatComposer] Added new components to allow contained variants, actions buttons and attachments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@twilio-paste/chat-composer": minor | ||
"@twilio-paste/core": minor | ||
--- | ||
|
||
[ChatComposer] Added new components to allow contained variants, actions buttons and attachments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@twilio-paste/ai-chat-log": patch | ||
"@twilio-paste/core": patch | ||
--- | ||
|
||
[AIChatLog] Updated internal styling types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@twilio-paste/lexical-library": minor | ||
"@twilio-paste/core": minor | ||
--- | ||
|
||
[Lexical] added export for EditorRefPlugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@twilio-paste/anchor": patch | ||
"@twilio-paste/core": patch | ||
--- | ||
|
||
[Anchor] Added border radius to focus styling |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 6 additions & 7 deletions
13
packages/paste-core/components/ai-chat-log/src/AIChatMessageBody.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
packages/paste-core/components/chat-composer/__tests__/ChatComposer.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { render, screen, waitFor } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import { $createParagraphNode, $createTextNode, $getRoot } from "@twilio-paste/lexical-library"; | ||
import { Theme } from "@twilio-paste/theme"; | ||
import * as React from "react"; | ||
|
||
import { ChatComposer } from "../src"; | ||
|
||
const initialText = (): void => { | ||
const root = $getRoot(); | ||
|
||
if (root.getFirstChild() === null) { | ||
const paragraph = $createParagraphNode(); | ||
paragraph.append($createTextNode("Hello")); | ||
|
||
root.append(paragraph); | ||
} | ||
}; | ||
|
||
const baseConfig = { | ||
namespace: "foo", | ||
onError: (error: Error) => { | ||
throw error; | ||
}, | ||
}; | ||
|
||
describe("ChatComposer", () => { | ||
it("should render with placeholder text", () => { | ||
render(<ChatComposer data-testid="my-composer" placeholder="Type here.." config={baseConfig} />); | ||
expect(screen.getByRole("textbox")).toBeDefined(); | ||
expect(screen.getByText("Type here..")).toBeDefined(); | ||
}); | ||
|
||
it("should pass props to the content editable", async () => { | ||
render( | ||
<ChatComposer | ||
data-testid="my-composer" | ||
ariaLabel="Feedback" | ||
ariaDescribedBy="foo" | ||
ariaOwns="foo" | ||
ariaActiveDescendant="foo" | ||
config={baseConfig} | ||
/>, | ||
); | ||
|
||
const contentEditable = screen.getByRole("textbox"); | ||
await waitFor(() => { | ||
expect(contentEditable).toHaveAttribute("aria-label", "Feedback"); | ||
expect(contentEditable).toHaveAttribute("aria-activedescendant", "foo"); | ||
expect(contentEditable).toHaveAttribute("aria-owns", "foo"); | ||
expect(contentEditable).toHaveAttribute("aria-describedby", "foo"); | ||
expect(contentEditable.dataset.testid).toEqual("my-composer"); | ||
}); | ||
}); | ||
|
||
it("should render initial value with the initialValue prop", async () => { | ||
render(<ChatComposer initialValue="Type here.." config={baseConfig} />); | ||
|
||
const contentEditable = screen.getByRole("textbox"); | ||
await waitFor(() => { | ||
expect(contentEditable).toHaveTextContent("Type here.."); | ||
}); | ||
}); | ||
|
||
it("should render custom initial value with the config prop", async () => { | ||
render( | ||
<ChatComposer | ||
config={{ | ||
...baseConfig, | ||
editorState: initialText, | ||
}} | ||
/>, | ||
); | ||
|
||
const contentEditable = screen.getByRole("textbox"); | ||
await waitFor(() => { | ||
expect(contentEditable).toHaveTextContent("Hello"); | ||
}); | ||
}); | ||
|
||
it("should set maxHeight with the maxHeight prop", async () => { | ||
render( | ||
<Theme.Provider theme="default"> | ||
<ChatComposer maxHeight="size10" config={baseConfig} /> | ||
</Theme.Provider>, | ||
); | ||
|
||
const wrapper = screen.getByRole("textbox").parentElement; | ||
await waitFor(() => { | ||
expect(wrapper).toHaveStyleRule("max-height", "5.5rem"); | ||
}); | ||
}); | ||
|
||
it("should call onChange function", async () => { | ||
const onChangeMock: jest.Mock = jest.fn(); | ||
|
||
render(<ChatComposer onChange={onChangeMock} config={baseConfig} />); | ||
|
||
const contentEditable = screen.getByRole("textbox"); | ||
|
||
userEvent.type(contentEditable, "foo bar"); | ||
waitFor(() => { | ||
expect(onChangeMock).toHaveBeenCalledTimes(1); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.