8
packages/react/.eslintrc.js
Normal file
8
packages/react/.eslintrc.js
Normal file
@ -0,0 +1,8 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: ['custom'],
|
||||
rules: {
|
||||
'@next/next/no-img-element': 'off',
|
||||
'@next/next/no-html-link-for-pages': 'off',
|
||||
},
|
||||
}
|
30
packages/react/package.json
Normal file
30
packages/react/package.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "@typebot.io/react",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "pnpm tsc --noEmit && tsup",
|
||||
"dev": "tsup --watch",
|
||||
"lint": "eslint --fix \"src/**/*.ts*\""
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Baptiste Arnaud",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@typebot.io/js": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.0.26",
|
||||
"eslint": "^8.30.0",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"react": "^18.2.0",
|
||||
"tsconfig": "workspace:*",
|
||||
"tsup": "6.5.0",
|
||||
"typescript": "^4.9.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "18.0.0"
|
||||
}
|
||||
}
|
27
packages/react/src/Standard.tsx
Normal file
27
packages/react/src/Standard.tsx
Normal file
@ -0,0 +1,27 @@
|
||||
import { useEffect } from 'react'
|
||||
import type { BotProps } from '@typebot.io/js'
|
||||
|
||||
type Props = BotProps
|
||||
|
||||
declare global {
|
||||
namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
'typebot-standard': React.DetailedHTMLProps<
|
||||
React.HTMLAttributes<HTMLElement>,
|
||||
HTMLElement
|
||||
>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const Standard = (props: Props) => {
|
||||
useEffect(() => {
|
||||
;(async () => {
|
||||
const { registerWebComponents } = await import('@typebot.io/js')
|
||||
registerWebComponents(props)
|
||||
})()
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [])
|
||||
|
||||
return <typebot-standard />
|
||||
}
|
6
packages/react/src/index.ts
Normal file
6
packages/react/src/index.ts
Normal file
@ -0,0 +1,6 @@
|
||||
/* eslint-disable import/no-anonymous-default-export */
|
||||
import { Standard } from './Standard'
|
||||
|
||||
export { Standard }
|
||||
|
||||
export default { Standard }
|
10
packages/react/tsconfig.json
Normal file
10
packages/react/tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "tsconfig/react-library.json",
|
||||
"include": ["src/**/*"],
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["src/*"]
|
||||
}
|
||||
}
|
||||
}
|
9
packages/react/tsup.config.js
Normal file
9
packages/react/tsup.config.js
Normal file
@ -0,0 +1,9 @@
|
||||
import { defineConfig } from 'tsup'
|
||||
|
||||
export default defineConfig((options) => ({
|
||||
entry: ['src/index.ts'],
|
||||
sourcemap: options.watch,
|
||||
minify: !options.watch,
|
||||
dts: true,
|
||||
format: ['esm'],
|
||||
}))
|
Reference in New Issue
Block a user