@uncinc/uncinc-react-kitchen-sink 2.5.2 → 2.5.4-1-treeshaking
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/dist/Context/KitchenSinkComponentMapperContext.js +3 -11
- package/dist/Context/ViewportContext.js +8 -21
- package/dist/Context/withMapping.js +6 -17
- package/dist/components/AbbreviationAnnotation/index.js +17 -28
- package/dist/components/AbbreviationAnnotation/stories.js +12 -21
- package/dist/components/Accordion/AccordionItem/index.js +18 -29
- package/dist/components/Accordion/AccordionItemVariant/index.js +14 -25
- package/dist/components/Accordion/index.js +6 -14
- package/dist/components/Accordion/stories.js +16 -26
- package/dist/components/ApiAutocomplete/index.js +7 -17
- package/dist/components/ApiAutocomplete/stories.js +7 -16
- package/dist/components/Button/index.js +21 -30
- package/dist/components/Button/stories.js +11 -21
- package/dist/components/Cookie/Checkbox/index.js +6 -14
- package/dist/components/Cookie/index.js +61 -71
- package/dist/components/Cookie/stories.js +20 -33
- package/dist/components/Dialog/DialogHelpersStory/index.js +31 -0
- package/dist/components/Dialog/DialogHookStory/index.js +36 -0
- package/dist/components/Dialog/DialogOverrideStory/index.js +22 -0
- package/dist/components/Dialog/index.d.ts +6 -0
- package/dist/components/Dialog/index.js +44 -46
- package/dist/components/Dialog/stories.js +10 -43
- package/dist/components/FontSizeSwitcher/index.js +17 -28
- package/dist/components/FontSizeSwitcher/stories.js +10 -20
- package/dist/components/Form/Checkbox/index.js +13 -21
- package/dist/components/Form/Checkbox/stories.js +8 -17
- package/dist/components/Form/Checkboxes/index.js +19 -27
- package/dist/components/Form/Checkboxes/index.test.js +108 -77
- package/dist/components/Form/Checkboxes/stories.js +9 -18
- package/dist/components/Form/Date/index.js +4 -12
- package/dist/components/Form/Date/stories.js +7 -16
- package/dist/components/Form/DatePicker/index.js +12 -20
- package/dist/components/Form/DatePicker/stories.js +7 -16
- package/dist/components/Form/DateSelect/index.js +24 -35
- package/dist/components/Form/DateSelect/stories.js +10 -22
- package/dist/components/Form/Email/index.js +4 -12
- package/dist/components/Form/Email/stories.js +7 -16
- package/dist/components/Form/FormikWrapper/index.js +9 -17
- package/dist/components/Form/GenericFormElement/index.js +14 -22
- package/dist/components/Form/Number/index.js +6 -14
- package/dist/components/Form/Number/stories.js +7 -16
- package/dist/components/Form/RadioButtons/index.js +17 -25
- package/dist/components/Form/RadioButtons/index.test.js +81 -52
- package/dist/components/Form/RadioButtons/stories.js +9 -18
- package/dist/components/Form/SearchField/index.js +14 -22
- package/dist/components/Form/Select/Input/index.js +10 -18
- package/dist/components/Form/Select/index.js +18 -20
- package/dist/components/Form/Select/stories.js +9 -19
- package/dist/components/Form/TextField/index.js +11 -19
- package/dist/components/Form/TextField/index.test.js +75 -54
- package/dist/components/Form/TextField/stories.js +8 -17
- package/dist/components/Form/Textarea/index.js +10 -18
- package/dist/components/Form/Textarea/stories.js +7 -16
- package/dist/components/Hamburger/index.js +7 -15
- package/dist/components/Hamburger/stories.js +12 -22
- package/dist/components/Header/index.js +23 -38
- package/dist/components/Header/stories.js +22 -34
- package/dist/components/Image/Background/index.js +10 -21
- package/dist/components/Image/LazyLoadWrapper/index.js +16 -26
- package/dist/components/Image/Picture/index.js +20 -28
- package/dist/components/Image/index.js +11 -19
- package/dist/components/Image/stories.js +28 -41
- package/dist/components/InlineMenu/index.js +14 -25
- package/dist/components/InlineMenu/stories.js +18 -27
- package/dist/components/Layout/Container/index.js +10 -18
- package/dist/components/Layout/Container/stories.js +44 -53
- package/dist/components/Layout/QuickLayout/Auto/index.js +5 -13
- package/dist/components/Layout/QuickLayout/Center/index.js +6 -14
- package/dist/components/Layout/QuickLayout/Clamp/index.js +5 -13
- package/dist/components/Layout/QuickLayout/Sidebar/index.js +6 -14
- package/dist/components/Layout/QuickLayout/SpaceBetween/index.js +6 -14
- package/dist/components/Layout/QuickLayout/Stack/index.js +6 -14
- package/dist/components/Layout/QuickLayout/Wrap/index.js +7 -15
- package/dist/components/Layout/QuickLayout/index.js +16 -24
- package/dist/components/Layout/QuickLayout/stories.js +38 -54
- package/dist/components/Lottie/LottieAnimation/index.js +12 -23
- package/dist/components/Lottie/LottieAnimationWithMousePosition.js +8 -19
- package/dist/components/Lottie/index.js +29 -41
- package/dist/components/Lottie/stories.js +25 -36
- package/dist/components/MagicLine/index.js +12 -23
- package/dist/components/MagicLine/stories.js +16 -26
- package/dist/components/NavigationScroll/index.js +11 -21
- package/dist/components/NavigationScroll/stories.js +9 -18
- package/dist/components/Pagination/index.js +27 -36
- package/dist/components/Pagination/stories.js +17 -30
- package/dist/components/SearchKit/Facets/ChipFacet/index.js +11 -20
- package/dist/components/SearchKit/Facets/ListFacet/index.js +11 -20
- package/dist/components/SearchKit/Facets/SelectFacet/index.js +17 -24
- package/dist/components/SearchKit/Query/index.js +13 -24
- package/dist/components/SearchKit/SearchFacets/index.js +10 -18
- package/dist/components/SearchKit/SearchField/index.js +12 -23
- package/dist/components/SearchKit/SearchLoadMore/index.js +7 -15
- package/dist/components/SearchKit/SearchPage/index.js +8 -17
- package/dist/components/SearchKit/SearchPagination/index.js +6 -14
- package/dist/components/SearchKit/SearchReset/index.js +8 -16
- package/dist/components/SearchKit/SearchResults/index.js +28 -39
- package/dist/components/SearchKit/SearchSelectedFilters/Filters/CustomValue/index.js +6 -14
- package/dist/components/SearchKit/SearchSelectedFilters/Filters/DateRange/index.js +6 -14
- package/dist/components/SearchKit/SearchSelectedFilters/Filters/NumericRange/index.js +6 -14
- package/dist/components/SearchKit/SearchSelectedFilters/Filters/Value/index.js +7 -18
- package/dist/components/SearchKit/SearchSelectedFilters/index.js +18 -26
- package/dist/components/SearchKit/SearchSorting/index.js +9 -17
- package/dist/components/SearchKit/index.js +29 -40
- package/dist/components/SearchKit/stories.js +54 -69
- package/dist/components/Share/index.js +18 -26
- package/dist/components/Share/stories.js +7 -16
- package/dist/components/Sliders/SliderRelated/index.js +11 -19
- package/dist/components/Sliders/SliderRelated/stories.js +22 -33
- package/dist/components/WysiwygField/index.js +10 -18
- package/dist/components/WysiwygField/stories.js +10 -20
- package/dist/components/index.js +15 -111
- package/dist/config/constants.js +17 -37
- package/dist/config/i18next/index.js +9 -17
- package/dist/helpers/date.js +4 -13
- package/dist/helpers/gtm.js +4 -11
- package/dist/helpers/link.js +4 -12
- package/dist/helpers/useValueForCurrentViewPort.js +6 -13
- package/dist/hooks/useBoolean.js +6 -12
- package/dist/hooks/useClickOutside.js +3 -9
- package/dist/hooks/useDialog.js +6 -13
- package/dist/hooks/useDialogHelpers.d.ts +1 -0
- package/dist/hooks/useDialogHelpers.js +27 -28
- package/dist/hooks/useEscape.js +3 -9
- package/dist/hooks/useOnScreen.js +4 -10
- package/dist/hooks/usePrevious.js +4 -10
- package/dist/hooks/useScrollPosition.js +4 -11
- package/dist/hooks/useTrapFocus.js +3 -9
- package/dist/hooks/useWindowDimensions.js +4 -10
- package/dist/index.js +76 -397
- package/dist/setupTests.js +13 -9
- package/package.json +15 -8
|
@@ -1,46 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.default = useDialogHelpers;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _uuid = require("uuid");
|
|
9
|
-
var _useClickOutside = _interopRequireDefault(require("./useClickOutside"));
|
|
10
|
-
var _useEscape = _interopRequireDefault(require("./useEscape"));
|
|
11
|
-
var _useTrapFocus = _interopRequireDefault(require("./useTrapFocus"));
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
3
|
+
import useClickOutside from './useClickOutside';
|
|
4
|
+
import useEscape from './useEscape';
|
|
5
|
+
import useTrapFocus from './useTrapFocus';
|
|
13
6
|
/**
|
|
14
7
|
* Hook to allow you to implement your own Dialog component.
|
|
15
8
|
* This takes care of focus, and closing the Dialog by
|
|
16
9
|
* click outside it, or hitting Escape.
|
|
17
10
|
*/
|
|
18
|
-
function useDialogHelpers(options) {
|
|
11
|
+
export default function useDialogHelpers(options) {
|
|
19
12
|
var _options$id = options.id,
|
|
20
|
-
id = _options$id === void 0 ? (
|
|
13
|
+
id = _options$id === void 0 ? uuidv4() : _options$id,
|
|
21
14
|
wrapperElement = options.wrapperElement,
|
|
22
15
|
closeFunction = options.closeFunction,
|
|
23
|
-
isOpen = options.isOpen
|
|
16
|
+
isOpen = options.isOpen,
|
|
17
|
+
disableClosers = options.disableClosers;
|
|
24
18
|
|
|
25
19
|
/**
|
|
26
|
-
*
|
|
20
|
+
* Allows you to disable these two hooks.
|
|
27
21
|
*/
|
|
28
|
-
(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
if (!disableClosers) {
|
|
23
|
+
/**
|
|
24
|
+
* Close the Dialog by pressing Escape.
|
|
25
|
+
*/
|
|
26
|
+
useClickOutside({
|
|
27
|
+
refs: [wrapperElement],
|
|
28
|
+
onClick: closeFunction
|
|
29
|
+
});
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Close the Dialog by pressing Escape.
|
|
33
|
+
*/
|
|
34
|
+
useEscape({
|
|
35
|
+
onPress: closeFunction
|
|
36
|
+
});
|
|
37
|
+
}
|
|
39
38
|
|
|
40
39
|
/**
|
|
41
40
|
* Make sure focus does not leave the Dialog while it's open.
|
|
42
41
|
*/
|
|
43
|
-
(
|
|
42
|
+
useTrapFocus({
|
|
44
43
|
ref: wrapperElement,
|
|
45
44
|
isActive: isOpen
|
|
46
45
|
});
|
|
@@ -49,7 +48,7 @@ function useDialogHelpers(options) {
|
|
|
49
48
|
* Sets focus on the popup so that screen readers announce
|
|
50
49
|
* that the user is currently on a dialog.
|
|
51
50
|
*/
|
|
52
|
-
|
|
51
|
+
useEffect(function () {
|
|
53
52
|
if (isOpen && wrapperElement.current) {
|
|
54
53
|
wrapperElement.current.setAttribute('tabindex', '-1');
|
|
55
54
|
wrapperElement.current.focus();
|
package/dist/hooks/useEscape.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = useEscape;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
function useEscape(_ref) {
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
export default function useEscape(_ref) {
|
|
9
3
|
var unless = _ref.unless,
|
|
10
4
|
onPress = _ref.onPress;
|
|
11
|
-
|
|
5
|
+
useEffect(function () {
|
|
12
6
|
function handleOnPress(e) {
|
|
13
7
|
var shouldNotExecute = typeof unless === 'function' ? unless(e) : unless;
|
|
14
8
|
if (shouldNotExecute || e.key !== 'Escape') {
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = useOnScreen;
|
|
7
|
-
var _react = require("react");
|
|
8
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
2
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
3
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
4
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
5
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
13
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
import { useEffect, useState } from 'react';
|
|
8
|
+
export default function useOnScreen(ref) {
|
|
9
|
+
var _useState = useState(false),
|
|
16
10
|
_useState2 = _slicedToArray(_useState, 2),
|
|
17
11
|
isIntersecting = _useState2[0],
|
|
18
12
|
setIntersecting = _useState2[1];
|
|
@@ -21,7 +15,7 @@ function useOnScreen(ref) {
|
|
|
21
15
|
entry = _ref2[0];
|
|
22
16
|
return setIntersecting(entry.isIntersecting);
|
|
23
17
|
});
|
|
24
|
-
|
|
18
|
+
useEffect(function () {
|
|
25
19
|
observer.observe(ref.current);
|
|
26
20
|
// Remove the observer as soon as the component is unmounted
|
|
27
21
|
return function () {
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = usePrevious;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
function usePrevious(value) {
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
export default function usePrevious(value) {
|
|
9
3
|
// The ref object is a generic container whose current property is mutable ...
|
|
10
4
|
// ... and can hold any value, similar to an instance property on a class
|
|
11
|
-
var ref =
|
|
5
|
+
var ref = useRef();
|
|
12
6
|
|
|
13
7
|
// Store current value in ref
|
|
14
|
-
|
|
8
|
+
useEffect(function () {
|
|
15
9
|
ref.current = value;
|
|
16
10
|
}, [value]); // Only re-run if value changes
|
|
17
11
|
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
2
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
3
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
4
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
5
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
13
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { useEffect, useState } from 'react';
|
|
14
8
|
var useScrollPosition = function useScrollPosition() {
|
|
15
|
-
var _useState =
|
|
9
|
+
var _useState = useState(0),
|
|
16
10
|
_useState2 = _slicedToArray(_useState, 2),
|
|
17
11
|
scrollPosition = _useState2[0],
|
|
18
12
|
setScrollPosition = _useState2[1];
|
|
19
|
-
|
|
13
|
+
useEffect(function () {
|
|
20
14
|
var updatePosition = function updatePosition() {
|
|
21
15
|
setScrollPosition(window.pageYOffset);
|
|
22
16
|
};
|
|
@@ -28,5 +22,4 @@ var useScrollPosition = function useScrollPosition() {
|
|
|
28
22
|
}, []);
|
|
29
23
|
return scrollPosition;
|
|
30
24
|
};
|
|
31
|
-
|
|
32
|
-
exports.default = _default;
|
|
25
|
+
export default useScrollPosition;
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = useTrapFocus;
|
|
7
|
-
var _react = require("react");
|
|
8
1
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
2
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
3
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
4
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12
5
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
13
6
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
import { useEffect } from 'react';
|
|
14
8
|
/**
|
|
15
9
|
* Helper to trap focus within a certain component,
|
|
16
10
|
* which is useful for canvas menu lists or modals
|
|
17
11
|
*/
|
|
18
|
-
function useTrapFocus(options) {
|
|
12
|
+
export default function useTrapFocus(options) {
|
|
19
13
|
var ref = options.ref,
|
|
20
14
|
_options$isActive = options.isActive,
|
|
21
15
|
isActive = _options$isActive === void 0 ? false : _options$isActive;
|
|
22
|
-
|
|
16
|
+
useEffect(function () {
|
|
23
17
|
function onKeyDown(e) {
|
|
24
18
|
if (ref.current && isActive) {
|
|
25
19
|
var _getFocusableElements = getFocusableElements(ref.current),
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = useWindowDimensions;
|
|
7
|
-
var _react = require("react");
|
|
8
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
2
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
3
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
4
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
5
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
13
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { useState, useEffect } from 'react';
|
|
14
8
|
function getWindowDimensions() {
|
|
15
9
|
var _window = window,
|
|
16
10
|
width = _window.innerWidth,
|
|
@@ -20,12 +14,12 @@ function getWindowDimensions() {
|
|
|
20
14
|
height: height
|
|
21
15
|
};
|
|
22
16
|
}
|
|
23
|
-
function useWindowDimensions() {
|
|
24
|
-
var _useState =
|
|
17
|
+
export default function useWindowDimensions() {
|
|
18
|
+
var _useState = useState(getWindowDimensions()),
|
|
25
19
|
_useState2 = _slicedToArray(_useState, 2),
|
|
26
20
|
windowDimensions = _useState2[0],
|
|
27
21
|
setWindowDimensions = _useState2[1];
|
|
28
|
-
|
|
22
|
+
useEffect(function () {
|
|
29
23
|
function handleResize() {
|
|
30
24
|
setWindowDimensions(getWindowDimensions());
|
|
31
25
|
}
|