@jetbrains/ring-ui 5.0.144 → 5.0.145
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/date-picker/date-popup.js +1 -1
- package/components/date-picker/years.d.ts +4 -0
- package/components/date-picker/years.js +26 -14
- package/dist/date-picker/date-popup.js +1 -3
- package/dist/date-picker/years.d.ts +4 -0
- package/dist/date-picker/years.js +29 -14
- package/package.json +4 -4
|
@@ -67,7 +67,7 @@ export default class DatePopup extends Component {
|
|
|
67
67
|
}
|
|
68
68
|
componentDidMount() {
|
|
69
69
|
if (this.componentRef.current) {
|
|
70
|
-
this.componentRef.current.addEventListener('wheel', this.handleWheel
|
|
70
|
+
this.componentRef.current.addEventListener('wheel', this.handleWheel);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
componentDidUpdate(prevProps, prevState) {
|
|
@@ -13,9 +13,13 @@ export default class Years extends PureComponent<CalendarProps> {
|
|
|
13
13
|
state: {
|
|
14
14
|
scrollDate: null;
|
|
15
15
|
};
|
|
16
|
+
componentDidMount(): void;
|
|
16
17
|
componentDidUpdate(prevProps: CalendarProps, prevState: YearsState): void;
|
|
18
|
+
componentWillUnmount(): void;
|
|
17
19
|
stoppedScrolling?: boolean;
|
|
18
20
|
setYear(date: number): void;
|
|
21
|
+
componentRef: React.RefObject<HTMLDivElement>;
|
|
22
|
+
handleWheel: (e: WheelEvent) => void;
|
|
19
23
|
render(): React.JSX.Element;
|
|
20
24
|
}
|
|
21
25
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { PureComponent } from 'react';
|
|
1
|
+
import React, { createRef, PureComponent } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import addYears from 'date-fns/addYears';
|
|
@@ -23,9 +23,19 @@ export default class Years extends PureComponent {
|
|
|
23
23
|
onScrollChange: PropTypes.func
|
|
24
24
|
};
|
|
25
25
|
state = { scrollDate: null };
|
|
26
|
+
componentDidMount() {
|
|
27
|
+
if (this.componentRef.current) {
|
|
28
|
+
this.componentRef.current.addEventListener('wheel', this.handleWheel);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
26
31
|
componentDidUpdate(prevProps, prevState) {
|
|
27
32
|
this.stoppedScrolling = prevState.scrollDate != null && !this.state.scrollDate;
|
|
28
33
|
}
|
|
34
|
+
componentWillUnmount() {
|
|
35
|
+
if (this.componentRef.current) {
|
|
36
|
+
this.componentRef.current.removeEventListener('wheel', this.handleWheel);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
29
39
|
stoppedScrolling;
|
|
30
40
|
setYear(date) {
|
|
31
41
|
if (scrollTO) {
|
|
@@ -35,6 +45,20 @@ export default class Years extends PureComponent {
|
|
|
35
45
|
this.setState({ scrollDate: null });
|
|
36
46
|
this.props.onScroll(Number(setYear(this.props.scrollDate, getYear(date))));
|
|
37
47
|
}
|
|
48
|
+
componentRef = createRef();
|
|
49
|
+
handleWheel = (e) => {
|
|
50
|
+
const { scrollDate } = this.props;
|
|
51
|
+
const date = this.state.scrollDate || scrollDate;
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
const newScrollDate = linearFunction(0, Number(date), yearDuration / yearHeight).y(e.deltaY);
|
|
54
|
+
this.setState({
|
|
55
|
+
scrollDate: newScrollDate
|
|
56
|
+
});
|
|
57
|
+
if (scrollTO) {
|
|
58
|
+
window.clearTimeout(scrollTO);
|
|
59
|
+
}
|
|
60
|
+
scrollTO = window.setTimeout(() => this.setYear(newScrollDate), scrollDelay);
|
|
61
|
+
};
|
|
38
62
|
render() {
|
|
39
63
|
const { onScrollChange, scrollDate } = this.props;
|
|
40
64
|
const date = this.state.scrollDate || scrollDate;
|
|
@@ -46,19 +70,7 @@ export default class Years extends PureComponent {
|
|
|
46
70
|
years.push(year);
|
|
47
71
|
}
|
|
48
72
|
const pxToDate = linearFunction(0, Number(years[0]), yearDuration / yearHeight);
|
|
49
|
-
|
|
50
|
-
e.preventDefault();
|
|
51
|
-
const newScrollDate = linearFunction(0, Number(date), yearDuration / yearHeight).
|
|
52
|
-
y(e.deltaY);
|
|
53
|
-
this.setState({
|
|
54
|
-
scrollDate: newScrollDate
|
|
55
|
-
});
|
|
56
|
-
if (scrollTO) {
|
|
57
|
-
window.clearTimeout(scrollTO);
|
|
58
|
-
}
|
|
59
|
-
scrollTO = window.setTimeout(() => this.setYear(newScrollDate), scrollDelay);
|
|
60
|
-
};
|
|
61
|
-
return (<div className={styles.years} onWheel={handleWheel} style={{
|
|
73
|
+
return (<div className={styles.years} ref={this.componentRef} style={{
|
|
62
74
|
transition: this.stoppedScrolling ? 'top .2s ease-out 0s' : 'none',
|
|
63
75
|
top: Math.floor(calHeight * HALF - pxToDate.x(Number(date)))
|
|
64
76
|
}}>
|
|
@@ -127,9 +127,7 @@ class DatePopup extends Component {
|
|
|
127
127
|
}
|
|
128
128
|
componentDidMount() {
|
|
129
129
|
if (this.componentRef.current) {
|
|
130
|
-
this.componentRef.current.addEventListener('wheel', this.handleWheel
|
|
131
|
-
passive: true
|
|
132
|
-
});
|
|
130
|
+
this.componentRef.current.addEventListener('wheel', this.handleWheel);
|
|
133
131
|
}
|
|
134
132
|
}
|
|
135
133
|
componentDidUpdate(prevProps, prevState) {
|
|
@@ -13,9 +13,13 @@ export default class Years extends PureComponent<CalendarProps> {
|
|
|
13
13
|
state: {
|
|
14
14
|
scrollDate: null;
|
|
15
15
|
};
|
|
16
|
+
componentDidMount(): void;
|
|
16
17
|
componentDidUpdate(prevProps: CalendarProps, prevState: YearsState): void;
|
|
18
|
+
componentWillUnmount(): void;
|
|
17
19
|
stoppedScrolling?: boolean;
|
|
18
20
|
setYear(date: number): void;
|
|
21
|
+
componentRef: React.RefObject<HTMLDivElement>;
|
|
22
|
+
handleWheel: (e: WheelEvent) => void;
|
|
19
23
|
render(): React.JSX.Element;
|
|
20
24
|
}
|
|
21
25
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { PureComponent } from 'react';
|
|
1
|
+
import React, { PureComponent, createRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import addYears from 'date-fns/addYears';
|
|
@@ -11,7 +11,7 @@ import startOfYear from 'date-fns/startOfYear';
|
|
|
11
11
|
import subYears from 'date-fns/subYears';
|
|
12
12
|
import linearFunction from '../global/linear-function.js';
|
|
13
13
|
import { m as modules_0c7b7d96 } from '../_helpers/date-picker.js';
|
|
14
|
-
import units, { dateType, DOUBLE, HALF
|
|
14
|
+
import units, { dateType, yearDuration, DOUBLE, HALF } from './consts.js';
|
|
15
15
|
import 'date-fns/add';
|
|
16
16
|
|
|
17
17
|
const {
|
|
@@ -30,9 +30,19 @@ class Years extends PureComponent {
|
|
|
30
30
|
state = {
|
|
31
31
|
scrollDate: null
|
|
32
32
|
};
|
|
33
|
+
componentDidMount() {
|
|
34
|
+
if (this.componentRef.current) {
|
|
35
|
+
this.componentRef.current.addEventListener('wheel', this.handleWheel);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
33
38
|
componentDidUpdate(prevProps, prevState) {
|
|
34
39
|
this.stoppedScrolling = prevState.scrollDate != null && !this.state.scrollDate;
|
|
35
40
|
}
|
|
41
|
+
componentWillUnmount() {
|
|
42
|
+
if (this.componentRef.current) {
|
|
43
|
+
this.componentRef.current.removeEventListener('wheel', this.handleWheel);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
36
46
|
stoppedScrolling;
|
|
37
47
|
setYear(date) {
|
|
38
48
|
if (scrollTO) {
|
|
@@ -44,6 +54,22 @@ class Years extends PureComponent {
|
|
|
44
54
|
});
|
|
45
55
|
this.props.onScroll(Number(setYear(this.props.scrollDate, getYear(date))));
|
|
46
56
|
}
|
|
57
|
+
componentRef = /*#__PURE__*/createRef();
|
|
58
|
+
handleWheel = e => {
|
|
59
|
+
const {
|
|
60
|
+
scrollDate
|
|
61
|
+
} = this.props;
|
|
62
|
+
const date = this.state.scrollDate || scrollDate;
|
|
63
|
+
e.preventDefault();
|
|
64
|
+
const newScrollDate = linearFunction(0, Number(date), yearDuration / yearHeight).y(e.deltaY);
|
|
65
|
+
this.setState({
|
|
66
|
+
scrollDate: newScrollDate
|
|
67
|
+
});
|
|
68
|
+
if (scrollTO) {
|
|
69
|
+
window.clearTimeout(scrollTO);
|
|
70
|
+
}
|
|
71
|
+
scrollTO = window.setTimeout(() => this.setYear(newScrollDate), scrollDelay);
|
|
72
|
+
};
|
|
47
73
|
render() {
|
|
48
74
|
const {
|
|
49
75
|
onScrollChange,
|
|
@@ -58,20 +84,9 @@ class Years extends PureComponent {
|
|
|
58
84
|
years.push(year);
|
|
59
85
|
}
|
|
60
86
|
const pxToDate = linearFunction(0, Number(years[0]), yearDuration / yearHeight);
|
|
61
|
-
const handleWheel = e => {
|
|
62
|
-
e.preventDefault();
|
|
63
|
-
const newScrollDate = linearFunction(0, Number(date), yearDuration / yearHeight).y(e.deltaY);
|
|
64
|
-
this.setState({
|
|
65
|
-
scrollDate: newScrollDate
|
|
66
|
-
});
|
|
67
|
-
if (scrollTO) {
|
|
68
|
-
window.clearTimeout(scrollTO);
|
|
69
|
-
}
|
|
70
|
-
scrollTO = window.setTimeout(() => this.setYear(newScrollDate), scrollDelay);
|
|
71
|
-
};
|
|
72
87
|
return /*#__PURE__*/React.createElement("div", {
|
|
73
88
|
className: modules_0c7b7d96.years,
|
|
74
|
-
|
|
89
|
+
ref: this.componentRef,
|
|
75
90
|
style: {
|
|
76
91
|
transition: this.stoppedScrolling ? 'top .2s ease-out 0s' : 'none',
|
|
77
92
|
top: Math.floor(calHeight * HALF - pxToDate.x(Number(date)))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jetbrains/ring-ui",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.145",
|
|
4
4
|
"description": "JetBrains UI library",
|
|
5
5
|
"author": "JetBrains",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"core-js": "^3.30.2",
|
|
127
127
|
"cpy-cli": "^3.1.1",
|
|
128
128
|
"enzyme": "^3.11.0",
|
|
129
|
-
"eslint": "^8.
|
|
129
|
+
"eslint": "^8.42.0",
|
|
130
130
|
"eslint-import-resolver-webpack": "^0.13.2",
|
|
131
131
|
"eslint-plugin-angular": "^4.1.0",
|
|
132
132
|
"eslint-plugin-bdd": "^2.1.1",
|
|
@@ -176,8 +176,8 @@
|
|
|
176
176
|
"terser-webpack-plugin": "^5.3.9",
|
|
177
177
|
"typescript": "~5.1.3",
|
|
178
178
|
"wallaby-webpack": "^3.9.16",
|
|
179
|
-
"webpack": "^5.85.
|
|
180
|
-
"webpack-cli": "^5.1.
|
|
179
|
+
"webpack": "^5.85.1",
|
|
180
|
+
"webpack-cli": "^5.1.3",
|
|
181
181
|
"xmlappend": "^1.0.4"
|
|
182
182
|
},
|
|
183
183
|
"peerDependencies": {
|