@onesy/ui-react 1.0.179 → 1.0.180

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/Chart/Chart.js CHANGED
@@ -542,14 +542,16 @@ const Chart = props_ => {
542
542
  setHover(true);
543
543
  };
544
544
  const onWrapperMouseLeave = () => {
545
- setHover(false);
546
- setTimeout(() => {
547
- if (tooltipCloseOnMouseLeave) setAppend(values__0 => _objectSpread(_objectSpread({}, values__0), {}, {
548
- open: false
549
- }));
550
- if (!guidelinesDisplayInactive) setGuidelineIn(false);
551
- setGuidelinePosition({});
552
- });
545
+ if (refs.hover.current) {
546
+ setHover(false);
547
+ setTimeout(() => {
548
+ if (tooltipCloseOnMouseLeave) setAppend(values__0 => _objectSpread(_objectSpread({}, values__0), {}, {
549
+ open: false
550
+ }));
551
+ if (!guidelinesDisplayInactive) setGuidelineIn(false);
552
+ setGuidelinePosition({});
553
+ });
554
+ }
553
555
  };
554
556
  const makeGroupTooltip = (x_, y_) => {
555
557
  const items_0 = refs.allValues.current.filter(item_2 => item_2.normalized[0] === x_);
package/Expand/Expand.js CHANGED
@@ -113,7 +113,8 @@ const Expand = props_ => {
113
113
  placeholder: _react.default.useRef(undefined),
114
114
  parent: _react.default.useRef(undefined),
115
115
  element: _react.default.useRef(undefined),
116
- value: _react.default.useRef(0)
116
+ value: _react.default.useRef(0),
117
+ previousWidth: _react.default.useRef((0, _utils.isEnvironment)('browser') && window.innerWidth)
117
118
  };
118
119
  refs.value.current = value;
119
120
  refs.parent.current = parent;
@@ -126,8 +127,11 @@ const Expand = props_ => {
126
127
  const childrenWithTransition = isTransition(children === null || children === void 0 || (_children$type = children.type) === null || _children$type === void 0 ? void 0 : _children$type.displayName);
127
128
  _react.default.useEffect(() => {
128
129
  const method = () => {
130
+ const newWidth = window.innerWidth;
131
+ if (refs.previousWidth.current === newWidth) return;
129
132
  setValue(null);
130
133
  setParent(null);
134
+ refs.previousWidth.current = newWidth;
131
135
  };
132
136
 
133
137
  // on resize
@@ -534,14 +534,16 @@ const Chart = props_ => {
534
534
  setHover(true);
535
535
  };
536
536
  const onWrapperMouseLeave = () => {
537
- setHover(false);
538
- setTimeout(() => {
539
- if (tooltipCloseOnMouseLeave) setAppend(values__0 => _objectSpread(_objectSpread({}, values__0), {}, {
540
- open: false
541
- }));
542
- if (!guidelinesDisplayInactive) setGuidelineIn(false);
543
- setGuidelinePosition({});
544
- });
537
+ if (refs.hover.current) {
538
+ setHover(false);
539
+ setTimeout(() => {
540
+ if (tooltipCloseOnMouseLeave) setAppend(values__0 => _objectSpread(_objectSpread({}, values__0), {}, {
541
+ open: false
542
+ }));
543
+ if (!guidelinesDisplayInactive) setGuidelineIn(false);
544
+ setGuidelinePosition({});
545
+ });
546
+ }
545
547
  };
546
548
  const makeGroupTooltip = (x_, y_) => {
547
549
  const items_0 = refs.allValues.current.filter(item_2 => item_2.normalized[0] === x_);
@@ -6,7 +6,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  import { c as _c } from "react/compiler-runtime";
8
8
  import React from 'react';
9
- import { is } from '@onesy/utils';
9
+ import { is, isEnvironment } from '@onesy/utils';
10
10
  import { useOnesyTheme } from '@onesy/style-react';
11
11
  import { Transition } from '..';
12
12
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
@@ -105,7 +105,8 @@ const Expand = props_ => {
105
105
  placeholder: React.useRef(undefined),
106
106
  parent: React.useRef(undefined),
107
107
  element: React.useRef(undefined),
108
- value: React.useRef(0)
108
+ value: React.useRef(0),
109
+ previousWidth: React.useRef(isEnvironment('browser') && window.innerWidth)
109
110
  };
110
111
  refs.value.current = value;
111
112
  refs.parent.current = parent;
@@ -118,8 +119,11 @@ const Expand = props_ => {
118
119
  const childrenWithTransition = isTransition(children?.type?.displayName);
119
120
  React.useEffect(() => {
120
121
  const method = () => {
122
+ const newWidth = window.innerWidth;
123
+ if (refs.previousWidth.current === newWidth) return;
121
124
  setValue(null);
122
125
  setParent(null);
126
+ refs.previousWidth.current = newWidth;
123
127
  };
124
128
 
125
129
  // on resize
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license UiReact v1.0.178
1
+ /** @license UiReact v1.0.179
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -1,36 +1,27 @@
1
- import { c as _c } from "react/compiler-runtime";
2
1
  import React from 'react';
3
2
  import { isEnvironment } from '@onesy/utils';
4
3
  const useResize = () => {
5
- const $ = _c(2);
6
- const [windowWidth, setWindowWidth] = React.useState(_temp);
7
- let t0;
8
- let t1;
9
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
10
- t0 = () => {
11
- const onResize = () => {
12
- setWindowWidth(window.innerWidth);
13
- };
14
- if (isEnvironment("browser")) {
15
- setWindowWidth(window.innerWidth);
16
- window.addEventListener("resize", onResize);
17
- return () => window.removeEventListener("resize", onResize);
18
- }
4
+ const [width, setWidth] = React.useState(() => {
5
+ if (isEnvironment('browser')) return window.innerWidth;
6
+ return 0;
7
+ });
8
+ const refs = {
9
+ width: React.useRef(width)
10
+ };
11
+ refs.width.current = width;
12
+ React.useEffect(() => {
13
+ const onResize = () => {
14
+ const newWidth = window.innerWidth;
15
+ if (refs.width.current === newWidth) return;
16
+ setWidth(newWidth);
19
17
  };
20
- t1 = [];
21
- $[0] = t0;
22
- $[1] = t1;
23
- } else {
24
- t0 = $[0];
25
- t1 = $[1];
26
- }
27
- React.useEffect(t0, t1);
28
- return windowWidth;
18
+ if (isEnvironment('browser')) {
19
+ const newWidth_0 = window.innerWidth;
20
+ if (refs.width.current !== newWidth_0) setWidth(newWidth_0);
21
+ window.addEventListener('resize', onResize);
22
+ return () => window.removeEventListener('resize', onResize);
23
+ }
24
+ }, []);
25
+ return width;
29
26
  };
30
- export default useResize;
31
- function _temp() {
32
- if (isEnvironment("browser")) {
33
- return window.innerWidth;
34
- }
35
- return 0;
36
- }
27
+ export default useResize;
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license UiReact v1.0.178
1
+ /** @license UiReact v1.0.179
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onesy/ui-react",
3
- "version": "1.0.179",
3
+ "version": "1.0.180",
4
4
  "description": "UI for React",
5
5
  "repository": "https://github.com/onesy-me/onesy.git",
6
6
  "author": "Lazar Erić <lazareric1@proton.me>",
@@ -5,39 +5,30 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _compilerRuntime = require("react/compiler-runtime");
9
8
  var _react = _interopRequireDefault(require("react"));
10
9
  var _utils = require("@onesy/utils");
11
10
  const useResize = () => {
12
- const $ = (0, _compilerRuntime.c)(2);
13
- const [windowWidth, setWindowWidth] = _react.default.useState(_temp);
14
- let t0;
15
- let t1;
16
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
17
- t0 = () => {
18
- const onResize = () => {
19
- setWindowWidth(window.innerWidth);
20
- };
21
- if ((0, _utils.isEnvironment)("browser")) {
22
- setWindowWidth(window.innerWidth);
23
- window.addEventListener("resize", onResize);
24
- return () => window.removeEventListener("resize", onResize);
25
- }
11
+ const [width, setWidth] = _react.default.useState(() => {
12
+ if ((0, _utils.isEnvironment)('browser')) return window.innerWidth;
13
+ return 0;
14
+ });
15
+ const refs = {
16
+ width: _react.default.useRef(width)
17
+ };
18
+ refs.width.current = width;
19
+ _react.default.useEffect(() => {
20
+ const onResize = () => {
21
+ const newWidth = window.innerWidth;
22
+ if (refs.width.current === newWidth) return;
23
+ setWidth(newWidth);
26
24
  };
27
- t1 = [];
28
- $[0] = t0;
29
- $[1] = t1;
30
- } else {
31
- t0 = $[0];
32
- t1 = $[1];
33
- }
34
- _react.default.useEffect(t0, t1);
35
- return windowWidth;
25
+ if ((0, _utils.isEnvironment)('browser')) {
26
+ const newWidth_0 = window.innerWidth;
27
+ if (refs.width.current !== newWidth_0) setWidth(newWidth_0);
28
+ window.addEventListener('resize', onResize);
29
+ return () => window.removeEventListener('resize', onResize);
30
+ }
31
+ }, []);
32
+ return width;
36
33
  };
37
- var _default = exports.default = useResize;
38
- function _temp() {
39
- if ((0, _utils.isEnvironment)("browser")) {
40
- return window.innerWidth;
41
- }
42
- return 0;
43
- }
34
+ var _default = exports.default = useResize;