-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9519960
commit aac8835
Showing
263 changed files
with
11,344 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
*.js | ||
|
||
# build | ||
dist | ||
es | ||
lib |
This file contains 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,35 @@ | ||
module.exports = { | ||
root: true, | ||
parserOptions: { | ||
ecmaVersion: 2020, | ||
// project: './tsconfig.eslint.json', | ||
}, | ||
extends: [ | ||
'airbnb', | ||
'airbnb-typescript', | ||
'prettier', | ||
'prettier/react', | ||
'prettier/@typescript-eslint', | ||
], | ||
env: { | ||
browser: true, | ||
// jest: true, | ||
}, | ||
plugins: ['compat', 'react-hooks'], | ||
rules: { | ||
'compat/compat': 'error', | ||
'no-underscore-dangle': 'off', | ||
'react/jsx-filename-extension': 'off', | ||
'react/jsx-props-no-spreading': 'off', | ||
'react/no-array-index-key': 'off', | ||
'react/require-default-props': 'off', | ||
'react/prop-types': 'off', | ||
'react-hooks/rules-of-hooks': 'error', | ||
'jsx-a11y/click-events-have-key-events': 'off', | ||
'jsx-a11y/label-has-associated-control': 'off', | ||
'jsx-a11y/label-has-for': 'off', | ||
}, | ||
settings: { | ||
polyfills: ['IntersectionObserver', 'Promise'], | ||
}, | ||
}; |
This file contains 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,19 @@ | ||
# dependencies | ||
/node_modules | ||
/storybook/node_modules | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
/dist | ||
/lib | ||
/es | ||
|
||
# misc | ||
.DS_Store | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains 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,7 @@ | ||
{ | ||
"printWidth": 100, | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"proseWrap": "never", | ||
"endOfLine": "lf" | ||
} |
This file contains 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,73 @@ | ||
<p align="center"> | ||
<a href="https://chatui.io/"> | ||
<img width="109" height="28" src="https://gw.alicdn.com/tfs/TB1uYH4QoY1gK0jSZFMXXaWcVXa-218-56.svg" alt="ChatUI"> | ||
</a> | ||
</p> | ||
|
||
<p align="center">服务于智能对话领域的设计和开发体系,助力智能对话机器人的搭建</p> | ||
|
||
## 安装 | ||
|
||
```bash | ||
npm install chatui --save | ||
``` | ||
|
||
```bash | ||
yarn add chatui | ||
``` | ||
|
||
## 示例 | ||
|
||
```jsx | ||
import Chat, { Bubble, useMessages } from 'chatui'; | ||
import 'chatui/dist/index.css'; | ||
|
||
const App = () => { | ||
const { messages, appendMsg, setTyping } = useMessages([]); | ||
|
||
function handleSend(type, val) { | ||
if (type === 'text' && val.trim()) { | ||
appendMsg({ | ||
type: 'text', | ||
content: { text: val }, | ||
position: 'right', | ||
}); | ||
|
||
setTyping(true); | ||
|
||
setTimeout(() => { | ||
appendMsg({ | ||
type: 'text', | ||
content: { text: 'Bala bala' }, | ||
}); | ||
}, 1000); | ||
} | ||
} | ||
|
||
function renderMessageContent(msg) { | ||
const { content } = msg; | ||
return <Bubble content={content.text} />; | ||
} | ||
|
||
return ( | ||
<Chat | ||
navbar={{ title: '智能助理' }} | ||
messages={messages} | ||
renderMessageContent={renderMessageContent} | ||
onSend={handleSend} | ||
/> | ||
); | ||
}; | ||
``` | ||
|
||
### 定制主题 | ||
|
||
参考 [定制主题](https://chatui.io/docs/customize-theme) 文档。 | ||
|
||
## 国际化 | ||
|
||
参考 [国际化](https://chatui.io/docs/i18n) 文档。 | ||
|
||
## License | ||
|
||
MIT |
This file contains 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,50 @@ | ||
module.exports = (api) => { | ||
const env = api.env(); | ||
api.cache.using(() => env === 'development'); | ||
|
||
return { | ||
presets: ['@babel/preset-env', '@babel/preset-typescript', '@babel/preset-react'], | ||
plugins: [ | ||
'@babel/plugin-transform-runtime', | ||
|
||
// Stage 3 | ||
'@babel/plugin-proposal-class-properties', | ||
], | ||
env: { | ||
esm: { | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
modules: false, | ||
}, | ||
], | ||
], | ||
plugins: [ | ||
[ | ||
'@babel/plugin-transform-runtime', | ||
{ | ||
useESModules: true, | ||
}, | ||
], | ||
], | ||
}, | ||
umd: { | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: { | ||
android: '4.4', | ||
ios: '9', | ||
}, | ||
useBuiltIns: 'usage', | ||
corejs: 3, | ||
}, | ||
], | ||
], | ||
plugins: [['@babel/plugin-transform-runtime', { corejs: 3 }]], | ||
}, | ||
}, | ||
}; | ||
}; |
This file contains 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,3 @@ | ||
module.exports = { | ||
extends: ['@commitlint/config-conventional'], | ||
}; |
This file contains 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,43 @@ | ||
module.exports = () => { | ||
process.env.BROWSERSLIST_ENV = 'production'; | ||
|
||
return { | ||
mode: 'development', | ||
devtool: 'cheap-module-eval-source-map', | ||
entry: './demo/index.js', | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
use: 'babel-loader', | ||
}, | ||
{ | ||
test: /\.less$/, | ||
use: [ | ||
'style-loader', | ||
{ | ||
loader: 'css-loader', | ||
options: { | ||
importLoaders: 2, | ||
sourceMap: true, | ||
}, | ||
}, | ||
'postcss-loader', | ||
'less-loader', | ||
], | ||
}, | ||
], | ||
}, | ||
externals: { | ||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
'chat-ui': 'ChatUI', | ||
}, | ||
devServer: { | ||
contentBase: './demo', | ||
port: 9000, | ||
stats: 'minimal', | ||
}, | ||
}; | ||
}; |
This file contains 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,48 @@ | ||
const gulp = require('gulp'); | ||
const babel = require('gulp-babel'); | ||
const less = require('gulp-less'); | ||
const postcss = require('gulp-postcss'); | ||
|
||
process.env.NODE_ENV = 'production'; | ||
|
||
const paths = { | ||
js: ['./src/**/*.js'], | ||
dest: { | ||
lib: 'lib', | ||
esm: 'es', | ||
dist: 'dist', | ||
}, | ||
}; | ||
|
||
function fullStyle(cb) { | ||
gulp.src('./src/styles/index.less').pipe(less()).pipe(postcss()).pipe(gulp.dest(paths.dest.dist)); | ||
|
||
cb(); | ||
} | ||
|
||
function copyLess() { | ||
return gulp | ||
.src('src/**/**/*.less') | ||
.pipe(gulp.dest(paths.dest.lib)) | ||
.pipe(gulp.dest(paths.dest.esm)); | ||
} | ||
|
||
function compileScripts(babelEnv, destDir) { | ||
process.env.BABEL_ENV = babelEnv; | ||
|
||
return gulp | ||
.src(['src/**/*.{ts,tsx}', '!src/**/__tests__/*.{ts,tsx}']) | ||
.pipe(babel()) | ||
.pipe(gulp.dest(destDir)); | ||
} | ||
|
||
function compileCJS() { | ||
return compileScripts('cjs', paths.dest.lib); | ||
} | ||
|
||
function compileESM() { | ||
return compileScripts('esm', paths.dest.esm); | ||
} | ||
|
||
exports.default = gulp.series([compileESM, compileCJS, copyLess]); | ||
exports.umd = gulp.series([fullStyle]); |
This file contains 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 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'jsdom', | ||
testPathIgnorePatterns: ['/node_modules/', '/lib/', '/es/', '/dist/', 'examples'], | ||
setupFilesAfterEnv: ['./jest.setup.ts'], | ||
}; |
This file contains 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,2 @@ | ||
// https://github.com/testing-library/jest-dom | ||
import '@testing-library/jest-dom/extend-expect'; |
Oops, something went wrong.