Skip to content

Commit f240eea

Browse files
authored
chore: migrate (#174)
* chore: migrate * chore: migrate dumi2 * chore: update readme * chore: code clean * chore: add gh-pages * chore: jest config
1 parent 4355ad1 commit f240eea

29 files changed

+404
-408
lines changed

.dumirc.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// more config: https://d.umijs.org/config
2+
import { defineConfig } from 'dumi';
3+
4+
const name = 'mentions';
5+
6+
export default defineConfig({
7+
favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'],
8+
themeConfig: {
9+
name: 'rc-mentions',
10+
logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
11+
},
12+
outputPath: '.doc',
13+
exportStatic: {},
14+
base: `/${name}/`,
15+
publicPath: `/${name}/`,
16+
styles: [
17+
`
18+
.markdown table {
19+
width: auto !important;
20+
}
21+
`,
22+
],
23+
mfsu: {},
24+
});

.eslintrc.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
const base = require('@umijs/fabric/dist/eslint');
2-
31
module.exports = {
4-
...base,
2+
extends: [require.resolve('@umijs/fabric/dist/eslint')],
53
rules: {
6-
...base.rules,
74
'jsx-a11y/no-autofocus': 0,
85
},
6+
overrides: [
7+
{
8+
files: ['docs/**/*.tsx'],
9+
rules: {
10+
'no-console': 0,
11+
},
12+
},
13+
],
914
};

.fatherrc.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
export default {
2-
cjs: 'babel',
3-
esm: { type: 'babel', importLibToEs: true },
4-
preCommit: {
5-
eslint: true,
6-
prettier: true,
7-
},
8-
runtimeHelpers: true,
9-
};
1+
import { defineConfig } from 'father';
2+
3+
export default defineConfig({
4+
plugins: ['@rc-component/father-plugin'],
5+
});

.github/workflows/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ jobs:
3232
mkdir package-temp-dir
3333
fi
3434
cp package-lock.json package-temp-dir
35-
3635
- name: cache node_modules
3736
id: node_modules_cache_id
3837
uses: actions/cache@v2
@@ -111,4 +110,4 @@ jobs:
111110
- name: coverage
112111
run: npm test -- --coverage && bash <(curl -s https://codecov.io/bash)
113112

114-
needs: setup
113+
needs: setup

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ es/
3333
package-lock.json
3434
src/*.js
3535
src/*.map
36-
jest.config.js
3736
tslint.json
3837
tsconfig.test.json
3938
.prettierignore
40-
.doc/
39+
.doc/
40+
41+
# dumi
42+
.dumi/tmp
43+
.dumi/tmp-test
44+
.dumi/tmp-production

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
lint-staged

.travis.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

README.md

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
# rc-mentions
2-
---
3-
4-
React Mentions
52

63
[![NPM version][npm-image]][npm-url]
7-
[![build status][travis-image]][travis-url]
84
[![Test coverage][codecov-image]][codecov-url]
95
[![Dependencies](https://img.shields.io/david/react-component/mentions.svg?style=flat-square)](https://david-dm.org/react-component/mentions)
106
[![DevDependencies](https://img.shields.io/david/dev/react-component/mentions.svg?style=flat-square)](https://david-dm.org/react-component/mentions?type=dev)
117
[![npm download][download-image]][download-url]
12-
[![Storybook](https://gw.alipayobjects.com/mdn/ob_info/afts/img/A*CQXNTZfK1vwAAAAAAAAAAABjAQAAAQ/original)](https://github.com/react-component/mentions)
138

14-
[Storybook]: https://github.com/storybooks/press/blob/master/badges/storybook.svg
159
[npm-image]: http://img.shields.io/npm/v/rc-mentions.svg?style=flat-square
1610
[npm-url]: http://npmjs.org/package/rc-mentions
17-
[travis-image]: https://img.shields.io/travis/react-component/mentions.svg?style=flat-square
18-
[travis-url]: https://travis-ci.org/react-component/mentions
1911
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/mentions.svg?style=flat-square
2012
[codecov-url]: https://codecov.io/gh/react-component/mentions/branch/master
2113
[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square
@@ -29,12 +21,12 @@ React Mentions
2921

3022
## Feature
3123

32-
* support ie9,ie9+,chrome,firefox,safari
24+
- support ie9,ie9+,chrome,firefox,safari
3325

3426
### Keyboard
3527

36-
* Open mentions (focus input || focus and click)
37-
* KeyDown/KeyUp/Enter to navigate menu
28+
- Open mentions (focus input || focus and click)
29+
- KeyDown/KeyUp/Enter to navigate menu
3830

3931
## install
4032

@@ -45,6 +37,9 @@ React Mentions
4537
### basic use
4638

4739
```js
40+
/**
41+
* inline: true
42+
*/
4843
import Mentions from 'rc-mentions';
4944

5045
const { Option } = Mentions;
@@ -63,37 +58,37 @@ React.render(<Demo />, container);
6358

6459
### Mentions props
6560

66-
| name | description | type | default |
67-
|----------|----------------|----------|--------------|
68-
| autoFocus | Auto get focus when component mounted | boolean | `false` |
69-
| defaultValue | Default value | string | - |
70-
| filterOption | Customize filter option logic | false \| (input: string, option: OptionProps) => boolean | - |
71-
| notFoundContent | Set mentions content when not match | ReactNode | 'Not Found' |
72-
| placement | Set popup placement | 'top' \| 'bottom' | 'bottom' |
73-
| direction | Set popup direction | 'ltr' \| 'rtl' | 'ltr' |
74-
| prefix | Set trigger prefix keyword | string \| string[] | '@' |
75-
| rows | Set row count | number | 1 |
76-
| split | Set split string before and after selected mention | string | ' ' |
77-
| validateSearch | Customize trigger search logic | (text: string, props: MentionsProps) => void | - |
78-
| value | Set value of mentions | string | - |
79-
| onChange | Trigger when value changed |(text: string) => void | - |
80-
| onKeyDown | Trigger when user hits a key | React.KeyboardEventHandler<HTMLTextAreaElement> | - |
81-
| onKeyUp | Trigger when user releases a key | React.KeyboardEventHandler<HTMLTextAreaElement> | - |
82-
| onSelect | Trigger when user select the option | (option: OptionProps, prefix: string) => void | - |
83-
| onSearch | Trigger when prefix hit | (text: string, prefix: string) => void | - |
84-
| onFocus | Trigger when mentions get focus | React.FocusEventHandler<HTMLTextAreaElement> | - |
85-
| onBlur | Trigger when mentions lose focus | React.FocusEventHandler<HTMLTextAreaElement> | - |
86-
| getPopupContainer | DOM Container for suggestions | () => HTMLElement | - |
87-
| autoSize | Textarea height autosize feature, can be set to `true\|false` or an object `{ minRows: 2, maxRows: 6 }` | boolean \| object | - |
88-
| onPressEnter | The callback function that is triggered when Enter key is pressed | function(e) | - |
89-
| onResize | The callback function that is triggered when textarea resize | function({ width, height }) | - |
61+
| name | description | type | default |
62+
| ----------------- | ------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | ----------- |
63+
| autoFocus | Auto get focus when component mounted | `boolean` | `false` |
64+
| defaultValue | Default value | `string` | - |
65+
| filterOption | Customize filter option logic | `false \| (input: string, option: OptionProps) => boolean` | - |
66+
| notFoundContent | Set mentions content when not match | `ReactNode` | 'Not Found' |
67+
| placement | Set popup placement | `'top' \| 'bottom'` | 'bottom' |
68+
| direction | Set popup direction | `'ltr' \| 'rtl'` | 'ltr' |
69+
| prefix | Set trigger prefix keyword | `string \| string[]` | '@' |
70+
| rows | Set row count | `number` | 1 |
71+
| split | Set split string before and after selected mention | `string` | ' ' |
72+
| validateSearch | Customize trigger search logic | `(text: string, props: MentionsProps) => void` | - |
73+
| value | Set value of mentions | `string` | - |
74+
| onChange | Trigger when value changed | `(text: string) => void` | - |
75+
| onKeyDown | Trigger when user hits a key | `React.KeyboardEventHandler<HTMLTextAreaElement>` | - |
76+
| onKeyUp | Trigger when user releases a key | `React.KeyboardEventHandler<HTMLTextAreaElement>` | - |
77+
| onSelect | Trigger when user select the option | `(option: OptionProps, prefix: string) => void` | - |
78+
| onSearch | Trigger when prefix hit | `(text: string, prefix: string) => void` | - |
79+
| onFocus | Trigger when mentions get focus | `React.FocusEventHandler<HTMLTextAreaElement>` | - |
80+
| onBlur | Trigger when mentions lose focus | `React.FocusEventHandler<HTMLTextAreaElement>` | - |
81+
| getPopupContainer | DOM Container for suggestions | `() => HTMLElement` | - |
82+
| autoSize | Textarea height autosize feature, can be set to `true\|false` or an object `{ minRows: 2, maxRows: 6 }` | `boolean \| object` | - |
83+
| onPressEnter | The callback function that is triggered when Enter key is pressed | `function(e)` | - |
84+
| onResize | The callback function that is triggered when textarea resize | `function({ width, height })` | - |
9085

9186
### Methods
9287

93-
| name | description |
94-
|----------|----------------|
95-
| focus() | Component get focus |
96-
| blur() | Component lose focus |
88+
| name | description |
89+
| ------- | -------------------- |
90+
| focus() | Component get focus |
91+
| blur() | Component lose focus |
9792

9893
## Development
9994

@@ -120,7 +115,6 @@ npm test
120115
npm run coverage
121116
```
122117

123-
124118
## License
125119

126120
rc-mentions is released under the MIT license.

docs/demo.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Usage
3+
order: 0
4+
nav:
5+
title: Demo
6+
---
7+
8+
# Mentions Demos
9+
10+
## Basic
11+
12+
<code src="./examples/basic.tsx"></code>
13+
14+
## Dynamic
15+
16+
<code src="./examples/dynamic.tsx"></code>
17+
18+
## Filter
19+
20+
Option has `key` and filter only hit by `key`
21+
22+
<code src="./examples/filter.tsx"></code>
23+
24+
## Multiple Prefix
25+
26+
<code src="./examples/multiple-prefix.tsx"></code>
27+
28+
## Split
29+
30+
<code src="./examples/split.tsx"></code>
31+
32+
## Textarea
33+
34+
<code src="./examples/textarea.tsx"></code>
35+
36+
## Debug
37+
38+
<code src="./examples/debug.tsx"></code>

docs/examples/basic.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React from 'react';
2+
import Mentions from 'rc-mentions';
3+
import '../../assets/index.less';
4+
5+
const onSelect = (option, prefix) => {
6+
console.log('Select:', prefix, '-', option.value);
7+
};
8+
9+
const onFocus = () => {
10+
console.log('onFocus');
11+
};
12+
13+
const onBlur = () => {
14+
console.log('onBlur');
15+
};
16+
17+
export default () => (
18+
<Mentions
19+
autoFocus
20+
rows={3}
21+
defaultValue="Hello World"
22+
onSelect={onSelect}
23+
onFocus={onFocus}
24+
onBlur={onBlur}
25+
options={[
26+
{
27+
value: 'light',
28+
label: 'Light',
29+
},
30+
{
31+
value: 'bamboo',
32+
label: 'Bamboo',
33+
},
34+
{
35+
value: 'cat',
36+
label: 'Cat',
37+
},
38+
]}
39+
/>
40+
);

0 commit comments

Comments
 (0)