@onesy/ui-react 1.0.170 → 1.0.172
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/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { isEnvironment } from '@onesy/utils';
|
|
4
|
-
const
|
|
4
|
+
const useResize = () => {
|
|
5
5
|
const $ = _c(2);
|
|
6
6
|
const [windowWidth, setWindowWidth] = React.useState(_temp);
|
|
7
7
|
let t0;
|
|
@@ -27,7 +27,7 @@ const useWindowWidth = () => {
|
|
|
27
27
|
React.useEffect(t0, t1);
|
|
28
28
|
return windowWidth;
|
|
29
29
|
};
|
|
30
|
-
export default
|
|
30
|
+
export default useResize;
|
|
31
31
|
function _temp() {
|
|
32
32
|
if (isEnvironment("browser")) {
|
|
33
33
|
return window.innerWidth;
|
|
@@ -1,83 +1,35 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
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; }
|
|
4
|
-
import { c as _c } from "react/compiler-runtime";
|
|
5
4
|
import React from 'react';
|
|
6
5
|
import { is } from '@onesy/utils';
|
|
7
6
|
const useSubscription = (onesySubscription, method, value) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
7
|
+
// an array of the value
|
|
8
|
+
// we are getting the same reference value
|
|
9
|
+
// from some of the subscriptions
|
|
10
|
+
// in order for rerender to be made
|
|
11
|
+
const [response, setResponse] = React.useState([value !== undefined ? value : onesySubscription?.value]);
|
|
12
|
+
const refs = {
|
|
13
|
+
method: React.useRef(method)
|
|
14
|
+
};
|
|
15
|
+
refs.method.current = method;
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
if (value !== undefined) {
|
|
18
|
+
if (is('function', onesySubscription.init)) onesySubscription.init(_objectSpread(_objectSpread({}, value), {}, {
|
|
19
|
+
loaded: true
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
}, []);
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
if (!is('function', onesySubscription?.subscribe)) return;
|
|
25
|
+
const subscription = onesySubscription.subscribe(async valueItem => {
|
|
26
|
+
if (is('function', refs.method.current)) await refs.method.current(valueItem, setResponse);else setResponse([valueItem]);
|
|
27
|
+
});
|
|
28
|
+
if (onesySubscription.value !== undefined) setResponse([onesySubscription.value]);
|
|
29
|
+
return () => {
|
|
30
|
+
if (subscription) subscription.unsubscribe();
|
|
29
31
|
};
|
|
30
|
-
|
|
31
|
-
$[3] = value;
|
|
32
|
-
$[4] = t2;
|
|
33
|
-
} else {
|
|
34
|
-
t2 = $[4];
|
|
35
|
-
}
|
|
36
|
-
let t3;
|
|
37
|
-
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
38
|
-
t3 = [];
|
|
39
|
-
$[5] = t3;
|
|
40
|
-
} else {
|
|
41
|
-
t3 = $[5];
|
|
42
|
-
}
|
|
43
|
-
React.useEffect(t2, t3);
|
|
44
|
-
let t4;
|
|
45
|
-
if ($[6] !== method || $[7] !== onesySubscription) {
|
|
46
|
-
t4 = () => {
|
|
47
|
-
if (!is("function", onesySubscription?.subscribe)) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const subscription = onesySubscription.subscribe(async valueItem => {
|
|
51
|
-
if (is("function", method)) {
|
|
52
|
-
await method(valueItem, setResponse);
|
|
53
|
-
} else {
|
|
54
|
-
setResponse([valueItem]);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
if (onesySubscription.value !== undefined) {
|
|
58
|
-
setResponse([onesySubscription.value]);
|
|
59
|
-
}
|
|
60
|
-
return () => {
|
|
61
|
-
if (subscription) {
|
|
62
|
-
subscription.unsubscribe();
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
$[6] = method;
|
|
67
|
-
$[7] = onesySubscription;
|
|
68
|
-
$[8] = t4;
|
|
69
|
-
} else {
|
|
70
|
-
t4 = $[8];
|
|
71
|
-
}
|
|
72
|
-
let t5;
|
|
73
|
-
if ($[9] !== onesySubscription) {
|
|
74
|
-
t5 = [onesySubscription];
|
|
75
|
-
$[9] = onesySubscription;
|
|
76
|
-
$[10] = t5;
|
|
77
|
-
} else {
|
|
78
|
-
t5 = $[10];
|
|
79
|
-
}
|
|
80
|
-
React.useEffect(t4, t5);
|
|
32
|
+
}, [onesySubscription]);
|
|
81
33
|
return response[0];
|
|
82
34
|
};
|
|
83
35
|
export default useSubscription;
|
package/index.js
CHANGED
package/package.json
CHANGED
package/useResize/useResize.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
export default
|
|
1
|
+
declare const useResize: () => number;
|
|
2
|
+
export default useResize;
|
package/useResize/useResize.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _compilerRuntime = require("react/compiler-runtime");
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _utils = require("@onesy/utils");
|
|
11
|
-
const
|
|
11
|
+
const useResize = () => {
|
|
12
12
|
const $ = (0, _compilerRuntime.c)(2);
|
|
13
13
|
const [windowWidth, setWindowWidth] = _react.default.useState(_temp);
|
|
14
14
|
let t0;
|
|
@@ -34,7 +34,7 @@ const useWindowWidth = () => {
|
|
|
34
34
|
_react.default.useEffect(t0, t1);
|
|
35
35
|
return windowWidth;
|
|
36
36
|
};
|
|
37
|
-
var _default = exports.default =
|
|
37
|
+
var _default = exports.default = useResize;
|
|
38
38
|
function _temp() {
|
|
39
39
|
if ((0, _utils.isEnvironment)("browser")) {
|
|
40
40
|
return window.innerWidth;
|
|
@@ -6,85 +6,37 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _compilerRuntime = require("react/compiler-runtime");
|
|
10
9
|
var _react = _interopRequireDefault(require("react"));
|
|
11
10
|
var _utils = require("@onesy/utils");
|
|
12
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
12
|
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) { (0, _defineProperty2.default)(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; }
|
|
14
13
|
const useSubscription = (onesySubscription, method, value) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
14
|
+
// an array of the value
|
|
15
|
+
// we are getting the same reference value
|
|
16
|
+
// from some of the subscriptions
|
|
17
|
+
// in order for rerender to be made
|
|
18
|
+
const [response, setResponse] = _react.default.useState([value !== undefined ? value : onesySubscription === null || onesySubscription === void 0 ? void 0 : onesySubscription.value]);
|
|
19
|
+
const refs = {
|
|
20
|
+
method: _react.default.useRef(method)
|
|
21
|
+
};
|
|
22
|
+
refs.method.current = method;
|
|
23
|
+
_react.default.useEffect(() => {
|
|
24
|
+
if (value !== undefined) {
|
|
25
|
+
if ((0, _utils.is)('function', onesySubscription.init)) onesySubscription.init(_objectSpread(_objectSpread({}, value), {}, {
|
|
26
|
+
loaded: true
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
}, []);
|
|
30
|
+
_react.default.useEffect(() => {
|
|
31
|
+
if (!(0, _utils.is)('function', onesySubscription === null || onesySubscription === void 0 ? void 0 : onesySubscription.subscribe)) return;
|
|
32
|
+
const subscription = onesySubscription.subscribe(async valueItem => {
|
|
33
|
+
if ((0, _utils.is)('function', refs.method.current)) await refs.method.current(valueItem, setResponse);else setResponse([valueItem]);
|
|
34
|
+
});
|
|
35
|
+
if (onesySubscription.value !== undefined) setResponse([onesySubscription.value]);
|
|
36
|
+
return () => {
|
|
37
|
+
if (subscription) subscription.unsubscribe();
|
|
36
38
|
};
|
|
37
|
-
|
|
38
|
-
$[3] = value;
|
|
39
|
-
$[4] = t2;
|
|
40
|
-
} else {
|
|
41
|
-
t2 = $[4];
|
|
42
|
-
}
|
|
43
|
-
let t3;
|
|
44
|
-
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
45
|
-
t3 = [];
|
|
46
|
-
$[5] = t3;
|
|
47
|
-
} else {
|
|
48
|
-
t3 = $[5];
|
|
49
|
-
}
|
|
50
|
-
_react.default.useEffect(t2, t3);
|
|
51
|
-
let t4;
|
|
52
|
-
if ($[6] !== method || $[7] !== onesySubscription) {
|
|
53
|
-
t4 = () => {
|
|
54
|
-
if (!(0, _utils.is)("function", onesySubscription === null || onesySubscription === void 0 ? void 0 : onesySubscription.subscribe)) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const subscription = onesySubscription.subscribe(async valueItem => {
|
|
58
|
-
if ((0, _utils.is)("function", method)) {
|
|
59
|
-
await method(valueItem, setResponse);
|
|
60
|
-
} else {
|
|
61
|
-
setResponse([valueItem]);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
if (onesySubscription.value !== undefined) {
|
|
65
|
-
setResponse([onesySubscription.value]);
|
|
66
|
-
}
|
|
67
|
-
return () => {
|
|
68
|
-
if (subscription) {
|
|
69
|
-
subscription.unsubscribe();
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
$[6] = method;
|
|
74
|
-
$[7] = onesySubscription;
|
|
75
|
-
$[8] = t4;
|
|
76
|
-
} else {
|
|
77
|
-
t4 = $[8];
|
|
78
|
-
}
|
|
79
|
-
let t5;
|
|
80
|
-
if ($[9] !== onesySubscription) {
|
|
81
|
-
t5 = [onesySubscription];
|
|
82
|
-
$[9] = onesySubscription;
|
|
83
|
-
$[10] = t5;
|
|
84
|
-
} else {
|
|
85
|
-
t5 = $[10];
|
|
86
|
-
}
|
|
87
|
-
_react.default.useEffect(t4, t5);
|
|
39
|
+
}, [onesySubscription]);
|
|
88
40
|
return response[0];
|
|
89
41
|
};
|
|
90
42
|
var _default = exports.default = useSubscription;
|