Skip to content

Commit d708d84

Browse files
afc163zombieJ
authored andcommitted
Upgrade rc-trigger to 4.0 (#170)
* 🆙 upgrade rc-trigger and remove polyfill * 🔧 use father over rc-tools * ✅ fix test cases * 🚮 remove prop-types and findDOMNode * ✅ improve eslint rules
1 parent e77b310 commit d708d84

32 files changed

+206
-322
lines changed

.circleci/config.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: 2
2+
jobs:
3+
lint:
4+
docker:
5+
- image: circleci/node:latest
6+
steps:
7+
- checkout
8+
- restore_cache:
9+
keys:
10+
- v1-dependencies-{{ checksum "package.json" }}
11+
- run: npm install
12+
- save_cache:
13+
paths:
14+
- node_modules
15+
key: v1-dependencies-{{ checksum "package.json" }}
16+
- run: npm run lint
17+
test:
18+
docker:
19+
- image: circleci/node:latest
20+
working_directory: ~/repo
21+
steps:
22+
- checkout
23+
- restore_cache:
24+
keys:
25+
- v1-dependencies-{{ checksum "package.json" }}
26+
- run: npm install
27+
- save_cache:
28+
paths:
29+
- node_modules
30+
key: v1-dependencies-{{ checksum "package.json" }}
31+
- run: npm test -- --coverage
32+
workflows:
33+
version: 2
34+
build_and_test:
35+
jobs:
36+
- lint
37+
- test

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports= require('@umijs/fabric/dist/eslint');

.fatherrc.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
cjs: 'babel',
3+
esm: { type: 'babel', importLibToEs: true },
4+
preCommit: {
5+
eslint: true,
6+
prettier: true,
7+
},
8+
};

.gitignore

+11-3
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,19 @@ Thumbs.db
2121
node_modules
2222
.cache
2323
dist
24-
*.css
24+
assets/**/*.css
2525
build
2626
lib
27-
es
2827
coverage
29-
npm-debug.log.*
28+
.vscode
3029
yarn.lock
30+
es/
3131
package-lock.json
32+
src/*.js
33+
src/*.map
34+
.prettierrc
35+
tslint.json
36+
tsconfig.test.json
37+
.prettierignore
38+
.storybook
39+
storybook/index.js

README.md

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
# TimePicker
22

3-
React TimePicker
3+
React Time Picker Control.
44

55
[![NPM version][npm-image]][npm-url]
6-
[![build status][travis-image]][travis-url]
7-
[![Test coverage][codecov-image]][codecov-url]
6+
[![build status][circleci-image]][circleci-url]
7+
[![Test coverage][coveralls-image]][coveralls-url]
88
[![Dependencies](https://img.shields.io/david/react-component/time-picker.svg?style=flat-square)](https://david-dm.org/react-component/time-picker)
99
[![DevDependencies](https://img.shields.io/david/dev/react-component/time-picker.svg?style=flat-square)](https://david-dm.org/react-component/time-picker?type=dev)
1010
[![npm download][download-image]][download-url]
11+
[![Storybook](https://gw.alipayobjects.com/mdn/ob_info/afts/img/A*CQXNTZfK1vwAAAAAAAAAAABjAQAAAQ/original)](https://github.com/react-component/time-picker)
1112

13+
[Storybook]: https://github.com/storybooks/press/blob/master/badges/storybook.svg
1214
[npm-image]: http://img.shields.io/npm/v/rc-time-picker.svg?style=flat-square
1315
[npm-url]: http://npmjs.org/package/rc-time-picker
14-
[travis-image]: https://img.shields.io/travis/react-component/time-picker.svg?style=flat-square
15-
[travis-url]: https://travis-ci.org/react-component/time-picker
16-
[codecov-image]: https://codecov.io/gh/react-component/time-picker/branch/master/graph/badge.svg
17-
[codecov-url]: https://codecov.io/gh/react-component/time-picker
16+
[circleci-image]: https://img.shields.io/circleci/react-component/time-picker.svg?style=flat-square
17+
[circleci-url]: https://circleci.com/gh/react-component/time-picker
18+
[coveralls-image]: https://img.shields.io/coveralls/react-component/time-picker.svg?style=flat-square
19+
[coveralls-url]: https://coveralls.io/r/react-component/time-picker?branch=maste
20+
[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square
21+
[node-url]: http://nodejs.org/download/
1822
[download-image]: https://img.shields.io/npm/dm/rc-time-picker.svg?style=flat-square
1923
[download-url]: https://npmjs.org/package/rc-time-picker
2024

@@ -70,8 +74,8 @@ API
7074
| disabledSeconds | Function | - | disabled second options |
7175
| use12Hours | Boolean | false | 12 hours display mode |
7276
| hideDisabledOptions | Boolean | false | whether hide disabled options |
73-
| onChange | Function | null | called when select a different value |
74-
| onAmPmChange | Function | null | called when select an am/pm value |
77+
| onChange | Function | null | called when time-picker a different value |
78+
| onAmPmChange | Function | null | called when time-picker an am/pm value |
7579
| addon | Function | - | called from timepicker panel to render some addon to its bottom, like an OK button. Receives panel instance as parameter, to be able to close it like `panel.close()`.|
7680
| placement | String | bottomLeft | one of ['topLeft', 'topRight', 'bottomLeft', 'bottomRight'] |
7781
| transitionName | String | '' | |
@@ -83,14 +87,13 @@ API
8387
| secondStep | Number | 1 | interval between seconds in picker |
8488
| focusOnOpen | Boolean | false | automatically focus the input when the picker opens |
8589
| inputReadOnly | Boolean | false | set input to read only |
86-
| inputIcon | ReactNode | | specific the select icon. |
90+
| inputIcon | ReactNode | | specific the time-picker icon. |
8791
| clearIcon | ReactNode | | specific the clear icon. |
8892

8993
## Test Case
9094

9195
```
9296
npm test
93-
npm run chrome-test
9497
```
9598

9699
## Coverage

examples/12hours.html

Whitespace-only changes.

examples/disabled.html

-1
This file was deleted.

examples/disabled.js

+14-18
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
/* eslint no-console:0 */
22

