@easyv/charts 1.2.1 → 1.2.2

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.
@@ -1,202 +1,202 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
-
14
- var _react = require("react");
15
-
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
17
-
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
-
20
- var left = {
21
- position: 'relative',
22
- width: 5,
23
- height: '100%',
24
- cursor: 'col-resize',
25
- backgroundClip: 'content-box'
26
- };
27
- var center = {
28
- flex: '1 1 0%',
29
- height: '100%',
30
- cursor: 'move'
31
- };
32
- var right = {
33
- position: 'relative',
34
- width: 5,
35
- height: '100%',
36
- cursor: 'col-resize',
37
- backgroundClip: 'content-box'
38
- };
39
- var initialPosition = {
40
- start: 0,
41
- end: 0,
42
- status: ''
43
- };
44
-
45
- var getValue = function getValue(x, min, max) {
46
- return Math.max(min, Math.min(x, max));
47
- };
48
-
49
- var _default = function _default(_ref) {
50
- var width = _ref.width,
51
- _ref$config = _ref.config,
52
- height = _ref$config.height,
53
- background = _ref$config.background,
54
- _ref$config$margin = _ref$config.margin,
55
- marginLeft = _ref$config$margin.marginLeft,
56
- marginRight = _ref$config$margin.marginRight,
57
- _ref$config$detail = _ref$config.detail,
58
- blockWidth = _ref$config$detail.width,
59
- color = _ref$config$detail.color;
60
-
61
- var _useState = (0, _react.useState)({
62
- translateX: 0,
63
- width: blockWidth
64
- }),
65
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
66
- state = _useState2[0],
67
- setState = _useState2[1];
68
-
69
- var availableWidth = width - marginLeft - marginRight;
70
- var cache = (0, _react.useRef)(state);
71
- var move = (0, _react.useCallback)(function (_ref2) {
72
- var delta = _ref2.delta,
73
- status = _ref2.status,
74
- name = _ref2.name;
75
- var _cache$current = cache.current,
76
- width = _cache$current.width,
77
- translateX = _cache$current.translateX;
78
- var minWidth = 40;
79
- var minX = 0;
80
-
81
- switch (name) {
82
- case 'center':
83
- translateX = getValue(translateX + delta, minX, availableWidth - width);
84
- break;
85
-
86
- case 'left':
87
- var tempWidth = width;
88
- width = getValue(width + delta * -1, minWidth, translateX + width);
89
- translateX = getValue(translateX + delta, minX, translateX + tempWidth - width);
90
- break;
91
-
92
- case 'right':
93
- width = getValue(width + delta, minWidth, availableWidth - translateX);
94
- break;
95
- }
96
-
97
- if (status === 'up') {
98
- cache.current = {
99
- width: width,
100
- translateX: translateX
101
- };
102
- }
103
-
104
- setState({
105
- width: width,
106
- translateX: translateX
107
- });
108
- }, [availableWidth]);
109
- (0, _react.useEffect)(function () {}, [state]);
110
- return /*#__PURE__*/React.createElement("div", {
111
- style: {
112
- marginLeft: marginLeft,
113
- marginRight: marginRight,
114
- height: height,
115
- background: background,
116
- position: 'absolute',
117
- bottom: 0,
118
- width: availableWidth
119
- }
120
- }, /*#__PURE__*/React.createElement("div", {
121
- style: {
122
- display: 'flex',
123
- justifyContent: 'space-between',
124
- position: 'absolute',
125
- top: 0,
126
- left: 0,
127
- transform: 'translate3d(' + state.translateX + 'px, 0, 0)',
128
- height: '100%',
129
- width: state.width + 'px',
130
- backgroundColor: color
131
- }
132
- }, /*#__PURE__*/React.createElement(Move, {
133
- style: left,
134
- move: move,
135
- name: "left"
136
- }), /*#__PURE__*/React.createElement(Move, {
137
- style: center,
138
- move: move,
139
- name: "center"
140
- }), /*#__PURE__*/React.createElement(Move, {
141
- style: right,
142
- move: move,
143
- name: "right"
144
- })));
145
- };
146
-
147
- exports["default"] = _default;
148
- var Move = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
149
- var style = _ref3.style,
150
- move = _ref3.move,
151
- name = _ref3.name;
152
-
153
- var _useState3 = (0, _react.useState)(initialPosition),
154
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
155
- position = _useState4[0],
156
- setPosition = _useState4[1];
157
-
158
- var documentOnMouseMove = (0, _react.useCallback)(function (e) {
159
- // console.log('documentOnMouseMove');
160
- setPosition(function (position) {
161
- return _objectSpread(_objectSpread({}, position), {}, {
162
- end: e.clientX,
163
- status: 'move'
164
- });
165
- });
166
- }, []);
167
- var documentOnMouseUp = (0, _react.useCallback)(function (e) {
168
- // console.log('documentOnMouseUp');
169
- setPosition(function (position) {
170
- return _objectSpread(_objectSpread({}, position), {}, {
171
- end: e.clientX,
172
- status: 'up'
173
- });
174
- });
175
- document.removeEventListener('mousemove', documentOnMouseMove);
176
- document.removeEventListener('mouseup', documentOnMouseUp);
177
- }, []);
178
- var onMouseDown = (0, _react.useCallback)(function (e) {
179
- // console.log('onMouseDown');
180
- setPosition({
181
- end: e.clientX,
182
- start: e.clientX,
183
- status: 'down'
184
- });
185
- document.addEventListener('mousemove', documentOnMouseMove);
186
- document.addEventListener('mouseup', documentOnMouseUp);
187
- }, []);
188
- (0, _react.useEffect)(function () {
189
- var start = position.start,
190
- end = position.end,
191
- status = position.status;
192
- move({
193
- delta: end - start,
194
- status: status,
195
- name: name
196
- });
197
- }, [position, move, name]);
198
- return /*#__PURE__*/React.createElement("div", {
199
- style: style,
200
- onMouseDown: onMouseDown
201
- });
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
14
+ var _react = require("react");
15
+
16
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
17
+
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
+
20
+ var left = {
21
+ position: 'relative',
22
+ width: 5,
23
+ height: '100%',
24
+ cursor: 'col-resize',
25
+ backgroundClip: 'content-box'
26
+ };
27
+ var center = {
28
+ flex: '1 1 0%',
29
+ height: '100%',
30
+ cursor: 'move'
31
+ };
32
+ var right = {
33
+ position: 'relative',
34
+ width: 5,
35
+ height: '100%',
36
+ cursor: 'col-resize',
37
+ backgroundClip: 'content-box'
38
+ };
39
+ var initialPosition = {
40
+ start: 0,
41
+ end: 0,
42
+ status: ''
43
+ };
44
+
45
+ var getValue = function getValue(x, min, max) {
46
+ return Math.max(min, Math.min(x, max));
47
+ };
48
+
49
+ var _default = function _default(_ref) {
50
+ var width = _ref.width,
51
+ _ref$config = _ref.config,
52
+ height = _ref$config.height,
53
+ background = _ref$config.background,
54
+ _ref$config$margin = _ref$config.margin,
55
+ marginLeft = _ref$config$margin.marginLeft,
56
+ marginRight = _ref$config$margin.marginRight,
57
+ _ref$config$detail = _ref$config.detail,
58
+ blockWidth = _ref$config$detail.width,
59
+ color = _ref$config$detail.color;
60
+
61
+ var _useState = (0, _react.useState)({
62
+ translateX: 0,
63
+ width: blockWidth
64
+ }),
65
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
66
+ state = _useState2[0],
67
+ setState = _useState2[1];
68
+
69
+ var availableWidth = width - marginLeft - marginRight;
70
+ var cache = (0, _react.useRef)(state);
71
+ var move = (0, _react.useCallback)(function (_ref2) {
72
+ var delta = _ref2.delta,
73
+ status = _ref2.status,
74
+ name = _ref2.name;
75
+ var _cache$current = cache.current,
76
+ width = _cache$current.width,
77
+ translateX = _cache$current.translateX;
78
+ var minWidth = 40;
79
+ var minX = 0;
80
+
81
+ switch (name) {
82
+ case 'center':
83
+ translateX = getValue(translateX + delta, minX, availableWidth - width);
84
+ break;
85
+
86
+ case 'left':
87
+ var tempWidth = width;
88
+ width = getValue(width + delta * -1, minWidth, translateX + width);
89
+ translateX = getValue(translateX + delta, minX, translateX + tempWidth - width);
90
+ break;
91
+
92
+ case 'right':
93
+ width = getValue(width + delta, minWidth, availableWidth - translateX);
94
+ break;
95
+ }
96
+
97
+ if (status === 'up') {
98
+ cache.current = {
99
+ width: width,
100
+ translateX: translateX
101
+ };
102
+ }
103
+
104
+ setState({
105
+ width: width,
106
+ translateX: translateX
107
+ });
108
+ }, [availableWidth]);
109
+ (0, _react.useEffect)(function () {}, [state]);
110
+ return /*#__PURE__*/React.createElement("div", {
111
+ style: {
112
+ marginLeft: marginLeft,
113
+ marginRight: marginRight,
114
+ height: height,
115
+ background: background,
116
+ position: 'absolute',
117
+ bottom: 0,
118
+ width: availableWidth
119
+ }
120
+ }, /*#__PURE__*/React.createElement("div", {
121
+ style: {
122
+ display: 'flex',
123
+ justifyContent: 'space-between',
124
+ position: 'absolute',
125
+ top: 0,
126
+ left: 0,
127
+ transform: 'translate3d(' + state.translateX + 'px, 0, 0)',
128
+ height: '100%',
129
+ width: state.width + 'px',
130
+ backgroundColor: color
131
+ }
132
+ }, /*#__PURE__*/React.createElement(Move, {
133
+ style: left,
134
+ move: move,
135
+ name: "left"
136
+ }), /*#__PURE__*/React.createElement(Move, {
137
+ style: center,
138
+ move: move,
139
+ name: "center"
140
+ }), /*#__PURE__*/React.createElement(Move, {
141
+ style: right,
142
+ move: move,
143
+ name: "right"
144
+ })));
145
+ };
146
+
147
+ exports["default"] = _default;
148
+ var Move = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
149
+ var style = _ref3.style,
150
+ move = _ref3.move,
151
+ name = _ref3.name;
152
+
153
+ var _useState3 = (0, _react.useState)(initialPosition),
154
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
155
+ position = _useState4[0],
156
+ setPosition = _useState4[1];
157
+
158
+ var documentOnMouseMove = (0, _react.useCallback)(function (e) {
159
+ // console.log('documentOnMouseMove');
160
+ setPosition(function (position) {
161
+ return _objectSpread(_objectSpread({}, position), {}, {
162
+ end: e.clientX,
163
+ status: 'move'
164
+ });
165
+ });
166
+ }, []);
167
+ var documentOnMouseUp = (0, _react.useCallback)(function (e) {
168
+ // console.log('documentOnMouseUp');
169
+ setPosition(function (position) {
170
+ return _objectSpread(_objectSpread({}, position), {}, {
171
+ end: e.clientX,
172
+ status: 'up'
173
+ });
174
+ });
175
+ document.removeEventListener('mousemove', documentOnMouseMove);
176
+ document.removeEventListener('mouseup', documentOnMouseUp);
177
+ }, []);
178
+ var onMouseDown = (0, _react.useCallback)(function (e) {
179
+ // console.log('onMouseDown');
180
+ setPosition({
181
+ end: e.clientX,
182
+ start: e.clientX,
183
+ status: 'down'
184
+ });
185
+ document.addEventListener('mousemove', documentOnMouseMove);
186
+ document.addEventListener('mouseup', documentOnMouseUp);
187
+ }, []);
188
+ (0, _react.useEffect)(function () {
189
+ var start = position.start,
190
+ end = position.end,
191
+ status = position.status;
192
+ move({
193
+ delta: end - start,
194
+ status: status,
195
+ name: name
196
+ });
197
+ }, [position, move, name]);
198
+ return /*#__PURE__*/React.createElement("div", {
199
+ style: style,
200
+ onMouseDown: onMouseDown
201
+ });
202
202
  });