mind-link-ai-widget
Version:
A react widget for React Web and React-Native Mobile integrations.
185 lines (142 loc) • 4.73 kB
Markdown
# Mind Link UI Widget Widget
The MindLinkAI widget is built with React, TypeScript, and Vite. Easily embed in any web app or React Native app.
## Usage
### Web (React/Vite/CRA/Next.js)
1. **Install**
```bash
npm install mind-link-ai-widget
# or
yarn add mind-link-ai-widget
```
2. **Import and Use**
```jsx
import MindLinkAIWidget from 'mind-link-ai-widget';
function App() {
return (
<div>
<MindLinkAIWidget />
</div>
);
}
export default App;
```
### React Native
1. **Install**
```bash
npm install mind-link-ai-widget
# or
yarn add mind-link-ai-widget
```
2. **Link Peer Dependencies**
Ensure `react`, `react-native`, and `react-dom` are installed in your project.
3. **Import and Use**
```jsx
import MindLinkAIWidget from 'mind-link-ai-widget';
export default function App() {
return <MindLinkAIWidget />;
}
```
## Build as a Library
To build the widget for distribution:
```bash
npm run build-widget
```
- Output: `widget/mind-link-ai-widget.umd.js`
## Development
- `npm run dev` - Start dev server
- `npm run build-widget` - Build library for distribution
## License
MIT
# React + TypeScript + Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
## Expanding the ESLint configuration
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
```js
export default tseslint.config([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Remove tseslint.configs.recommended and replace with this
...tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
...tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
...tseslint.configs.stylisticTypeChecked,
// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'
export default tseslint.config([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```
## Using as a Web Script
You can inject the MindLinkAI widget into any web app using the UMD bundle:
1. Add React and ReactDOM to your page (if not already present):
```html
<script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
```
2. Add the UMD bundle (after building, found in `widget/mind-link-ai-widget.umd.js`):
```html
<script src="/path/to/widget/mind-link-ai-widget.umd.js"></script>
<div id="my-ai-widget"></div>
<script>
ReactDOM.createRoot(document.getElementById('my-ai-widget')).render(
React.createElement(MindLinkAIWidget, {
onSendMessage: async (msg) => `Echo: ${msg}`
})
);
</script>
```
- The widget is available as `MindLinkAIWidget`.
- You can pass props as you would in React.
## Tech Stack & Requirements
- **Node.js:** ^20.19.0 or >=22.12.0 (recommended: latest LTS)
- **React:** ^19.1.0
- **React DOM:** ^19.1.0
- **Vite:** ^7.0.3
- **TypeScript:** ~5.8.3
- **react-icons:** ^5.5.0
> **Note:** Vite 7+ requires Node.js ^20.19.0 or >=22.12.0. If you see errors about `crypto.hash is not a function`, upgrade your Node.js version.