@micromag/core 0.3.813 → 0.3.814

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/es/hooks.js CHANGED
@@ -17,6 +17,7 @@ import raf from 'raf';
17
17
  import createDebug from 'debug';
18
18
  import isString from 'lodash/isString';
19
19
  import { useScreensManager, useFieldsManager, useTracking, useScreen } from '@micromag/core/contexts';
20
+ import { useWindowSize } from '@folklore/hooks';
20
21
  import { match } from 'css-mediaquery';
21
22
  import { useIntl } from 'react-intl';
22
23
  import dayjs from 'dayjs';
@@ -2093,30 +2094,8 @@ var useScreenSizeFromElement = function useScreenSizeFromElement() {
2093
2094
  resolution: !withoutScale ? scale * devicePixelRatio : devicePixelRatio
2094
2095
  };
2095
2096
  };
2096
- var getWindowSize = function getWindowSize() {
2097
- return {
2098
- width: typeof window !== 'undefined' ? window.innerWidth : null,
2099
- height: typeof window !== 'undefined' ? window.innerHæeight : null
2100
- };
2101
- };
2102
2097
  var useScreenSizeFromWindow = function useScreenSizeFromWindow(opts) {
2103
- var _useState3 = useState(getWindowSize()),
2104
- _useState4 = _slicedToArray(_useState3, 2),
2105
- windowSize = _useState4[0],
2106
- setWindowSize = _useState4[1];
2107
- useEffect(function () {
2108
- var onResize = function onResize() {
2109
- return setWindowSize(getWindowSize());
2110
- };
2111
- if (typeof window !== 'undefined') {
2112
- window.addEventListener('resize', onResize);
2113
- }
2114
- return function () {
2115
- if (typeof window !== 'undefined') {
2116
- window.removeEventListener('resize', onResize);
2117
- }
2118
- };
2119
- }, [setWindowSize]);
2098
+ var windowSize = useWindowSize();
2120
2099
  return useScreenSize(_objectSpread(_objectSpread({}, opts), windowSize));
2121
2100
  };
2122
2101
 
@@ -2204,7 +2183,8 @@ var useSwipe = function useSwipe() {
2204
2183
  var index = useRef(0);
2205
2184
  var lockedAxis = useRef(null);
2206
2185
  var hasWidth = width !== null;
2207
- var windowWidth = typeof window !== 'undefined' && !hasWidth ? window.innerWidth : null;
2186
+ var _useWindowSize = useWindowSize(),
2187
+ windowWidth = _useWindowSize.width;
2208
2188
  var currentWidth = hasWidth ? width : windowWidth;
2209
2189
  var count = items.length;
2210
2190
  var getItem = useCallback(function () {
package/lib/hooks.js CHANGED
@@ -19,6 +19,7 @@ var raf = require('raf');
19
19
  var createDebug = require('debug');
20
20
  var isString = require('lodash/isString');
21
21
  var contexts = require('@micromag/core/contexts');
22
+ var hooks = require('@folklore/hooks');
22
23
  var cssMediaquery = require('css-mediaquery');
23
24
  var reactIntl = require('react-intl');
24
25
  var dayjs = require('dayjs');
@@ -2095,30 +2096,8 @@ var useScreenSizeFromElement = function useScreenSizeFromElement() {
2095
2096
  resolution: !withoutScale ? scale * devicePixelRatio : devicePixelRatio
2096
2097
  };
2097
2098
  };
2098
- var getWindowSize = function getWindowSize() {
2099
- return {
2100
- width: typeof window !== 'undefined' ? window.innerWidth : null,
2101
- height: typeof window !== 'undefined' ? window.innerHæeight : null
2102
- };
2103
- };
2104
2099
  var useScreenSizeFromWindow = function useScreenSizeFromWindow(opts) {
2105
- var _useState3 = react.useState(getWindowSize()),
2106
- _useState4 = _slicedToArray(_useState3, 2),
2107
- windowSize = _useState4[0],
2108
- setWindowSize = _useState4[1];
2109
- react.useEffect(function () {
2110
- var onResize = function onResize() {
2111
- return setWindowSize(getWindowSize());
2112
- };
2113
- if (typeof window !== 'undefined') {
2114
- window.addEventListener('resize', onResize);
2115
- }
2116
- return function () {
2117
- if (typeof window !== 'undefined') {
2118
- window.removeEventListener('resize', onResize);
2119
- }
2120
- };
2121
- }, [setWindowSize]);
2100
+ var windowSize = hooks.useWindowSize();
2122
2101
  return useScreenSize(_objectSpread(_objectSpread({}, opts), windowSize));
2123
2102
  };
2124
2103
 
@@ -2206,7 +2185,8 @@ var useSwipe = function useSwipe() {
2206
2185
  var index = react.useRef(0);
2207
2186
  var lockedAxis = react.useRef(null);
2208
2187
  var hasWidth = width !== null;
2209
- var windowWidth = typeof window !== 'undefined' && !hasWidth ? window.innerWidth : null;
2188
+ var _useWindowSize = hooks.useWindowSize(),
2189
+ windowWidth = _useWindowSize.width;
2210
2190
  var currentWidth = hasWidth ? width : windowWidth;
2211
2191
  var count = items.length;
2212
2192
  var getItem = react.useCallback(function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/core",
3
- "version": "0.3.813",
3
+ "version": "0.3.814",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -130,6 +130,7 @@
130
130
  "@babel/runtime": "^7.13.10",
131
131
  "@folklore/fetch": "^0.1.17",
132
132
  "@folklore/forms": "~0.0.23",
133
+ "@folklore/hooks": "^0.0.83",
133
134
  "@folklore/routes": "^0.2.36",
134
135
  "@folklore/services": "^0.1.24",
135
136
  "@folklore/size": "^0.1.20",
@@ -167,5 +168,5 @@
167
168
  "access": "public",
168
169
  "registry": "https://registry.npmjs.org/"
169
170
  },
170
- "gitHead": "24f52ddea5f0ee918f594af86c3c8fd2e1b6f289"
171
+ "gitHead": "96d19c8ede8dc2e8c051ba118975258e061a8da2"
171
172
  }