Repository navigation
feat(react): add <ChatCops> component and useChatCops() hook (#573) - #583
Open
Saifjafri212213 wants to merge 1 commit into
Open
Saifjafri212213 wants to merge 1 commit into
Saifjafri212213 wants to merge 1 commit into
Conversation
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds the
@chatcops/reactpackage with a<ChatCops>component anduseChatCops()hook for React and Next.js applications (F-12 tasks 2 to 4).Closes #573
What was done
@chatcops/react:CONTRIBUTING.md:244("private": true,"type": "module", package exports,build,typecheck, andtestscripts).@chatcops/widget(workspace:^) andreact(>=18) as peer dependencies.<ChatCops {...props} />:null, safe for Server-Side Rendering (SSR).@chatcops/widgeton mount insideuseEffectwithout touchingwindowduring SSR.open,close,message,error,leadCaptured,preChatSubmit) usingChatCops.on(), keeping callbacks in a ref to avoid resubscribing on re-render.ChatCops.update()(branding,welcomeMessage,suggestions,placeholder,strings,theme,privacyUrl,disclosure) throughupdate().apiUrl,mode,container, ortheme.position).useChatCops()hook:{ open, close, toggle, send, update }controlling the widget instance.send()returns a resolved promise)..size-limit.jsonwith a 1 kB gzipped budget.website/src/content/docs/widget/react.mdxdocumenting setup, props, updates, anduseChatCops().website/astro.config.mjs.pnpm docs:check.How I tested this
packages/react/tests/react.test.tsx(13 tests) using React Testing Library andreact-dom/servercovering mount, StrictMode, unmount cleanup, update diffing, reinit diffing, ref callback persistence, handle controls, and SSRrenderToString.pnpm test:coverageverifying 100% statements, 93.75% branches, and 100% lines on@chatcops/react(exceeding the 85/80 threshold).pnpm lint(0 errors)pnpm publint(All good)pnpm api:check(Snapshots up to date)pnpm size(999 B gzipped vs 1 kB limit)pnpm docs:check(All 204 doc samples validated)pnpm -r build(Full workspace built clean)AI assistance
AI-assisted with code implementation, test authoring, and documentation generation.