-
Notifications
You must be signed in to change notification settings - Fork 119
feat: add components to ChatComposer #3964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
81 commits
Select commit
Hold shift + click to select a range
83f6275
chore(chat-composer): add fontSize and lineHeight to props
krisantrobus 3ddda45
feat(composer): wip base elements
krisantrobus 9fe61d0
feat(composer): addition of all attatchment components
krisantrobus b482492
feat(composer): lint fix
krisantrobus 2b244c5
Merge branch 'main' of github.com:twilio-labs/paste into chore/chat-c…
krisantrobus 48e1f47
feat(composer): fix disabled styling
krisantrobus 3abd117
feat(composer): customization stories
krisantrobus ea302d0
feat(composer): testing
krisantrobus 6e47e71
feat(composer): import cleanup
krisantrobus 9ff59ce
feat(composer): build changes
krisantrobus 8bcfc2a
feat(composer): responsive columns and JS doc
krisantrobus 583d758
feat(anchor): border radius
krisantrobus 3993a04
feat(composer): changesets
krisantrobus a16718c
chore(composer): update typedocs
krisantrobus eb46fc4
chore(composer): fix lint
krisantrobus 1f8de1a
chore(composer): missing codemod
krisantrobus cccafd4
feat(composer): add new plugin to access state
krisantrobus 5caf933
feat(composer): fix lint issues
krisantrobus fec0c84
chore(chat-composer): fix spellings
krisantrobus 15f7020
chore(chat-composer): styling updates from PR comments
krisantrobus 8bfa07e
Merge branch 'main' of github.com:twilio-labs/paste into chore/chat-c…
krisantrobus b87b86d
chore(chat-composer): udpate typedocs
krisantrobus 019f6d5
chore(lexical-library): added changeset for export
krisantrobus 6bdf523
chore(lexical-library): update changeset
krisantrobus 6dc1f8f
chore(chat-composer): naming updates
krisantrobus 8390eb8
chore(chat-composer): chnage stlying types
krisantrobus ad6c2b7
chore(ai-chatl-log): added changeset
krisantrobus d0d5b67
chore(ai-chatl-log): updated changeset
krisantrobus a0636ef
chore(chat-composer): pr cleanup
krisantrobus 5eea7a2
chore(chat-composer): refactor ChatCompaserAttachment
krisantrobus 54d6687
chore(chat-composer): add fontSize and lineHeight to props
krisantrobus 202b839
feat(composer): wip base elements
krisantrobus d043493
feat(composer): addition of all attatchment components
krisantrobus bfc94a2
feat(composer): lint fix
krisantrobus e56b225
feat(composer): fix disabled styling
krisantrobus 7523621
feat(composer): customization stories
krisantrobus 8df066b
feat(composer): testing
krisantrobus 3b5e92d
feat(composer): import cleanup
krisantrobus a22dda5
feat(composer): build changes
krisantrobus 535dec8
feat(composer): responsive columns and JS doc
krisantrobus dc003a4
feat(anchor): border radius
krisantrobus c0e275c
feat(composer): changesets
krisantrobus dff1e1f
chore(composer): update typedocs
krisantrobus d9d73ec
chore(composer): fix lint
krisantrobus 587d4f2
chore(composer): missing codemod
krisantrobus eec0ec1
feat(composer): add new plugin to access state
krisantrobus 0e30560
feat(composer): fix lint issues
krisantrobus 80f3976
chore(chat-composer): fix spellings
krisantrobus 0f2a179
chore(chat-composer): styling updates from PR comments
krisantrobus 7fe1db9
chore(chat-composer): udpate typedocs
krisantrobus b63e78a
chore(lexical-library): added changeset for export
krisantrobus 425b802
chore(lexical-library): update changeset
krisantrobus e722acf
chore(chat-composer): naming updates
krisantrobus e84f02a
chore(chat-composer): chnage stlying types
krisantrobus 9ef9f03
chore(ai-chatl-log): added changeset
krisantrobus 3405cb6
chore(ai-chatl-log): updated changeset
krisantrobus 8253df1
chore(chat-composer): pr cleanup
krisantrobus 018849a
chore(chat-composer): refactor ChatCompaserAttachment
krisantrobus c975bc6
chore(chat-composer): rename editorRef in stories
krisantrobus c46e9a9
Merge branch 'chore/chat-composer-contained' of github.com:twilio-lab…
krisantrobus 97a1759
chore(chat-composer): change CSS grid so rowGap conditionally applied…
krisantrobus 283362d
chore(chat-composer): add fontSize and lineHeight to props
krisantrobus 096614b
feat(composer): wip base elements
krisantrobus 6b270db
feat(composer): addition of all attatchment components
krisantrobus 1581013
feat(composer): lint fix
krisantrobus 51dbff4
feat(composer): fix disabled styling
krisantrobus d17b508
feat(composer): responsive columns and JS doc
krisantrobus e305b2d
feat(composer): add new plugin to access state
krisantrobus 9fa1d7f
feat(composer): fix lint issues
krisantrobus f6dc5a1
chore(chat-composer): fix spellings
krisantrobus 4769dae
chore(chat-composer): styling updates from PR comments
krisantrobus fe959e3
chore(chat-composer): chnage stlying types
krisantrobus 4d8cde5
chore(chat-composer): pr cleanup
krisantrobus 330e644
chore(chat-composer): refactor ChatCompaserAttachment
krisantrobus d03b038
chore(chat-composer): change CSS grid so rowGap conditionally applied…
krisantrobus 2779501
chore(chat-composer): changeset update
krisantrobus ef8b92e
Merge branch 'chore/chat-composer-contained' of github.com:twilio-lab…
krisantrobus 8acef8f
chore(chat-composer): codemods& lint
krisantrobus a1a20ab
chore(lexical): changeset
krisantrobus e5c74fe
chore(chat-composer): flex attachments group to full width
krisantrobus d197b63
Merge branch 'main' into chore/chat-composer-contained
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: nice design improvement