3-
import 'rc-time-picker/assets/index.less';
4-
3+
import '../assets/index.less';
54
import React from 'react';
6-
import ReactDom from 'react-dom';
7-
85
import moment from 'moment';
9-
10-
import TimePicker from 'rc-time-picker';
6+
import TimePicker from '..';
117

128
const showSecond = true;
139
const str = showSecond ? 'HH:mm:ss' : 'HH:mm';
1410

15-
const now = moment().hour(14).minute(30);
11+
const now = moment()
12+
.hour(14)
13+
.minute(30);
1614

1715
function generateOptions(length, excludedOptions) {
1816
const arr = [];
19-
for (let value = 0; value < length; value++) {
17+
for (let value = 0; value < length; value += 1) {
2018
if (excludedOptions.indexOf(value) < 0) {
2119
arr.push(value);
2220
}
@@ -44,17 +42,13 @@ function disabledMinutes(h) {
4442
}
4543

4644
function disabledSeconds(h, m) {
47-
return [h + m % 60];
45+
return [h + (m % 60)];
4846
}
4947

50-
ReactDom.render(
51-
<div>
48+
const App = () => (
49+
<>
5250
<h3>Disabled picker</h3>
53-
<TimePicker
54-
defaultValue={now}
55-
disabled
56-
onChange={onChange}
57-
/>
51+
<TimePicker defaultValue={now} disabled onChange={onChange} />
5852
<h3>Disabled options</h3>
5953
<TimePicker
6054
showSecond={showSecond}
@@ -65,5 +59,7 @@ ReactDom.render(
6559
disabledMinutes={disabledMinutes}
6660
disabledSeconds={disabledSeconds}
6761
/>
68-
</div>
69-
, document.getElementById('__react-content'));
62+
</>
63+
);
64+
65+
export default App;

examples/format.html

Whitespace-only changes.

examples/format.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
import 'rc-time-picker/assets/index.less';
1+
import '../assets/index.less';
22
import React from 'react';
3-
import ReactDom from 'react-dom';
43
import moment from 'moment';
5-
import TimePicker from 'rc-time-picker';
4+
import TimePicker from '..';
65

7-
ReactDom.render(
8-
<div>
6+
const App = () => (
7+
<>
98
<TimePicker defaultValue={moment()} showHour={false} />
109
<TimePicker defaultValue={moment()} showMinute={false} />
1110
<TimePicker defaultValue={moment()} showSecond={false} />
1211

1312
<TimePicker defaultValue={moment()} showMinute={false} showSecond={false} />
14-
<TimePicker defaultValue={moment()} showHour={false} showSecond={false}/>
13+
<TimePicker defaultValue={moment()} showHour={false} showSecond={false} />
1514
<TimePicker defaultValue={moment()} showHour={false} showMinute={false} />
16-
</div>
17-
, document.getElementById('__react-content'));
15+
</>
16+
);
17+
18+
export default App;

examples/hidden.html

-1
This file was deleted.

examples/hidden.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
/* eslint no-console:0 */
2-
3-
import 'rc-time-picker/assets/index.less';
4-
2+
import '../assets/index.less';
53
import React from 'react';
6-
import ReactDom from 'react-dom';
7-
84
import moment from 'moment';
9-
10-
import TimePicker from 'rc-time-picker';
5+
import TimePicker from '..';
116

127
const showSecond = true;
138
const str = showSecond ? 'HH:mm:ss' : 'HH:mm';
@@ -16,7 +11,7 @@ function onChange(value) {
1611
console.log(value && value.format(str));
1712
}
1813

19-
ReactDom.render(
14+
const App = () => (
2015
<TimePicker
2116
format={str}
2217
showSecond={showSecond}
@@ -27,6 +22,7 @@ ReactDom.render(
2722
disabledHours={() => [0, 1, 2, 3, 4, 5, 6, 7, 8, 22, 23]}
2823
disabledMinutes={() => [0, 2, 4, 6, 8]}
2924
hideDisabledOptions
30-
/>,
31-
document.getElementById('__react-content')
25+
/>
3226
);
27+
28+
export default App;

examples/open.html

Whitespace-only changes.

examples/open.js

+26-30
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/* eslint no-console:0 */
2-
3-
import 'rc-time-picker/assets/index.less';
2+
import '../assets/index.less';
43
import React from 'react';
5-
import ReactDom from 'react-dom';
6-
import TimePicker from 'rc-time-picker';
74
import moment from 'moment';
5+
import TimePicker from '..';
86

97
const iconStyle = {
108
position: 'absolute',
@@ -51,32 +49,30 @@ class App extends React.Component {
5149
useIcon: false,
5250
};
5351

54-
getIcon = (path, style = {}) => {
55-
return (
56-
<i
57-
style={{
58-
fontSize: '12px',
59-
fontStyle: 'normal',
60-
color: '#aaa',
61-
display: 'inline-block',
62-
lineHeight: '1',
63-
width: '20px',
64-
transition: 'color 0.3s ease',
65-
...style,
66-
}}
52+
getIcon = (path, style = {}) => (
53+
<i
54+
style={{
55+
fontSize: '12px',
56+
fontStyle: 'normal',
57+
color: '#aaa',
58+
display: 'inline-block',
59+
lineHeight: '1',
60+
width: '20px',
61+
transition: 'color 0.3s ease',
62+
...style,
63+
}}
64+
>
65+
<svg
66+
viewBox="0 0 1024 1024"
67+
width="1em"
68+
height="1em"
69+
fill="currentColor"
70+
style={{ verticalAlign: '-.125em' }}
6771
>
68-
<svg
69-
viewBox="0 0 1024 1024"
70-
width="1em"
71-
height="1em"
72-
fill="currentColor"
73-
style={{ verticalAlign: '-.125em' }}
74-
>
75-
<path d={path} p-id="5827" />
76-
</svg>
77-
</i>
78-
);
79-
};
72+
<path d={path} p-id="5827" />
73+
</svg>
74+
</i>
75+
);
8076

8177
setOpen = ({ open }) => {
8278
this.setState({ open });
@@ -125,4 +121,4 @@ class App extends React.Component {
125121
}
126122
}
127123

128-
ReactDom.render(<App />, document.getElementById('__react-content'));
124+
export default App;

examples/pick-time.html

-1
This file was deleted.

examples/pick-time.js

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
11
/* eslint no-console:0 */
2-
3-
import 'rc-time-picker/assets/index.less';
4-
2+
import '../assets/index.less';
53
import React from 'react';
6-
import ReactDom from 'react-dom';
7-
84
import moment from 'moment';
9-
10-
import TimePicker from 'rc-time-picker';
5+
import TimePicker from '..';
116

127
const showSecond = true;
138
const str = showSecond ? 'HH:mm:ss' : 'HH:mm';
149

15-
1610
function onChange(value) {
1711
console.log(value && value.format(str));
1812
}
1913

20-
ReactDom.render(
14+
const App = () => (
2115
<TimePicker
2216
style={{ width: 100 }}
2317
showSecond={showSecond}
2418
defaultValue={moment()}
2519
className="xxx"
2620
onChange={onChange}
27-
/>,
28-
document.getElementById('__react-content')
21+
/>
2922
);
23+
24+
export default App;

examples/step.html

Whitespace-only changes.

examples/step.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import 'rc-time-picker/assets/index.less';
2-
1+
import '../assets/index.less';
32
import React from 'react';
4-
import ReactDom from 'react-dom';
53
import moment from 'moment';
6-
import TimePicker from 'rc-time-picker';
4+
import TimePicker from '..';
5+
6+
const App = () => <TimePicker defaultValue={moment()} showSecond={false} minuteStep={15} />;
77

8-
ReactDom.render(
9-
<TimePicker defaultValue={moment()} showSecond={false} minuteStep={15} />
10-
, document.getElementById('__react-content'));
8+
export default App;

0 commit comments

Comments
 (0)