@steroidsjs/core 3.0.0-beta.81 → 3.0.0-beta.82
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/docs-autogen-result.json +398 -43
- package/en.json +23 -1
- package/hooks/useAbsolutePositioning.d.ts +56 -7
- package/hooks/useAbsolutePositioning.js +39 -131
- package/hooks/useApplication.js +2 -0
- package/hooks/useDataSelect.js +3 -0
- package/package.json +1 -1
- package/ui/content/Chart/Chart.d.ts +37 -0
- package/ui/content/Chart/Chart.js +19 -0
- package/ui/content/Chart/index.d.ts +2 -0
- package/ui/content/Chart/index.js +7 -0
- package/ui/content/DropDown/DropDown.d.ts +1 -1
- package/ui/content/DropDown/DropDown.js +1 -1
- package/ui/content/index.d.ts +2 -1
- package/ui/content/index.js +3 -1
- package/ui/form/CheckboxListField/CheckboxListField.d.ts +1 -1
- package/ui/form/CheckboxListField/CheckboxListField.js +1 -1
- package/ui/form/DateField/useDateRange.d.ts +2 -1
- package/ui/form/DateField/useDateRange.js +23 -0
- package/ui/form/DateRangeField/DateRangeField.js +3 -1
- package/ui/form/DateTimeRangeField/DateTimeRangeField.js +3 -1
- package/ui/form/RadioListField/RadioListField.js +1 -1
- package/ui/layout/Sidebar/Sidebar.d.ts +0 -5
- package/ui/layout/Sidebar/Sidebar.js +1 -4
- package/ui/layout/Tooltip/Tooltip.d.ts +3 -7
- package/ui/layout/Tooltip/Tooltip.js +17 -49
- package/utils/calculateComponentAbsolutePosition.d.ts +6 -0
- package/{ui/layout/Tooltip/calculate.js → utils/calculateComponentAbsolutePosition.js} +64 -58
- package/utils/calendar.js +2 -0
- package/ui/layout/Tooltip/calculate.d.ts +0 -6
|
@@ -29,8 +29,8 @@ exports.__esModule = true;
|
|
|
29
29
|
var React = __importStar(require("react"));
|
|
30
30
|
var react_1 = require("react");
|
|
31
31
|
var react_use_1 = require("react-use");
|
|
32
|
-
var calculate_1 = __importDefault(require("../Tooltip/calculate"));
|
|
33
32
|
var hooks_1 = require("../../../hooks");
|
|
33
|
+
var useAbsolutePositioning_1 = __importDefault(require("../../../hooks/useAbsolutePositioning"));
|
|
34
34
|
var TooltipPortalInner_1 = __importDefault(require("./TooltipPortalInner"));
|
|
35
35
|
/*
|
|
36
36
|
* @Todo + check all calculations + describe
|
|
@@ -44,53 +44,21 @@ var TooltipPortalInner_1 = __importDefault(require("./TooltipPortalInner"));
|
|
|
44
44
|
* */
|
|
45
45
|
function Tooltip(props) {
|
|
46
46
|
var components = (0, hooks_1.useComponents)();
|
|
47
|
-
var _a = (0,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}),
|
|
54
|
-
var _d = (0, react_1.useState)({
|
|
55
|
-
left: null,
|
|
56
|
-
right: null,
|
|
57
|
-
top: null,
|
|
58
|
-
bottom: null
|
|
59
|
-
}), arrowPosition = _d[0], setArrowPosition = _d[1];
|
|
60
|
-
var timerRef = (0, react_1.useRef)(null);
|
|
61
|
-
var positionRef = (0, react_1.useRef)(props.position);
|
|
47
|
+
var _a = (0, useAbsolutePositioning_1["default"])({
|
|
48
|
+
componentDestroyDelay: props.animationMs,
|
|
49
|
+
position: props.position,
|
|
50
|
+
children: props.children,
|
|
51
|
+
gap: props.gap,
|
|
52
|
+
defaultVisible: props.defaultVisible
|
|
53
|
+
}), isComponentExist = _a.isComponentExist, isComponentVisible = _a.isComponentVisible, calculateAbsolutePosition = _a.calculateAbsolutePosition, onShow = _a.onShow, onHide = _a.onHide, position = _a.position, arrowPosition = _a.arrowPosition, style = _a.style;
|
|
62
54
|
var childRef = (0, react_1.useRef)(null);
|
|
63
|
-
var onShowTooltip = (0, react_1.useCallback)(function () {
|
|
64
|
-
if (timerRef.current) {
|
|
65
|
-
clearTimeout(timerRef.current);
|
|
66
|
-
}
|
|
67
|
-
setIsComponentExist(true);
|
|
68
|
-
setIsTooltipVisible(false);
|
|
69
|
-
// TODO: How to wait setState callback?
|
|
70
|
-
setTimeout(function () { return setIsTooltipVisible(true); });
|
|
71
|
-
}, []);
|
|
72
|
-
var onHideTooltip = (0, react_1.useCallback)(function () {
|
|
73
|
-
setIsTooltipVisible(false);
|
|
74
|
-
if (timerRef.current) {
|
|
75
|
-
clearTimeout(timerRef.current);
|
|
76
|
-
}
|
|
77
|
-
timerRef.current = setTimeout(function () { return setIsComponentExist(false); }, props.animationMs);
|
|
78
|
-
}, [props.animationMs]);
|
|
79
|
-
// Основная функция расчета позиции
|
|
80
55
|
var calculatePosition = (0, react_1.useCallback)(function (tooltipSize, arrowSize) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
positionRef.current = result.position;
|
|
86
|
-
setStyle(result.style);
|
|
87
|
-
if (result.arrowPosition) {
|
|
88
|
-
setArrowPosition(result.arrowPosition);
|
|
89
|
-
}
|
|
90
|
-
}, [props.gap]);
|
|
56
|
+
calculateAbsolutePosition(position, childRef.current, tooltipSize, arrowSize);
|
|
57
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
58
|
+
}, []);
|
|
91
59
|
(0, react_use_1.useMount)(function () {
|
|
92
|
-
if (
|
|
93
|
-
|
|
60
|
+
if (isComponentVisible) {
|
|
61
|
+
onShow();
|
|
94
62
|
}
|
|
95
63
|
});
|
|
96
64
|
if (!props.content) {
|
|
@@ -104,12 +72,12 @@ function Tooltip(props) {
|
|
|
104
72
|
childrenElement
|
|
105
73
|
? React.cloneElement(childrenElement, {
|
|
106
74
|
ref: childRef,
|
|
107
|
-
onMouseOver:
|
|
108
|
-
onMouseOut:
|
|
75
|
+
onMouseOver: onShow,
|
|
76
|
+
onMouseOut: onHide
|
|
109
77
|
})
|
|
110
|
-
: (React.createElement("span", { ref: childRef, onFocus:
|
|
78
|
+
: (React.createElement("span", { ref: childRef, onFocus: onShow, onMouseOver: onShow, onBlur: onHide, onMouseOut: onHide }, props.children)),
|
|
111
79
|
isComponentExist && (React.createElement(TooltipPortalInner_1["default"], null,
|
|
112
|
-
React.createElement(TooltipView, { isTooltipVisible:
|
|
80
|
+
React.createElement(TooltipView, { isTooltipVisible: isComponentVisible, content: props.content, position: position, style: style, arrowPosition: arrowPosition, calculatePosition: calculatePosition })))));
|
|
113
81
|
}
|
|
114
82
|
Tooltip.defaultProps = {
|
|
115
83
|
content: '',
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IComponentArrowPosition, IComponentStylePosition } from '../hooks/useAbsolutePositioning';
|
|
2
|
+
export default function calculateComponentAbsolutePosition(gap: any, position: any, parentRef: any, componentSize: any, arrowSize?: any, hasAutoPositioning?: boolean): {
|
|
3
|
+
style: IComponentStylePosition;
|
|
4
|
+
position: any;
|
|
5
|
+
arrowPosition: IComponentArrowPosition;
|
|
6
|
+
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
|
-
|
|
3
|
+
var useAbsolutePositioning_1 = require("../hooks/useAbsolutePositioning");
|
|
4
|
+
function calculateComponentAbsolutePosition(gap, position, parentRef, componentSize, arrowSize, hasAutoPositioning) {
|
|
5
|
+
if (arrowSize === void 0) { arrowSize = null; }
|
|
6
|
+
if (hasAutoPositioning === void 0) { hasAutoPositioning = true; }
|
|
4
7
|
if (process.env.IS_SSR) {
|
|
5
8
|
return null;
|
|
6
9
|
}
|
|
@@ -11,54 +14,57 @@ function calculate(gap, position, parentRef, tooltipSize, arrowSize) {
|
|
|
11
14
|
parentDimensions.top += window.scrollY;
|
|
12
15
|
// eslint-disable-next-line default-case
|
|
13
16
|
switch (position) {
|
|
14
|
-
case
|
|
15
|
-
case
|
|
16
|
-
case
|
|
17
|
+
case useAbsolutePositioning_1.Position.TOP:
|
|
18
|
+
case useAbsolutePositioning_1.Position.TOP_LEFT:
|
|
19
|
+
case useAbsolutePositioning_1.Position.TOP_RIGHT:
|
|
17
20
|
// Проверка - выходит ли tooltip за верхний край страницы?
|
|
18
21
|
// Если да - меняем позицию на bottom
|
|
19
|
-
if (
|
|
22
|
+
if (hasAutoPositioning
|
|
23
|
+
&& ((parentDimensions.top - window.scrollY) <= Math.round(componentSize.height + gap))) {
|
|
20
24
|
style.top = parentDimensions.top + parentDimensions.height;
|
|
21
|
-
position = position.replace(
|
|
25
|
+
position = position.replace(useAbsolutePositioning_1.Position.TOP, useAbsolutePositioning_1.Position.BOTTOM);
|
|
22
26
|
}
|
|
23
27
|
else {
|
|
24
|
-
style.top = parentDimensions.top -
|
|
28
|
+
style.top = parentDimensions.top - componentSize.height;
|
|
25
29
|
}
|
|
26
30
|
break;
|
|
27
|
-
case
|
|
28
|
-
case
|
|
29
|
-
case
|
|
31
|
+
case useAbsolutePositioning_1.Position.BOTTOM:
|
|
32
|
+
case useAbsolutePositioning_1.Position.BOTTOM_LEFT:
|
|
33
|
+
case useAbsolutePositioning_1.Position.BOTTOM_RIGHT:
|
|
30
34
|
/// Проверка - выходит ли tooltip за нижний край страницы?
|
|
31
35
|
// Если да - меняем позицию на top
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
if (hasAutoPositioning
|
|
37
|
+
&& ((window.innerHeight - (parentDimensions.top + parentDimensions.height - window.scrollY))
|
|
38
|
+
<= Math.round(componentSize.height + gap))) {
|
|
39
|
+
style.top = parentDimensions.top - componentSize.height;
|
|
40
|
+
position = position.replace(useAbsolutePositioning_1.Position.BOTTOM, useAbsolutePositioning_1.Position.TOP);
|
|
36
41
|
}
|
|
37
42
|
else {
|
|
38
43
|
style.top = parentDimensions.top + parentDimensions.height;
|
|
39
44
|
}
|
|
40
45
|
break;
|
|
41
|
-
case
|
|
42
|
-
case
|
|
43
|
-
case
|
|
46
|
+
case useAbsolutePositioning_1.Position.LEFT:
|
|
47
|
+
case useAbsolutePositioning_1.Position.LEFT_TOP:
|
|
48
|
+
case useAbsolutePositioning_1.Position.LEFT_BOTTOM:
|
|
44
49
|
// Проверка - выходит ли tooltip за левый край страницы?
|
|
45
50
|
// Если да - меняем позицию на right
|
|
46
|
-
if (parentDimensions.left <= Math.round(
|
|
51
|
+
if (hasAutoPositioning && (parentDimensions.left <= Math.round(componentSize.width + gap))) {
|
|
47
52
|
style.left = parentDimensions.right;
|
|
48
|
-
position = position.replace(
|
|
53
|
+
position = position.replace(useAbsolutePositioning_1.Position.LEFT, useAbsolutePositioning_1.Position.RIGHT);
|
|
49
54
|
}
|
|
50
55
|
else {
|
|
51
|
-
style.left = parentDimensions.left -
|
|
56
|
+
style.left = parentDimensions.left - componentSize.width;
|
|
52
57
|
}
|
|
53
58
|
break;
|
|
54
|
-
case
|
|
55
|
-
case
|
|
56
|
-
case
|
|
59
|
+
case useAbsolutePositioning_1.Position.RIGHT:
|
|
60
|
+
case useAbsolutePositioning_1.Position.RIGHT_TOP:
|
|
61
|
+
case useAbsolutePositioning_1.Position.RIGHT_BOTTOM:
|
|
57
62
|
// Проверка - выходит ли tooltip за правый край страницы?
|
|
58
63
|
// Если да - меняем позицию на left
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
if (hasAutoPositioning
|
|
65
|
+
&& (document.body.clientWidth - parentDimensions.right <= Math.round(componentSize.width + gap))) {
|
|
66
|
+
style.left = parentDimensions.left - componentSize.width;
|
|
67
|
+
position = position.replace(useAbsolutePositioning_1.Position.RIGHT, useAbsolutePositioning_1.Position.LEFT);
|
|
62
68
|
}
|
|
63
69
|
else {
|
|
64
70
|
style.left = parentDimensions.right;
|
|
@@ -67,45 +73,45 @@ function calculate(gap, position, parentRef, tooltipSize, arrowSize) {
|
|
|
67
73
|
}
|
|
68
74
|
// eslint-disable-next-line default-case
|
|
69
75
|
switch (position) {
|
|
70
|
-
case
|
|
71
|
-
case
|
|
76
|
+
case useAbsolutePositioning_1.Position.TOP:
|
|
77
|
+
case useAbsolutePositioning_1.Position.BOTTOM:
|
|
72
78
|
// Выравнивание по середине
|
|
73
|
-
style.left = (parentDimensions.left + (parentDimensions.width / 2)) - (
|
|
79
|
+
style.left = (parentDimensions.left + (parentDimensions.width / 2)) - (componentSize.width / 2);
|
|
74
80
|
break;
|
|
75
|
-
case
|
|
76
|
-
case
|
|
81
|
+
case useAbsolutePositioning_1.Position.TOP_LEFT:
|
|
82
|
+
case useAbsolutePositioning_1.Position.BOTTOM_LEFT:
|
|
77
83
|
// Ширина tooltip больше родителя - стрелка на середину родителя
|
|
78
84
|
style.left = parentDimensions.left;
|
|
79
|
-
if (parentDimensions.width <
|
|
85
|
+
if (arrowSize && (parentDimensions.width < componentSize.width)) {
|
|
80
86
|
arrowPosition = { left: parentDimensions.width / 2 };
|
|
81
87
|
}
|
|
82
88
|
break;
|
|
83
|
-
case
|
|
84
|
-
case
|
|
89
|
+
case useAbsolutePositioning_1.Position.TOP_RIGHT:
|
|
90
|
+
case useAbsolutePositioning_1.Position.BOTTOM_RIGHT:
|
|
85
91
|
// Ширина tooltip больше родителя - стрелка на середину родителя
|
|
86
|
-
style.left = parentDimensions.right -
|
|
87
|
-
if (parentDimensions.width <
|
|
92
|
+
style.left = parentDimensions.right - componentSize.width;
|
|
93
|
+
if (arrowSize && (parentDimensions.width < componentSize.width)) {
|
|
88
94
|
arrowPosition = {
|
|
89
95
|
left: null,
|
|
90
96
|
right: (parentDimensions.width / 2) - (arrowSize.width / 2)
|
|
91
97
|
};
|
|
92
98
|
}
|
|
93
99
|
break;
|
|
94
|
-
case
|
|
95
|
-
case
|
|
96
|
-
style.top = (parentDimensions.top + (parentDimensions.height / 2)) - (
|
|
100
|
+
case useAbsolutePositioning_1.Position.LEFT:
|
|
101
|
+
case useAbsolutePositioning_1.Position.RIGHT:
|
|
102
|
+
style.top = (parentDimensions.top + (parentDimensions.height / 2)) - (componentSize.height / 2);
|
|
97
103
|
break;
|
|
98
|
-
case
|
|
99
|
-
case
|
|
104
|
+
case useAbsolutePositioning_1.Position.LEFT_TOP:
|
|
105
|
+
case useAbsolutePositioning_1.Position.RIGHT_TOP:
|
|
100
106
|
style.top = parentDimensions.top;
|
|
101
|
-
if (parentDimensions.height <
|
|
107
|
+
if (arrowSize && (parentDimensions.height < componentSize.height)) {
|
|
102
108
|
arrowPosition = { top: parentDimensions.height / 2 };
|
|
103
109
|
}
|
|
104
110
|
break;
|
|
105
|
-
case
|
|
106
|
-
case
|
|
107
|
-
style.top = parentDimensions.top + parentDimensions.height -
|
|
108
|
-
if (parentDimensions.height <
|
|
111
|
+
case useAbsolutePositioning_1.Position.LEFT_BOTTOM:
|
|
112
|
+
case useAbsolutePositioning_1.Position.RIGHT_BOTTOM:
|
|
113
|
+
style.top = parentDimensions.top + parentDimensions.height - componentSize.height;
|
|
114
|
+
if (arrowSize && (parentDimensions.height < componentSize.height)) {
|
|
109
115
|
arrowPosition = {
|
|
110
116
|
bottom: (parentDimensions.height / 2) - (arrowSize.height / 2)
|
|
111
117
|
};
|
|
@@ -115,20 +121,20 @@ function calculate(gap, position, parentRef, tooltipSize, arrowSize) {
|
|
|
115
121
|
// Проверка - при позиционировании top/bottom tooltip не выходит за пределы страницы по горизонтали
|
|
116
122
|
if (position.includes('top') || position.includes('bottom')) {
|
|
117
123
|
if (!position.includes('Left')
|
|
118
|
-
&& (style.left < 0 || parentDimensions.left <= Math.round((
|
|
124
|
+
&& (style.left < 0 || parentDimensions.left <= Math.round((componentSize.width - parentDimensions.width) + gap))) {
|
|
119
125
|
style.right = null;
|
|
120
126
|
position = position.replace('Right', 'Left');
|
|
121
127
|
// Если ширина tooltip больше ширины родителя - выставить стрелку на середину родителя
|
|
122
|
-
if (parentDimensions.left <
|
|
128
|
+
if (parentDimensions.left < componentSize.width) {
|
|
123
129
|
arrowPosition = { left: parentDimensions.width / 2 };
|
|
124
130
|
}
|
|
125
131
|
style.left = parentDimensions.left;
|
|
126
132
|
}
|
|
127
|
-
if (!position.includes('Right')
|
|
133
|
+
else if (!position.includes('Right')
|
|
128
134
|
&& (document.body.clientWidth - parentDimensions.right
|
|
129
|
-
<= Math.round((
|
|
135
|
+
<= Math.round((componentSize.width - parentDimensions.width) + gap))) {
|
|
130
136
|
position = position.replace('Left', 'Right');
|
|
131
|
-
if (parentDimensions.width <
|
|
137
|
+
if (arrowSize && (parentDimensions.width < componentSize.width)) {
|
|
132
138
|
arrowPosition = {
|
|
133
139
|
left: null,
|
|
134
140
|
right: (parentDimensions.width / 2) - (arrowSize.width / 2)
|
|
@@ -141,25 +147,25 @@ function calculate(gap, position, parentRef, tooltipSize, arrowSize) {
|
|
|
141
147
|
// Проверка - при позиционировании left/right tooltip не выходит за пределы страницы по вертикали
|
|
142
148
|
if (position.includes('left') || position.includes('right')) {
|
|
143
149
|
if (!position.includes('Top')
|
|
144
|
-
&& parentDimensions.top - window.scrollY <= Math.round((
|
|
150
|
+
&& parentDimensions.top - window.scrollY <= Math.round((componentSize.height - parentDimensions.height) + gap)) {
|
|
145
151
|
position = position.replace('Bottom', 'Top');
|
|
146
|
-
if (parentDimensions.height <
|
|
152
|
+
if (parentDimensions.height < componentSize.height) {
|
|
147
153
|
arrowPosition = { top: parentDimensions.height / 2 };
|
|
148
154
|
}
|
|
149
155
|
style.top = parentDimensions.top;
|
|
150
156
|
}
|
|
151
|
-
if (!position.includes('Bottom')
|
|
157
|
+
else if (!position.includes('Bottom')
|
|
152
158
|
&& (window.innerHeight - (parentDimensions.top + parentDimensions.height - window.scrollY)
|
|
153
|
-
<= Math.round((
|
|
159
|
+
<= Math.round((componentSize.height - parentDimensions.height) + gap))) {
|
|
154
160
|
position = position.replace('Top', 'Bottom');
|
|
155
|
-
if (parentDimensions.height <
|
|
161
|
+
if (arrowSize && (parentDimensions.height < componentSize.height)) {
|
|
156
162
|
arrowPosition = {
|
|
157
163
|
bottom: (parentDimensions.height / 2) - (arrowSize.height / 2)
|
|
158
164
|
};
|
|
159
165
|
}
|
|
160
|
-
style.top = parentDimensions.top + parentDimensions.height -
|
|
166
|
+
style.top = parentDimensions.top + parentDimensions.height - componentSize.height;
|
|
161
167
|
}
|
|
162
168
|
}
|
|
163
169
|
return { style: style, position: position, arrowPosition: arrowPosition };
|
|
164
170
|
}
|
|
165
|
-
exports["default"] =
|
|
171
|
+
exports["default"] = calculateComponentAbsolutePosition;
|
package/utils/calendar.js
CHANGED
|
@@ -8,7 +8,9 @@ exports.convertDate = void 0;
|
|
|
8
8
|
/* eslint-disable import/prefer-default-export */
|
|
9
9
|
var dayjs_1 = __importDefault(require("dayjs"));
|
|
10
10
|
var utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
11
|
+
var customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
|
|
11
12
|
dayjs_1["default"].extend(utc_1["default"]);
|
|
13
|
+
dayjs_1["default"].extend(customParseFormat_1["default"]);
|
|
12
14
|
var convertDate = function (date, fromFormats, toFormat, isUtc, dateInUtc) {
|
|
13
15
|
if (toFormat === void 0) { toFormat = null; }
|
|
14
16
|
if (isUtc === void 0) { isUtc = false; }
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ITooltipArrowPosition, ITooltipStylePosition } from '../Tooltip/Tooltip';
|
|
2
|
-
export default function calculate(gap: any, position: any, parentRef: any, tooltipSize: any, arrowSize: any): {
|
|
3
|
-
style: ITooltipStylePosition;
|
|
4
|
-
position: any;
|
|
5
|
-
arrowPosition: ITooltipArrowPosition;
|
|
6
|
-
};
|