### Development setup and verification Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/README.md Install dependencies, run the local docs and component playground, and run the full verification chain (format, types, lint, tests, build, pack, storybook). Requires Node 22.14.0 or newer. ```bash npm ci ``` ```bash npm run storybook # local docs + component playground ``` ```bash npm run verify # format + types + lint + tests + build + pack + storybook ``` -------------------------------- ### Update package registration and app setup Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/docs/07-migration-from-v2.mdx Shows the diff for replacing the v2 `register()` call with the V3 plugin and component imports. The V3 setup requires installing the plugin with `app.use(AdvancedChatPlugin({ strings: { … } }))` and importing the styles. ```diff - import { register } from 'vue-advanced-chat' - register() + import { AdvancedChatPlugin, AdvancedChat } from '@advanced-chat/components' + import '@advanced-chat/components/styles' const app = createApp(App) + app.use(AdvancedChatPlugin({ strings: { … } })) app.mount('#app') ``` -------------------------------- ### Vue 3 quick example - main.ts Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/README.md Sets up the Vue app with the AdvancedChatPlugin and imports the component styles. ```ts // main.ts import { createApp } from 'vue' import App from './App.vue' import { AdvancedChatPlugin } from '@advanced-chat/components' import '@advanced-chat/components/styles' createApp(App).use(AdvancedChatPlugin()).mount('#app') ``` -------------------------------- ### Set up local environment with nvm and npm ci Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/CONTRIBUTING.md Use the checked-in .nvmrc to select Node.js 22.14.0, then install dependencies with npm ci (not npm install) to validate the lockfile. ```sh nvm use npm ci ``` -------------------------------- ### Install vue-advanced-chat v2.1.2 Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/README.md Install the stable v2 line (2.1.2) of vue-advanced-chat via npm. ```bash npm install vue-advanced-chat ``` -------------------------------- ### Install V3 package with npm Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/README.md Install the V3 package using npm. Vue 3.5+ is a peer dependency. ```bash npm install @advanced-chat/components@next ``` -------------------------------- ### Vue 3 quick example - App.vue Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/README.md Defines the App.vue component using the AdvancedChat component with current user, chats, and messages. ```vue ``` -------------------------------- ### Install Playwright Chromium for browser tests Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/CONTRIBUTING.md Install Playwright Chromium when needed for browser tests. ```sh npx playwright install chromium ``` -------------------------------- ### Local + Server-Driven Hybrid Example Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/docs/composables/use-local-search.mdx Vue component demonstrating a hybrid search: local filtering with useLocalSearch and optional server-driven results via a custom onSearch callback. The custom flag toggles between local and remote modes. ```vue ``` -------------------------------- ### Wire the plugin in main.ts Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/docs/01-quick-start.mdx Registers the AdvancedChatPlugin and imports the required stylesheet. The plugin provides the localized strings dictionary; without it, components fall back to bundled English strings and warn under import.meta.env.DEV. The CSS import is required because styles are not inlined. ```ts import { createApp } from 'vue' import App from './App.vue' import { AdvancedChatPlugin } from '@advanced-chat/components' import '@advanced-chat/components/styles' const app = createApp(App) app.use( AdvancedChatPlugin({ // Optional — override any subset of the bundled English strings. strings: { 'chats.search.placeholder': 'Search conversations', }, }), ) app.mount('#app') ``` -------------------------------- ### Chat-row selection example Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/docs/composables/use-message-selection.mdx Vue component demonstrating bulk selection of chat rows using useMessageSelection. Includes script setup with toggle, cancel, and archive actions, plus a template with selection mode buttons and row highlighting. ```vue ``` -------------------------------- ### Read strings outside setup() with getLocalizationStrings Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/docs/04-localization.mdx Use `getLocalizationStrings('en')` to retrieve the dictionary in non-component contexts, such as formatting a notification body. The returned object is typed as `Strings`. ```ts import { getLocalizationStrings } from '@advanced-chat/components' const strings = getLocalizationStrings('en') const failedMessageText = strings['chat.message.failure'] ``` -------------------------------- ### Import the Strings type Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/docs/04-localization.mdx Import the `Strings` type from the package to get a typed map of all keys the components read. Hover the type in your editor for the complete list of keys. ```ts import type { Strings } from '@advanced-chat/components' ``` -------------------------------- ### Render the chat in App.vue Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/docs/01-quick-start.mdx A complete chat component with in-memory data. When a user chooses an @ suggestion, the composer stores a stable <@user-id> token in payload.content and includes resolved users in payload.mentionedUsers; persist content as emitted. MessageTemplate resolves known ids against the chat's users array, so later name changes do not invalidate stored messages. This minimal example disables file selection. ```vue ``` -------------------------------- ### Setup: Override strings via AdvancedChatPlugin Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/docs/04-localization.mdx Configure the plugin with a `Partial` object to override bundled English strings. The plugin deep-merges overrides on top of defaults; omitted keys keep their defaults. If the plugin is skipped, components fall back to English and emit a `console.warn` under `import.meta.env.DEV` (silenced in production). ```ts import { createApp } from 'vue' import { AdvancedChatPlugin } from '@advanced-chat/components' import App from './App.vue' createApp(App) .use( AdvancedChatPlugin({ strings: { 'chats.empty': 'No conversations yet', 'chat.message.placeholder': 'Send a message to your team', }, }), ) .mount('#app') ``` -------------------------------- ### Vue message-list pagination with useInfiniteScroll Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/docs/composables/use-infinite-scroll.mdx Pagination example for a message list using the useInfiniteScroll composable. The sentinel element triggers onLoadMore when scrolled into view; call setLoading(false) after new data arrives. fetchOlderMessages is an app-owned API placeholder to replace with your backend implementation. ```vue ``` -------------------------------- ### Use advanced-chat-components with Properties and Events Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/docs/08-web-components.mdx Assign objects and arrays as DOM properties; use attributes for simple strings, numbers, and booleans. The example sets up the chat with a current user, chats, and event listener for 'send-message'. ```html ``` -------------------------------- ### Custom composer example with useReplyEdit Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/docs/composables/use-reply-edit.mdx A Vue component wiring useReplyEdit into a custom message list and composer. dispatch handles built-in reply/edit actions and passes custom actions through; resetReply and resetEdit clear the respective refs. ```vue ``` -------------------------------- ### Vite SSR mounted flag with async chat surface Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/docs/06-ssr.mdx For non-Nuxt Vite SSR setups, render the same fallback during the server pass and the client's initial hydration render. Set a mounted flag in onMounted before rendering a lazily imported chat surface. Unlike const isSsr = import.meta.env.SSR, mounted is false for both the server render and the client's initial render, so the fallback hydrates against matching markup; the async chat module is requested only after mount. ```vue ``` -------------------------------- ### Import Styles type Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/docs/03-theming.mdx The supported CSS custom properties are typed via the exported `Styles` interface. Import it to get the full list with field names when hovering over the type in your editor. ```ts import type { Styles } from '@advanced-chat/components' ``` -------------------------------- ### Localization Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/docs/api-reference.mdx Exports for localization support, including types and functions to get localized strings. ```APIDOC ## Localization ### Localization - **Type**: `'en' | 'auto'` - **Description**: Locale configuration type. ### Strings - **Type**: Full string-key map (frozen as a typed contract — adding a key is a breaking change for typed consumers). - **Description**: Type representing the string keys. ### getLocalizationStrings - **Function**: `(locale: Localization) => Strings` - **Description**: Returns the localized strings. The `'auto'` case calls `negotiateLocale()` internally. ### useLocalizationStrings - **Composable**: `inject`-based accessor for component code; falls back to `'auto'` and warns under DEV when no plugin is installed. - **Description**: Composable for accessing localized strings. ### negotiateLocale - **Function**: `() => 'en'` - **Description**: Lowercases `navigator.language` and returns the first supported matching prefix (`'en'` only today). ``` -------------------------------- ### Vue component using useAutocomplete for slash-command menu Source: https://github.com/advanced-chat/advanced-chat-components/blob/main/docs/composables/use-autocomplete.mdx Example of a slash-command menu in Vue 3 with TypeScript. It uses the useAutocomplete composable from '@advanced-chat/components' to filter commands based on the message input, handle keyboard navigation, and commit selection. The component includes a textarea and a listbox with mouse and keyboard interactions. ```vue