@reactuses/core 5.0.16 → 5.0.17

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/index.cjs CHANGED
@@ -5,10 +5,11 @@ var lodashEs = require('lodash-es');
5
5
  var Cookies = require('js-cookie');
6
6
  var screenfull = require('screenfull');
7
7
  var index_js = require('use-sync-external-store/shim/index.js');
8
- var indexClient = require('./index-client-DSNqfa2q.cjs');
8
+ var indexClient = require('./index-client-DJgtg2U_.cjs');
9
9
 
10
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
11
 
12
+ var React__default = /*#__PURE__*/_interopDefault(React);
12
13
  var Cookies__default = /*#__PURE__*/_interopDefault(Cookies);
13
14
  var screenfull__default = /*#__PURE__*/_interopDefault(screenfull);
14
15
 
@@ -19,13 +20,17 @@ const useLatest = (value)=>{
19
20
  };
20
21
 
21
22
  var _window_navigator, _window;
22
- const isFunction = (val)=>typeof val === "function";
23
- const isString = (val)=>typeof val === "string";
24
- const isDev = process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
25
- const isBrowser = typeof window !== "undefined";
26
- const isNavigator = typeof navigator !== "undefined";
27
- const noop = ()=>{};
28
- const isIOS = isBrowser && ((_window = window) == null ? void 0 : (_window_navigator = _window.navigator) == null ? void 0 : _window_navigator.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
23
+ function isFunction(val) {
24
+ return typeof val === 'function';
25
+ }
26
+ function isString(val) {
27
+ return typeof val === 'string';
28
+ }
29
+ const isDev = process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test';
30
+ const isBrowser = typeof window !== 'undefined';
31
+ const isNavigator = typeof navigator !== 'undefined';
32
+ function noop() {}
33
+ const isIOS = isBrowser && ((_window = window) == null ? void 0 : (_window_navigator = _window.navigator) == null ? void 0 : _window_navigator.userAgent) && /iP(?:ad|hone|od)/.test(window.navigator.userAgent);
29
34
 
30
35
  function on(obj, ...args) {
31
36
  if (obj && obj.addEventListener) {
@@ -40,9 +45,9 @@ function off(obj, ...args) {
40
45
  const defaultWindow = isBrowser ? window : undefined;
41
46
 
42
47
  const defaultOptions$1 = {};
43
- const defaultOnError = (e)=>{
48
+ function defaultOnError(e) {
44
49
  console.error(e);
45
- };
50
+ }
46
51
 
47
52
  function getTargetElement(target, defaultElement) {
48
53
  if (!isBrowser) {
@@ -54,7 +59,7 @@ function getTargetElement(target, defaultElement) {
54
59
  let targetElement;
55
60
  if (isFunction(target)) {
56
61
  targetElement = target();
57
- } else if ("current" in target) {
62
+ } else if ('current' in target) {
58
63
  targetElement = target.current;
59
64
  } else {
60
65
  targetElement = target;
@@ -63,12 +68,12 @@ function getTargetElement(target, defaultElement) {
63
68
  }
64
69
 
65
70
  const useCustomCompareEffect = (effect, deps, depsEqual)=>{
66
- if (process.env.NODE_ENV !== "production") {
71
+ if (process.env.NODE_ENV !== 'production') {
67
72
  if (!Array.isArray(deps) || !deps.length) {
68
- console.warn("`useCustomCompareEffect` should not be used with no dependencies. Use React.useEffect instead.");
73
+ console.warn('`useCustomCompareEffect` should not be used with no dependencies. Use React.useEffect instead.');
69
74
  }
70
- if (typeof depsEqual !== "function") {
71
- console.warn("`useCustomCompareEffect` should be used with depsEqual callback for comparing deps list");
75
+ if (typeof depsEqual !== 'function') {
76
+ console.warn('`useCustomCompareEffect` should be used with depsEqual callback for comparing deps list');
72
77
  }
73
78
  }
74
79
  const ref = React.useRef(undefined);
@@ -80,9 +85,9 @@ const useCustomCompareEffect = (effect, deps, depsEqual)=>{
80
85
  };
81
86
 
82
87
  const useDeepCompareEffect = (effect, deps)=>{
83
- if (process.env.NODE_ENV !== "production") {
88
+ if (process.env.NODE_ENV !== 'production') {
84
89
  if (!Array.isArray(deps) || !deps.length) {
85
- console.warn("`useDeepCompareEffect` should not be used with no dependencies. Use React.useEffect instead.");
90
+ console.warn('`useDeepCompareEffect` should not be used with no dependencies. Use React.useEffect instead.');
86
91
  }
87
92
  }
88
93
  useCustomCompareEffect(effect, deps, lodashEs.isEqual);
@@ -116,12 +121,12 @@ const useActiveElement = ()=>{
116
121
  var _window;
117
122
  setActive((_window = window) == null ? void 0 : _window.document.activeElement);
118
123
  }, []);
119
- useEventListener("blur", listener, ()=>window, true);
120
- useEventListener("focus", listener, ()=>window, true);
124
+ useEventListener('blur', listener, ()=>window, true);
125
+ useEventListener('focus', listener, ()=>window, true);
121
126
  return active;
122
127
  };
123
128
 
124
- const useMountedState = ()=>{
129
+ function useMountedState() {
125
130
  const mountedRef = React.useRef(false);
126
131
  const get = React.useCallback(()=>mountedRef.current, []);
127
132
  React.useEffect(()=>{
@@ -131,7 +136,7 @@ const useMountedState = ()=>{
131
136
  };
132
137
  }, []);
133
138
  return get;
134
- };
139
+ }
135
140
 
136
141
  function asyncGeneratorStep$6(gen, resolve, reject, _next, _throw, key, arg) {
137
142
  try {
@@ -198,11 +203,11 @@ const useClickOutside = (target, handler, enabled = true)=>{
198
203
  }
199
204
  savedHandler.current(event);
200
205
  };
201
- useEventListener("mousedown", listener, defaultWindow, listerOptions);
202
- useEventListener("touchstart", listener, defaultWindow, listerOptions);
206
+ useEventListener('mousedown', listener, defaultWindow, listerOptions);
207
+ useEventListener('touchstart', listener, defaultWindow, listerOptions);
203
208
  };
204
209
 
205
- const getInitialState$4 = (key, defaultValue)=>{
210
+ function getInitialState$4(key, defaultValue) {
206
211
  // Prevent a React hydration mismatch when a default value is provided.
207
212
  if (defaultValue !== undefined) {
208
213
  return defaultValue;
@@ -210,11 +215,11 @@ const getInitialState$4 = (key, defaultValue)=>{
210
215
  if (isBrowser) {
211
216
  return Cookies__default.default.get(key);
212
217
  }
213
- if (process.env.NODE_ENV !== "production") {
214
- console.warn("`useCookie` When server side rendering, defaultValue should be defined to prevent a hydration mismatches.");
218
+ if (process.env.NODE_ENV !== 'production') {
219
+ console.warn('`useCookie` When server side rendering, defaultValue should be defined to prevent a hydration mismatches.');
215
220
  }
216
- return "";
217
- };
221
+ return '';
222
+ }
218
223
  const useCookie = (key, options = defaultOptions$1, defaultValue)=>{
219
224
  const [cookieValue, setCookieValue] = React.useState(getInitialState$4(key, defaultValue));
220
225
  React.useEffect(()=>{
@@ -331,22 +336,22 @@ const useInterval = (callback, delay, options = defaultOptions$1)=>{
331
336
  };
332
337
  };
333
338
 
334
- const padZero = (time)=>{
339
+ function padZero(time) {
335
340
  return `${time}`.length < 2 ? `0${time}` : `${time}`;
336
- };
337
- const getHMSTime = (timeDiff)=>{
341
+ }
342
+ function getHMSTime(timeDiff) {
338
343
  if (timeDiff <= 0) {
339
344
  return [
340
- "00",
341
- "00",
342
- "00"
345
+ '00',
346
+ '00',
347
+ '00'
343
348
  ];
344
349
  }
345
350
  if (timeDiff > 100 * 3600) {
346
351
  return [
347
- "99",
348
- "59",
349
- "59"
352
+ '99',
353
+ '59',
354
+ '59'
350
355
  ];
351
356
  }
352
357
  const hour = Math.floor(timeDiff / 3600);
@@ -357,7 +362,7 @@ const getHMSTime = (timeDiff)=>{
357
362
  padZero(minute),
358
363
  padZero(second)
359
364
  ];
360
- };
365
+ }
361
366
  const useCountDown = (time, format = getHMSTime, callback)=>{
362
367
  const [remainTime, setRemainTime] = React.useState(time);
363
368
  const [delay, setDelay] = React.useState(1000);
@@ -388,14 +393,14 @@ const useCountDown = (time, format = getHMSTime, callback)=>{
388
393
  const useCounter = (initialValue = 0, max = null, min = null)=>{
389
394
  // avoid exec init code every render
390
395
  const initFunc = ()=>{
391
- let init = typeof initialValue === "function" ? initialValue() : initialValue;
392
- typeof init !== "number" && console.error(`initialValue has to be a number, got ${typeof initialValue}`);
393
- if (typeof min === "number") {
396
+ let init = typeof initialValue === 'function' ? initialValue() : initialValue;
397
+ typeof init !== 'number' && console.error(`initialValue has to be a number, got ${typeof initialValue}`);
398
+ if (typeof min === 'number') {
394
399
  init = Math.max(init, min);
395
400
  } else if (min !== null) {
396
401
  console.error(`min has to be a number, got ${typeof min}`);
397
402
  }
398
- if (typeof max === "number") {
403
+ if (typeof max === 'number') {
399
404
  init = Math.min(init, max);
400
405
  } else if (max !== null) {
401
406
  console.error(`max has to be a number, got ${typeof max}`);
@@ -405,11 +410,11 @@ const useCounter = (initialValue = 0, max = null, min = null)=>{
405
410
  const [value, setValue] = React.useState(initFunc);
406
411
  const set = useEvent((newState)=>{
407
412
  setValue((v)=>{
408
- let nextValue = typeof newState === "function" ? newState(v) : newState;
409
- if (typeof min === "number") {
413
+ let nextValue = typeof newState === 'function' ? newState(v) : newState;
414
+ if (typeof min === 'number') {
410
415
  nextValue = Math.max(nextValue, min);
411
416
  }
412
- if (typeof max === "number") {
417
+ if (typeof max === 'number') {
413
418
  nextValue = Math.min(nextValue, max);
414
419
  }
415
420
  return nextValue;
@@ -437,19 +442,19 @@ const defaultOptions = {
437
442
  observe: false
438
443
  };
439
444
 
440
- const getInitialState$3 = (defaultValue)=>{
445
+ function getInitialState$3(defaultValue) {
441
446
  // Prevent a React hydration mismatch when a default value is provided.
442
447
  if (defaultValue !== undefined) {
443
448
  return defaultValue;
444
449
  }
445
450
  if (isBrowser) {
446
- return "";
451
+ return '';
447
452
  }
448
- if (process.env.NODE_ENV !== "production") {
449
- console.warn("`useCssVar` When server side rendering, defaultValue should be defined to prevent a hydration mismatches.");
453
+ if (process.env.NODE_ENV !== 'production') {
454
+ console.warn('`useCssVar` When server side rendering, defaultValue should be defined to prevent a hydration mismatches.');
450
455
  }
451
- return "";
452
- };
456
+ return '';
457
+ }
453
458
  const useCssVar = (prop, target, defaultValue, options = defaultOptions)=>{
454
459
  const { observe } = options;
455
460
  const [variable, setVariable] = React.useState(getInitialState$3(defaultValue));
@@ -493,8 +498,8 @@ const useCssVar = (prop, target, defaultValue, options = defaultOptions)=>{
493
498
  observerRef.current = new MutationObserver(updateCssVar);
494
499
  observerRef.current.observe(element, {
495
500
  attributeFilter: [
496
- "style",
497
- "class"
501
+ 'style',
502
+ 'class'
498
503
  ]
499
504
  });
500
505
  return ()=>{
@@ -537,12 +542,12 @@ const useCycleList = (list, i = 0)=>{
537
542
  };
538
543
 
539
544
  function guessSerializerType(rawInit) {
540
- return rawInit == null || rawInit === undefined ? "any" : rawInit instanceof Set ? "set" : rawInit instanceof Map ? "map" : rawInit instanceof Date ? "date" : typeof rawInit === "boolean" ? "boolean" : typeof rawInit === "string" ? "string" : typeof rawInit === "object" ? "object" : Array.isArray(rawInit) ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
545
+ return rawInit == null || rawInit === undefined ? 'any' : rawInit instanceof Set ? 'set' : rawInit instanceof Map ? 'map' : rawInit instanceof Date ? 'date' : typeof rawInit === 'boolean' ? 'boolean' : typeof rawInit === 'string' ? 'string' : typeof rawInit === 'object' ? 'object' : Array.isArray(rawInit) ? 'object' : !Number.isNaN(rawInit) ? 'number' : 'any';
541
546
  }
542
547
 
543
548
  const StorageSerializers = {
544
549
  boolean: {
545
- read: (v)=>v === "true",
550
+ read: (v)=>v === 'true',
546
551
  write: (v)=>String(v)
547
552
  },
548
553
  object: {
@@ -574,7 +579,7 @@ const StorageSerializers = {
574
579
  write: (v)=>v.toISOString()
575
580
  }
576
581
  };
577
- const getInitialState$2 = (key, defaultValue, storage, serializer, onError)=>{
582
+ function getInitialState$2(key, defaultValue, storage, serializer, onError) {
578
583
  // Prevent a React hydration mismatch when a default value is provided.
579
584
  if (defaultValue !== undefined) {
580
585
  return defaultValue;
@@ -591,11 +596,11 @@ const getInitialState$2 = (key, defaultValue, storage, serializer, onError)=>{
591
596
  }
592
597
  }
593
598
  // A default value has not been provided, and you are rendering on the server, warn of a possible hydration mismatch when defaulting to false.
594
- if (process.env.NODE_ENV !== "production") {
595
- console.warn("`createStorage` When server side rendering, defaultValue should be defined to prevent a hydration mismatches.");
599
+ if (process.env.NODE_ENV !== 'production') {
600
+ console.warn('`createStorage` When server side rendering, defaultValue should be defined to prevent a hydration mismatches.');
596
601
  }
597
602
  return null;
598
- };
603
+ }
599
604
  function useStorage(key, defaultValue, getStorage = ()=>isBrowser ? sessionStorage : undefined, options = defaultOptions$1) {
600
605
  let storage;
601
606
  const { onError = defaultOnError, effectStorageValue } = options;
@@ -652,9 +657,9 @@ function useStorage(key, defaultValue, getStorage = ()=>isBrowser ? sessionStora
652
657
  }
653
658
 
654
659
  const useDarkMode = (options)=>{
655
- const { selector = "html", attribute = "class", classNameDark = "", classNameLight = "", storageKey = "reactuses-color-scheme", storage = ()=>isBrowser ? localStorage : undefined, defaultValue = false } = options;
660
+ const { selector = 'html', attribute = 'class', classNameDark = '', classNameLight = '', storageKey = 'reactuses-color-scheme', storage = ()=>isBrowser ? localStorage : undefined, defaultValue = false } = options;
656
661
  const value = ()=>{
657
- return window.matchMedia("(prefers-color-scheme: dark)").matches;
662
+ return window.matchMedia('(prefers-color-scheme: dark)').matches;
658
663
  };
659
664
  const [dark, setDark] = useStorage(storageKey, defaultValue, storage, {
660
665
  effectStorageValue: value
@@ -665,7 +670,7 @@ const useDarkMode = (options)=>{
665
670
  if (!element) {
666
671
  return;
667
672
  }
668
- if (attribute === "class") {
673
+ if (attribute === 'class') {
669
674
  dark && classNameDark && element.classList.add(classNameDark);
670
675
  !dark && classNameLight && element.classList.add(classNameLight);
671
676
  } else {
@@ -676,7 +681,7 @@ const useDarkMode = (options)=>{
676
681
  if (!element) {
677
682
  return;
678
683
  }
679
- if (attribute === "class") {
684
+ if (attribute === 'class') {
680
685
  dark && classNameDark && element.classList.remove(classNameDark);
681
686
  !dark && classNameLight && element.classList.remove(classNameLight);
682
687
  } else {
@@ -698,7 +703,7 @@ const useDarkMode = (options)=>{
698
703
  ];
699
704
  };
700
705
 
701
- const useUnmount = (fn)=>{
706
+ function useUnmount(fn) {
702
707
  if (isDev) {
703
708
  if (!isFunction(fn)) {
704
709
  console.error(`useUnmount expected parameter is a function, got ${typeof fn}`);
@@ -710,7 +715,7 @@ const useUnmount = (fn)=>{
710
715
  }, [
711
716
  fnRef
712
717
  ]);
713
- };
718
+ }
714
719
 
715
720
  const useDebounceFn = (fn, wait, options)=>{
716
721
  if (isDev) {
@@ -750,7 +755,7 @@ const useDebounce = (value, wait, options)=>{
750
755
  return debounced;
751
756
  };
752
757
 
753
- const getInitialState$1 = (defaultValue)=>{
758
+ function getInitialState$1(defaultValue) {
754
759
  // Prevent a React hydration mismatch when a default value is provided.
755
760
  if (defaultValue !== undefined) {
756
761
  return defaultValue;
@@ -758,28 +763,28 @@ const getInitialState$1 = (defaultValue)=>{
758
763
  if (isBrowser) {
759
764
  return document.visibilityState;
760
765
  }
761
- if (process.env.NODE_ENV !== "production") {
762
- console.warn("`useDocumentVisibility` When server side rendering, defaultValue should be defined to prevent a hydration mismatches.");
766
+ if (process.env.NODE_ENV !== 'production') {
767
+ console.warn('`useDocumentVisibility` When server side rendering, defaultValue should be defined to prevent a hydration mismatches.');
763
768
  }
764
- return "visible";
765
- };
766
- const useDocumentVisibility = (defaultValue)=>{
769
+ return 'visible';
770
+ }
771
+ function useDocumentVisibility(defaultValue) {
767
772
  const [visible, setVisible] = React.useState(getInitialState$1(defaultValue));
768
- useEventListener("visibilitychange", ()=>{
773
+ useEventListener('visibilitychange', ()=>{
769
774
  setVisible(document.visibilityState);
770
775
  }, ()=>document);
771
776
  React.useEffect(()=>{
772
777
  setVisible(document.visibilityState);
773
778
  }, []);
774
779
  return visible;
775
- };
780
+ }
776
781
 
777
782
  const useDoubleClick = ({ target, latency = 300, onSingleClick = ()=>{}, onDoubleClick = ()=>{} })=>{
778
783
  const handle = React.useCallback((onSingleClick, onDoubleClick)=>{
779
784
  let count = 0;
780
785
  return (e)=>{
781
786
  // prevent ios double click slide
782
- if (e.type === "touchend") {
787
+ if (e.type === 'touchend') {
783
788
  e.stopPropagation();
784
789
  e.preventDefault();
785
790
  }
@@ -798,24 +803,24 @@ const useDoubleClick = ({ target, latency = 300, onSingleClick = ()=>{}, onDoubl
798
803
  ]);
799
804
  const handleClick = handle(onSingleClick, onDoubleClick);
800
805
  const handleTouchEnd = handle(onSingleClick, onDoubleClick);
801
- useEventListener("click", handleClick, target);
802
- useEventListener("touchend", handleTouchEnd, target, {
806
+ useEventListener('click', handleClick, target);
807
+ useEventListener('touchend', handleTouchEnd, target, {
803
808
  passive: false
804
809
  });
805
810
  };
806
811
 
807
- const isScrollX = (node)=>{
812
+ function isScrollX(node) {
808
813
  if (!node) {
809
814
  return false;
810
815
  }
811
- return getComputedStyle(node).overflowX === "auto" || getComputedStyle(node).overflowX === "scroll";
812
- };
813
- const isScrollY = (node)=>{
816
+ return getComputedStyle(node).overflowX === 'auto' || getComputedStyle(node).overflowX === 'scroll';
817
+ }
818
+ function isScrollY(node) {
814
819
  if (!node) {
815
820
  return false;
816
821
  }
817
- return getComputedStyle(node).overflowY === "auto" || getComputedStyle(node).overflowY === "scroll";
818
- };
822
+ return getComputedStyle(node).overflowY === 'auto' || getComputedStyle(node).overflowY === 'scroll';
823
+ }
819
824
  const useDraggable = (target, options = {})=>{
820
825
  const { draggingElement, containerElement } = options;
821
826
  var _options_handle;
@@ -908,9 +913,9 @@ const useDraggable = (target, options = {})=>{
908
913
  options.onEnd == null ? void 0 : options.onEnd.call(options, position, e);
909
914
  handleEvent(e);
910
915
  };
911
- useEventListener("pointerdown", start, draggingHandle, true);
912
- useEventListener("pointermove", move, draggingElement, true);
913
- useEventListener("pointerup", end, draggingElement, true);
916
+ useEventListener('pointerdown', start, draggingHandle, true);
917
+ useEventListener('pointermove', move, draggingElement, true);
918
+ useEventListener('pointerup', end, draggingElement, true);
914
919
  return [
915
920
  position.x,
916
921
  position.y,
@@ -922,22 +927,22 @@ const useDraggable = (target, options = {})=>{
922
927
  const useDropZone = (target, onDrop)=>{
923
928
  const [over, setOver] = React.useState(false);
924
929
  const counter = React.useRef(0);
925
- useEventListener("dragenter", (event)=>{
930
+ useEventListener('dragenter', (event)=>{
926
931
  event.preventDefault();
927
932
  counter.current += 1;
928
933
  setOver(true);
929
934
  }, target);
930
- useEventListener("dragover", (event)=>{
935
+ useEventListener('dragover', (event)=>{
931
936
  event.preventDefault();
932
937
  }, target);
933
- useEventListener("dragleave", (event)=>{
938
+ useEventListener('dragleave', (event)=>{
934
939
  event.preventDefault();
935
940
  counter.current -= 1;
936
941
  if (counter.current === 0) {
937
942
  setOver(false);
938
943
  }
939
944
  }, target);
940
- useEventListener("drop", (event)=>{
945
+ useEventListener('drop', (event)=>{
941
946
  var _event_dataTransfer;
942
947
  event.preventDefault();
943
948
  counter.current = 0;
@@ -1020,21 +1025,21 @@ const useElementBounding = (target, options = defaultOptions$1)=>{
1020
1025
  ]);
1021
1026
  React.useEffect(()=>{
1022
1027
  if (windowScroll) {
1023
- window.addEventListener("scroll", update, {
1028
+ window.addEventListener('scroll', update, {
1024
1029
  passive: true
1025
1030
  });
1026
1031
  }
1027
1032
  if (windowResize) {
1028
- window.addEventListener("resize", update, {
1033
+ window.addEventListener('resize', update, {
1029
1034
  passive: true
1030
1035
  });
1031
1036
  }
1032
1037
  return ()=>{
1033
1038
  if (windowScroll) {
1034
- window.removeEventListener("scroll", update);
1039
+ window.removeEventListener('scroll', update);
1035
1040
  }
1036
1041
  if (windowResize) {
1037
- window.removeEventListener("resize", update);
1042
+ window.removeEventListener('resize', update);
1038
1043
  }
1039
1044
  };
1040
1045
  }, [
@@ -1056,11 +1061,11 @@ const useElementBounding = (target, options = defaultOptions$1)=>{
1056
1061
  };
1057
1062
 
1058
1063
  const useElementSize = (target, options = defaultOptions$1)=>{
1059
- const { box = "content-box" } = options;
1064
+ const { box = 'content-box' } = options;
1060
1065
  const [width, setWidth] = React.useState(0);
1061
1066
  const [height, setHeight] = React.useState(0);
1062
1067
  useResizeObserver(target, ([entry])=>{
1063
- const boxSize = box === "border-box" ? entry.borderBoxSize : box === "content-box" ? entry.contentBoxSize : entry.devicePixelContentBoxSize;
1068
+ const boxSize = box === 'border-box' ? entry.borderBoxSize : box === 'content-box' ? entry.contentBoxSize : entry.devicePixelContentBoxSize;
1064
1069
  if (boxSize) {
1065
1070
  setWidth(boxSize.reduce((acc, { inlineSize })=>acc + inlineSize, 0));
1066
1071
  setHeight(boxSize.reduce((acc, { blockSize })=>acc + blockSize, 0));
@@ -1111,7 +1116,7 @@ const useElementVisibility = (target, options = defaultOptions$1)=>{
1111
1116
  ];
1112
1117
  };
1113
1118
 
1114
- const useEventEmitter = ()=>{
1119
+ function useEventEmitter() {
1115
1120
  const listeners = React.useRef([]);
1116
1121
  const _disposed = React.useRef(false);
1117
1122
  const _event = React.useRef((listener)=>{
@@ -1150,16 +1155,16 @@ const useEventEmitter = ()=>{
1150
1155
  fire,
1151
1156
  dispose
1152
1157
  ];
1153
- };
1158
+ }
1154
1159
 
1155
- const useSupported = (callback, sync = false)=>{
1160
+ function useSupported(callback, sync = false) {
1156
1161
  const [supported, setSupported] = React.useState(false);
1157
1162
  const effect = sync ? useIsomorphicLayoutEffect : React.useEffect;
1158
1163
  effect(()=>{
1159
1164
  setSupported(Boolean(callback()));
1160
1165
  }, []);
1161
1166
  return supported;
1162
- };
1167
+ }
1163
1168
 
1164
1169
  function asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, key, arg) {
1165
1170
  try {
@@ -1191,11 +1196,11 @@ function _async_to_generator$5(fn) {
1191
1196
  };
1192
1197
  }
1193
1198
  const useEyeDropper = ()=>{
1194
- const isSupported = useSupported(()=>typeof window !== "undefined" && "EyeDropper" in window, true);
1199
+ const isSupported = useSupported(()=>typeof window !== 'undefined' && 'EyeDropper' in window, true);
1195
1200
  const open = React.useCallback(/*#__PURE__*/ _async_to_generator$5(function*(options = {}) {
1196
1201
  if (!isSupported) {
1197
1202
  return {
1198
- sRGBHex: ""
1203
+ sRGBHex: ''
1199
1204
  };
1200
1205
  }
1201
1206
  const eyeDropper = new window.EyeDropper();
@@ -1209,23 +1214,23 @@ const useEyeDropper = ()=>{
1209
1214
  ];
1210
1215
  };
1211
1216
 
1212
- const useFavicon = (href, baseUrl = "", rel = "icon")=>{
1217
+ function useFavicon(href, baseUrl = '', rel = 'icon') {
1213
1218
  React.useEffect(()=>{
1214
1219
  const url = `${baseUrl}${href}`;
1215
1220
  const element = document.head.querySelectorAll(`link[rel*="${rel}"]`);
1216
1221
  element.forEach((el)=>el.href = url);
1217
1222
  if (element.length === 0) {
1218
- const link = document.createElement("link");
1223
+ const link = document.createElement('link');
1219
1224
  link.rel = rel;
1220
1225
  link.href = url;
1221
- document.getElementsByTagName("head")[0].appendChild(link);
1226
+ document.getElementsByTagName('head')[0].appendChild(link);
1222
1227
  }
1223
1228
  }, [
1224
1229
  baseUrl,
1225
1230
  href,
1226
1231
  rel
1227
1232
  ]);
1228
- };
1233
+ }
1229
1234
 
1230
1235
  function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
1231
1236
  try {
@@ -1272,7 +1277,7 @@ function _extends$2() {
1272
1277
  }
1273
1278
  const DEFAULT_OPTIONS = {
1274
1279
  multiple: true,
1275
- accept: "*"
1280
+ accept: '*'
1276
1281
  };
1277
1282
  const useFileDialog = (options = defaultOptions$1)=>{
1278
1283
  const [files, setFiles] = React.useState(null);
@@ -1280,11 +1285,11 @@ const useFileDialog = (options = defaultOptions$1)=>{
1280
1285
  const fileOpenPromiseRef = React.useRef(null);
1281
1286
  const resolveFileOpenPromiseRef = React.useRef();
1282
1287
  const initFn = React.useCallback(()=>{
1283
- if (typeof document === "undefined") {
1288
+ if (typeof document === 'undefined') {
1284
1289
  return undefined;
1285
1290
  }
1286
- const input = document.createElement("input");
1287
- input.type = "file";
1291
+ const input = document.createElement('input');
1292
+ input.type = 'file';
1288
1293
  input.onchange = (event)=>{
1289
1294
  const result = event.target;
1290
1295
  setFiles(result.files);
@@ -1311,7 +1316,7 @@ const useFileDialog = (options = defaultOptions$1)=>{
1311
1316
  setFiles(null);
1312
1317
  resolveFileOpenPromiseRef.current == null ? void 0 : resolveFileOpenPromiseRef.current.call(resolveFileOpenPromiseRef, null);
1313
1318
  if (inputRef.current) {
1314
- inputRef.current.value = "";
1319
+ inputRef.current.value = '';
1315
1320
  }
1316
1321
  };
1317
1322
  return [
@@ -1344,8 +1349,8 @@ const useMount = (fn)=>{
1344
1349
 
1345
1350
  const useFocus = (target, initialValue = false)=>{
1346
1351
  const [focus, innerSetFocus] = React.useState(initialValue);
1347
- useEventListener("focus", ()=>innerSetFocus(true), target);
1348
- useEventListener("blur", ()=>innerSetFocus(false), target);
1352
+ useEventListener('focus', ()=>innerSetFocus(true), target);
1353
+ useEventListener('blur', ()=>innerSetFocus(false), target);
1349
1354
  const setFocus = (value)=>{
1350
1355
  const element = getTargetElement(target);
1351
1356
  if (!element) {
@@ -1409,7 +1414,7 @@ const useRafFn = (callback, initiallyActive = true)=>{
1409
1414
  return result;
1410
1415
  };
1411
1416
 
1412
- const useFps = (options = defaultOptions$1)=>{
1417
+ function useFps(options = defaultOptions$1) {
1413
1418
  const [fps, setFps] = React.useState(0);
1414
1419
  var _options_every;
1415
1420
  const every = (_options_every = options.every) != null ? _options_every : 10;
@@ -1426,7 +1431,7 @@ const useFps = (options = defaultOptions$1)=>{
1426
1431
  }
1427
1432
  });
1428
1433
  return fps;
1429
- };
1434
+ }
1430
1435
 
1431
1436
  const useFullscreen = (target, options = defaultOptions$1)=>{
1432
1437
  const { onExit, onEnter } = options;
@@ -1437,7 +1442,7 @@ const useFullscreen = (target, options = defaultOptions$1)=>{
1437
1442
  if (isFullscreen) {
1438
1443
  onEnter == null ? void 0 : onEnter();
1439
1444
  } else {
1440
- screenfull__default.default.off("change", onChange);
1445
+ screenfull__default.default.off('change', onChange);
1441
1446
  onExit == null ? void 0 : onExit();
1442
1447
  }
1443
1448
  setState(isFullscreen);
@@ -1451,7 +1456,7 @@ const useFullscreen = (target, options = defaultOptions$1)=>{
1451
1456
  if (screenfull__default.default.isEnabled) {
1452
1457
  try {
1453
1458
  screenfull__default.default.request(el);
1454
- screenfull__default.default.on("change", onChange);
1459
+ screenfull__default.default.on('change', onChange);
1455
1460
  } catch (error) {
1456
1461
  console.error(error);
1457
1462
  }
@@ -1471,7 +1476,7 @@ const useFullscreen = (target, options = defaultOptions$1)=>{
1471
1476
  };
1472
1477
  useUnmount(()=>{
1473
1478
  if (screenfull__default.default.isEnabled) {
1474
- screenfull__default.default.off("change", onChange);
1479
+ screenfull__default.default.off('change', onChange);
1475
1480
  }
1476
1481
  });
1477
1482
  return [
@@ -1539,18 +1544,18 @@ const useHover = (target)=>{
1539
1544
  const [hovered, setHovered] = React.useState(false);
1540
1545
  const onMouseEnter = React.useCallback(()=>setHovered(true), []);
1541
1546
  const onMouseLeave = React.useCallback(()=>setHovered(false), []);
1542
- useEventListener("mouseenter", onMouseEnter, target);
1543
- useEventListener("mouseleave", onMouseLeave, target);
1547
+ useEventListener('mouseenter', onMouseEnter, target);
1548
+ useEventListener('mouseleave', onMouseLeave, target);
1544
1549
  return hovered;
1545
1550
  };
1546
1551
 
1547
1552
  const defaultEvents$1 = [
1548
- "mousemove",
1549
- "mousedown",
1550
- "resize",
1551
- "keydown",
1552
- "touchstart",
1553
- "wheel"
1553
+ 'mousemove',
1554
+ 'mousedown',
1555
+ 'resize',
1556
+ 'keydown',
1557
+ 'touchstart',
1558
+ 'wheel'
1554
1559
  ];
1555
1560
  const oneMinute = 60e3;
1556
1561
  const useIdle = (ms = oneMinute, initialState = false, events = defaultEvents$1)=>{
@@ -1580,14 +1585,14 @@ const useIdle = (ms = oneMinute, initialState = false, events = defaultEvents$1)
1580
1585
  for(let i = 0; i < events.length; i++){
1581
1586
  on(window, events[i], onEvent);
1582
1587
  }
1583
- on(document, "visibilitychange", onVisibility);
1588
+ on(document, 'visibilitychange', onVisibility);
1584
1589
  timeout = setTimeout(()=>set(true), ms);
1585
1590
  return ()=>{
1586
1591
  mounted = false;
1587
1592
  for(let i = 0; i < events.length; i++){
1588
1593
  off(window, events[i], onEvent);
1589
1594
  }
1590
- off(document, "visibilitychange", onVisibility);
1595
+ off(document, 'visibilitychange', onVisibility);
1591
1596
  };
1592
1597
  // eslint-disable-next-line react-hooks/exhaustive-deps
1593
1598
  }, [
@@ -1597,7 +1602,7 @@ const useIdle = (ms = oneMinute, initialState = false, events = defaultEvents$1)
1597
1602
  return state;
1598
1603
  };
1599
1604
 
1600
- const useThrottleFn = (fn, wait, options)=>{
1605
+ function useThrottleFn(fn, wait, options) {
1601
1606
  if (isDev) {
1602
1607
  if (!isFunction(fn)) {
1603
1608
  console.error(`useThrottleFn expected parameter is a function, got ${typeof fn}`);
@@ -1619,7 +1624,7 @@ const useThrottleFn = (fn, wait, options)=>{
1619
1624
  cancel: throttled.cancel,
1620
1625
  flush: throttled.flush
1621
1626
  };
1622
- };
1627
+ }
1623
1628
 
1624
1629
  /**
1625
1630
  * We have to check if the scroll amount is close enough to some threshold in order to
@@ -1688,7 +1693,7 @@ const useScroll = (target, options = defaultOptions$1)=>{
1688
1693
  onScroll(e);
1689
1694
  });
1690
1695
  const { run: throttleOnScroll } = useThrottleFn(onScrollHandler, throttle);
1691
- useEventListener("scroll", throttle ? throttleOnScroll : onScrollHandler, target, eventListenerOptions);
1696
+ useEventListener('scroll', throttle ? throttleOnScroll : onScrollHandler, target, eventListenerOptions);
1692
1697
  return [
1693
1698
  x,
1694
1699
  y,
@@ -1755,7 +1760,7 @@ function _extends$1() {
1755
1760
  const useInfiniteScroll = (target, onLoadMore, options = defaultOptions$1)=>{
1756
1761
  const savedLoadMore = useLatest(onLoadMore);
1757
1762
  var _options_direction;
1758
- const direction = (_options_direction = options.direction) != null ? _options_direction : "bottom";
1763
+ const direction = (_options_direction = options.direction) != null ? _options_direction : 'bottom';
1759
1764
  var _options_distance;
1760
1765
  const state = useScroll(target, _extends$1({}, options, {
1761
1766
  offset: _extends$1({
@@ -1788,10 +1793,10 @@ const useInfiniteScroll = (target, onLoadMore, options = defaultOptions$1)=>{
1788
1793
  };
1789
1794
 
1790
1795
  const defaultEvents = [
1791
- "mousedown",
1792
- "mouseup",
1793
- "keydown",
1794
- "keyup"
1796
+ 'mousedown',
1797
+ 'mouseup',
1798
+ 'keydown',
1799
+ 'keyup'
1795
1800
  ];
1796
1801
  const useKeyModifier = (modifier, options = defaultOptions$1)=>{
1797
1802
  const { events = defaultEvents, initial = false } = options;
@@ -1799,7 +1804,7 @@ const useKeyModifier = (modifier, options = defaultOptions$1)=>{
1799
1804
  useMount(()=>{
1800
1805
  events.forEach((listenEvent)=>{
1801
1806
  on(document, listenEvent, (evt)=>{
1802
- if (typeof evt.getModifierState === "function") {
1807
+ if (typeof evt.getModifierState === 'function') {
1803
1808
  setState(evt.getModifierState(modifier));
1804
1809
  }
1805
1810
  });
@@ -1807,7 +1812,7 @@ const useKeyModifier = (modifier, options = defaultOptions$1)=>{
1807
1812
  return ()=>{
1808
1813
  events.forEach((listenerEvent)=>{
1809
1814
  off(document, listenerEvent, (evt)=>{
1810
- if (typeof evt.getModifierState === "function") {
1815
+ if (typeof evt.getModifierState === 'function') {
1811
1816
  setState(evt.getModifierState(modifier));
1812
1817
  }
1813
1818
  });
@@ -1822,11 +1827,11 @@ function useLocalStorage(key, defaultValue, options = defaultOptions$1) {
1822
1827
  }
1823
1828
 
1824
1829
  function subscribe$1(callback) {
1825
- window.addEventListener("popstate", callback);
1826
- window.addEventListener("hashchange", callback);
1830
+ window.addEventListener('popstate', callback);
1831
+ window.addEventListener('hashchange', callback);
1827
1832
  return ()=>{
1828
- window.removeEventListener("popstate", callback);
1829
- window.removeEventListener("hashchange", callback);
1833
+ window.removeEventListener('popstate', callback);
1834
+ window.removeEventListener('hashchange', callback);
1830
1835
  };
1831
1836
  }
1832
1837
  const useLocationSelector = (selector, /**
@@ -1836,24 +1841,24 @@ const useLocationSelector = (selector, /**
1836
1841
  return index_js.useSyncExternalStore(subscribe$1, ()=>selector(location), ()=>fallback);
1837
1842
  };
1838
1843
 
1839
- const isTouchEvent = (ev)=>{
1840
- return "touches" in ev;
1841
- };
1842
- const preventDefault$1 = (ev)=>{
1844
+ function isTouchEvent(ev) {
1845
+ return 'touches' in ev;
1846
+ }
1847
+ function preventDefault$1(ev) {
1843
1848
  if (!isTouchEvent(ev)) {
1844
1849
  return;
1845
1850
  }
1846
1851
  if (ev.touches.length < 2 && ev.preventDefault) {
1847
1852
  ev.preventDefault();
1848
1853
  }
1849
- };
1854
+ }
1850
1855
  const useLongPress = (callback, { isPreventDefault = true, delay = 300 } = defaultOptions$1)=>{
1851
1856
  const timeout = React.useRef();
1852
1857
  const target = React.useRef();
1853
1858
  const start = React.useCallback((event)=>{
1854
1859
  // prevent ghost click on mobile devices
1855
1860
  if (isPreventDefault && event.target) {
1856
- on(event.target, "touchend", preventDefault$1, {
1861
+ on(event.target, 'touchend', preventDefault$1, {
1857
1862
  passive: false
1858
1863
  });
1859
1864
  target.current = event.target;
@@ -1868,7 +1873,7 @@ const useLongPress = (callback, { isPreventDefault = true, delay = 300 } = defau
1868
1873
  // clearTimeout and removeEventListener
1869
1874
  timeout.current && clearTimeout(timeout.current);
1870
1875
  if (isPreventDefault && target.current) {
1871
- off(target.current, "touchend", preventDefault$1);
1876
+ off(target.current, 'touchend', preventDefault$1);
1872
1877
  }
1873
1878
  }, [
1874
1879
  isPreventDefault
@@ -1982,12 +1987,12 @@ const useMediaDevices = (options = {})=>{
1982
1987
  let state;
1983
1988
  try {
1984
1989
  state = (yield navigator.permissions.query({
1985
- name: "camera"
1990
+ name: 'camera'
1986
1991
  })).state;
1987
1992
  } catch (error) {
1988
- state = "prompt";
1993
+ state = 'prompt';
1989
1994
  }
1990
- if (state !== "granted") {
1995
+ if (state !== 'granted') {
1991
1996
  stream.current = yield navigator.mediaDevices.getUserMedia(constraints);
1992
1997
  onChange();
1993
1998
  permissionGranted.current = true;
@@ -2007,10 +2012,10 @@ const useMediaDevices = (options = {})=>{
2007
2012
  if (requestPermissions) {
2008
2013
  ensurePermissions();
2009
2014
  }
2010
- on(navigator.mediaDevices, "devicechange", onChange);
2015
+ on(navigator.mediaDevices, 'devicechange', onChange);
2011
2016
  onChange();
2012
2017
  return ()=>{
2013
- off(navigator.mediaDevices, "devicechange", onChange);
2018
+ off(navigator.mediaDevices, 'devicechange', onChange);
2014
2019
  };
2015
2020
  }, [
2016
2021
  onChange,
@@ -2024,7 +2029,7 @@ const useMediaDevices = (options = {})=>{
2024
2029
  ];
2025
2030
  };
2026
2031
 
2027
- const getInitialState = (query, defaultState)=>{
2032
+ function getInitialState(query, defaultState) {
2028
2033
  // Prevent a React hydration mismatch when a default value is provided by not defaulting to window.matchMedia(query).matches.
2029
2034
  if (defaultState !== undefined) {
2030
2035
  return defaultState;
@@ -2033,11 +2038,11 @@ const getInitialState = (query, defaultState)=>{
2033
2038
  return window.matchMedia(query).matches;
2034
2039
  }
2035
2040
  // A default value has not been provided, and you are rendering on the server, warn of a possible hydration mismatch when defaulting to false.
2036
- if (process.env.NODE_ENV !== "production") {
2037
- console.warn("`useMediaQuery` When server side rendering, defaultState should be defined to prevent a hydration mismatches.");
2041
+ if (process.env.NODE_ENV !== 'production') {
2042
+ console.warn('`useMediaQuery` When server side rendering, defaultState should be defined to prevent a hydration mismatches.');
2038
2043
  }
2039
2044
  return false;
2040
- };
2045
+ }
2041
2046
  const useMediaQuery = (query, defaultState)=>{
2042
2047
  const [state, setState] = React.useState(getInitialState(query, defaultState));
2043
2048
  React.useEffect(()=>{
@@ -2049,16 +2054,16 @@ const useMediaQuery = (query, defaultState)=>{
2049
2054
  }
2050
2055
  setState(!!mql.matches);
2051
2056
  };
2052
- if ("addEventListener" in mql) {
2053
- mql.addEventListener("change", onChange);
2057
+ if ('addEventListener' in mql) {
2058
+ mql.addEventListener('change', onChange);
2054
2059
  } else {
2055
2060
  mql.addListener == null ? void 0 : mql.addListener.call(mql, onChange);
2056
2061
  }
2057
2062
  setState(mql.matches);
2058
2063
  return ()=>{
2059
2064
  mounted = false;
2060
- if ("removeEventListener" in mql) {
2061
- mql.removeEventListener("change", onChange);
2065
+ if ('removeEventListener' in mql) {
2066
+ mql.removeEventListener('change', onChange);
2062
2067
  } else {
2063
2068
  mql.removeListener == null ? void 0 : mql.removeListener.call(mql, onChange);
2064
2069
  }
@@ -2069,7 +2074,7 @@ const useMediaQuery = (query, defaultState)=>{
2069
2074
  return state;
2070
2075
  };
2071
2076
 
2072
- const useRafState = (initialState)=>{
2077
+ function useRafState(initialState) {
2073
2078
  const frame = React.useRef(0);
2074
2079
  const [state, setState] = React.useState(initialState);
2075
2080
  const setRafState = React.useCallback((value)=>{
@@ -2085,7 +2090,7 @@ const useRafState = (initialState)=>{
2085
2090
  state,
2086
2091
  setRafState
2087
2092
  ];
2088
- };
2093
+ }
2089
2094
 
2090
2095
  const initState = {
2091
2096
  screenX: Number.NaN,
@@ -2103,7 +2108,7 @@ const initState = {
2103
2108
  };
2104
2109
  const useMouse = (target)=>{
2105
2110
  const [state, setState] = useRafState(initState);
2106
- useEventListener("mousemove", (event)=>{
2111
+ useEventListener('mousemove', (event)=>{
2107
2112
  const { screenX, screenY, clientX, clientY, pageX, pageY } = event;
2108
2113
  const newState = {
2109
2114
  screenX,
@@ -2150,30 +2155,30 @@ const useMousePressed = (target, options = defaultOptions$1)=>{
2150
2155
  setPressed(false);
2151
2156
  setSourceType(null);
2152
2157
  }, []);
2153
- useEventListener("mousedown", onPressed("mouse"), target, listenerOptions$2);
2154
- useEventListener("mouseleave", onReleased, ()=>window, listenerOptions$2);
2155
- useEventListener("mouseup", onReleased, ()=>window, listenerOptions$2);
2158
+ useEventListener('mousedown', onPressed('mouse'), target, listenerOptions$2);
2159
+ useEventListener('mouseleave', onReleased, ()=>window, listenerOptions$2);
2160
+ useEventListener('mouseup', onReleased, ()=>window, listenerOptions$2);
2156
2161
  React.useEffect(()=>{
2157
2162
  if (drag) {
2158
- element == null ? void 0 : element.addEventListener("dragstart", onPressed("mouse"), listenerOptions$2);
2159
- element == null ? void 0 : element.addEventListener("drop", onReleased, listenerOptions$2);
2160
- element == null ? void 0 : element.addEventListener("dragend", onReleased, listenerOptions$2);
2163
+ element == null ? void 0 : element.addEventListener('dragstart', onPressed('mouse'), listenerOptions$2);
2164
+ element == null ? void 0 : element.addEventListener('drop', onReleased, listenerOptions$2);
2165
+ element == null ? void 0 : element.addEventListener('dragend', onReleased, listenerOptions$2);
2161
2166
  }
2162
2167
  if (touch) {
2163
- element == null ? void 0 : element.addEventListener("touchstart", onPressed("touch"), listenerOptions$2);
2164
- element == null ? void 0 : element.addEventListener("touchend", onReleased, listenerOptions$2);
2165
- element == null ? void 0 : element.addEventListener("touchcancel", onReleased, listenerOptions$2);
2168
+ element == null ? void 0 : element.addEventListener('touchstart', onPressed('touch'), listenerOptions$2);
2169
+ element == null ? void 0 : element.addEventListener('touchend', onReleased, listenerOptions$2);
2170
+ element == null ? void 0 : element.addEventListener('touchcancel', onReleased, listenerOptions$2);
2166
2171
  }
2167
2172
  return ()=>{
2168
2173
  if (drag) {
2169
- element == null ? void 0 : element.removeEventListener("dragstart", onPressed("mouse"));
2170
- element == null ? void 0 : element.removeEventListener("drop", onReleased);
2171
- element == null ? void 0 : element.removeEventListener("dragend", onReleased);
2174
+ element == null ? void 0 : element.removeEventListener('dragstart', onPressed('mouse'));
2175
+ element == null ? void 0 : element.removeEventListener('drop', onReleased);
2176
+ element == null ? void 0 : element.removeEventListener('dragend', onReleased);
2172
2177
  }
2173
2178
  if (touch) {
2174
- element == null ? void 0 : element.removeEventListener("touchstart", onPressed("touch"));
2175
- element == null ? void 0 : element.removeEventListener("touchend", onReleased);
2176
- element == null ? void 0 : element.removeEventListener("touchcancel", onReleased);
2179
+ element == null ? void 0 : element.removeEventListener('touchstart', onPressed('touch'));
2180
+ element == null ? void 0 : element.removeEventListener('touchend', onReleased);
2181
+ element == null ? void 0 : element.removeEventListener('touchcancel', onReleased);
2177
2182
  }
2178
2183
  };
2179
2184
  }, [
@@ -2234,22 +2239,22 @@ const useNetwork = ()=>{
2234
2239
  const handleStateChange = ()=>{
2235
2240
  setState(getConnectionState);
2236
2241
  };
2237
- on(window, "online", handleStateChange, {
2242
+ on(window, 'online', handleStateChange, {
2238
2243
  passive: true
2239
2244
  });
2240
- on(window, "offline", handleStateChange, {
2245
+ on(window, 'offline', handleStateChange, {
2241
2246
  passive: true
2242
2247
  });
2243
2248
  if (conn) {
2244
- on(conn, "change", handleStateChange, {
2249
+ on(conn, 'change', handleStateChange, {
2245
2250
  passive: true
2246
2251
  });
2247
2252
  }
2248
2253
  return ()=>{
2249
- off(window, "online", handleStateChange);
2250
- off(window, "offline", handleStateChange);
2254
+ off(window, 'online', handleStateChange);
2255
+ off(window, 'offline', handleStateChange);
2251
2256
  if (conn) {
2252
- off(conn, "change", handleStateChange);
2257
+ off(conn, 'change', handleStateChange);
2253
2258
  }
2254
2259
  };
2255
2260
  }, []);
@@ -2299,7 +2304,7 @@ const useOnline = ()=>{
2299
2304
 
2300
2305
  const defaultState = {
2301
2306
  angle: 0,
2302
- type: "landscape-primary"
2307
+ type: 'landscape-primary'
2303
2308
  };
2304
2309
  const useOrientation = (initialState = defaultState)=>{
2305
2310
  const [state, setState] = React.useState(initialState);
@@ -2317,25 +2322,25 @@ const useOrientation = (initialState = defaultState)=>{
2317
2322
  });
2318
2323
  } else if (window.orientation !== undefined) {
2319
2324
  setState({
2320
- angle: typeof window.orientation === "number" ? window.orientation : 0,
2325
+ angle: typeof window.orientation === 'number' ? window.orientation : 0,
2321
2326
  type: void 0
2322
2327
  });
2323
2328
  }
2324
2329
  }
2325
2330
  };
2326
- on(window, "orientationchange", onChange);
2331
+ on(window, 'orientationchange', onChange);
2327
2332
  onChange();
2328
2333
  return ()=>{
2329
2334
  mounted = false;
2330
- off(window, "orientationchange", onChange);
2335
+ off(window, 'orientationchange', onChange);
2331
2336
  };
2332
2337
  }, []);
2333
2338
  const lockOrientation = (type)=>{
2334
2339
  if (isBrowser) {
2335
2340
  return;
2336
2341
  }
2337
- if (!(window && "screen" in window && "orientation" in window.screen)) {
2338
- return Promise.reject(new Error("Not supported"));
2342
+ if (!(window && 'screen' in window && 'orientation' in window.screen)) {
2343
+ return Promise.reject(new Error('Not supported'));
2339
2344
  }
2340
2345
  return window.screen.orientation.lock(type);
2341
2346
  };
@@ -2343,7 +2348,7 @@ const useOrientation = (initialState = defaultState)=>{
2343
2348
  if (isBrowser) {
2344
2349
  return;
2345
2350
  }
2346
- if (!(window && "screen" in window && "orientation" in window.screen)) {
2351
+ if (!(window && 'screen' in window && 'orientation' in window.screen)) {
2347
2352
  return;
2348
2353
  }
2349
2354
  return window.screen.orientation.unlock();
@@ -2355,7 +2360,7 @@ const useOrientation = (initialState = defaultState)=>{
2355
2360
  ];
2356
2361
  };
2357
2362
 
2358
- const usePageLeave = ()=>{
2363
+ function usePageLeave() {
2359
2364
  const [isLeft, setIsLeft] = React.useState(false);
2360
2365
  const handler = (event)=>{
2361
2366
  if (!window) return;
@@ -2364,23 +2369,23 @@ const usePageLeave = ()=>{
2364
2369
  const from = event.relatedTarget || event.toElement;
2365
2370
  setIsLeft(!from);
2366
2371
  };
2367
- useEventListener("mouseout", handler, ()=>window, {
2372
+ useEventListener('mouseout', handler, ()=>window, {
2368
2373
  passive: true
2369
2374
  });
2370
- useEventListener("mouseleave", handler, ()=>document, {
2375
+ useEventListener('mouseleave', handler, ()=>document, {
2371
2376
  passive: true
2372
2377
  });
2373
- useEventListener("mouseenter", handler, ()=>document, {
2378
+ useEventListener('mouseenter', handler, ()=>document, {
2374
2379
  passive: true
2375
2380
  });
2376
2381
  return isLeft;
2377
- };
2382
+ }
2378
2383
 
2379
2384
  const usePermission = (permissionDesc)=>{
2380
- const [state, setState] = React.useState("");
2385
+ const [state, setState] = React.useState('');
2381
2386
  React.useEffect(()=>{
2382
2387
  var _navigator_permissions;
2383
- const desc = typeof permissionDesc === "string" ? {
2388
+ const desc = typeof permissionDesc === 'string' ? {
2384
2389
  name: permissionDesc
2385
2390
  } : permissionDesc;
2386
2391
  let mounted = true;
@@ -2391,16 +2396,16 @@ const usePermission = (permissionDesc)=>{
2391
2396
  }
2392
2397
  setState(()=>{
2393
2398
  var _permissionStatus_state;
2394
- return (_permissionStatus_state = permissionStatus == null ? void 0 : permissionStatus.state) != null ? _permissionStatus_state : "";
2399
+ return (_permissionStatus_state = permissionStatus == null ? void 0 : permissionStatus.state) != null ? _permissionStatus_state : '';
2395
2400
  });
2396
2401
  };
2397
2402
  (_navigator_permissions = navigator.permissions) == null ? void 0 : _navigator_permissions.query(desc).then((status)=>{
2398
2403
  permissionStatus = status;
2399
- on(permissionStatus, "change", onChange);
2404
+ on(permissionStatus, 'change', onChange);
2400
2405
  onChange();
2401
2406
  }).catch(noop);
2402
2407
  return ()=>{
2403
- permissionStatus && off(permissionStatus, "change", onChange);
2408
+ permissionStatus && off(permissionStatus, 'change', onChange);
2404
2409
  mounted = false;
2405
2410
  permissionStatus = null;
2406
2411
  };
@@ -2410,56 +2415,56 @@ const usePermission = (permissionDesc)=>{
2410
2415
  return state;
2411
2416
  };
2412
2417
 
2413
- const usePreferredColorScheme = (defaultState = "no-preference")=>{
2414
- const isLight = useMediaQuery("(prefers-color-scheme: light)", false);
2415
- const isDark = useMediaQuery("(prefers-color-scheme: dark)", false);
2416
- return isDark ? "dark" : isLight ? "light" : defaultState;
2418
+ const usePreferredColorScheme = (defaultState = 'no-preference')=>{
2419
+ const isLight = useMediaQuery('(prefers-color-scheme: light)', false);
2420
+ const isDark = useMediaQuery('(prefers-color-scheme: dark)', false);
2421
+ return isDark ? 'dark' : isLight ? 'light' : defaultState;
2417
2422
  };
2418
2423
 
2419
- const usePreferredContrast = (defaultState = "no-preference")=>{
2420
- const isMore = useMediaQuery("(prefexrs-contrast: more)", false);
2421
- const isLess = useMediaQuery("(prefers-contrast: less)", false);
2422
- const isCustom = useMediaQuery("(prefers-contrast: custom)", false);
2423
- return isMore ? "more" : isLess ? "less" : isCustom ? "custom" : defaultState;
2424
+ const usePreferredContrast = (defaultState = 'no-preference')=>{
2425
+ const isMore = useMediaQuery('(prefexrs-contrast: more)', false);
2426
+ const isLess = useMediaQuery('(prefers-contrast: less)', false);
2427
+ const isCustom = useMediaQuery('(prefers-contrast: custom)', false);
2428
+ return isMore ? 'more' : isLess ? 'less' : isCustom ? 'custom' : defaultState;
2424
2429
  };
2425
2430
 
2426
- const usePreferredDark = (defaultState)=>{
2427
- return useMediaQuery("(prefers-color-scheme: dark)", defaultState);
2428
- };
2431
+ function usePreferredDark(defaultState) {
2432
+ return useMediaQuery('(prefers-color-scheme: dark)', defaultState);
2433
+ }
2429
2434
 
2430
- const usePrevious = (state)=>{
2435
+ function usePrevious(state) {
2431
2436
  const ref = React.useRef();
2432
2437
  React.useEffect(()=>{
2433
2438
  ref.current = state;
2434
2439
  });
2435
2440
  return ref.current;
2436
- };
2441
+ }
2437
2442
 
2438
- const useReducedMotion = (defaultState)=>{
2439
- return useMediaQuery("(prefers-reduced-motion: reduce)", defaultState);
2440
- };
2443
+ function useReducedMotion(defaultState) {
2444
+ return useMediaQuery('(prefers-reduced-motion: reduce)', defaultState);
2445
+ }
2441
2446
 
2442
2447
  const updateReducer = (num)=>(num + 1) % 1000000;
2443
- const useUpdate = ()=>{
2448
+ function useUpdate() {
2444
2449
  const [, update] = React.useReducer(updateReducer, 0);
2445
2450
  return update;
2446
- };
2451
+ }
2447
2452
 
2448
- const topVarName = "--reactuse-safe-area-top";
2449
- const rightVarName = "--reactuse-safe-area-right";
2450
- const bottomVarName = "--reactuse-safe-area-bottom";
2451
- const leftVarName = "--reactuse-safe-area-left";
2453
+ const topVarName = '--reactuse-safe-area-top';
2454
+ const rightVarName = '--reactuse-safe-area-right';
2455
+ const bottomVarName = '--reactuse-safe-area-bottom';
2456
+ const leftVarName = '--reactuse-safe-area-left';
2452
2457
  const defaultElement = ()=>document.documentElement;
2453
- const useScreenSafeArea = ()=>{
2454
- const top = React.useRef("");
2455
- const right = React.useRef("");
2456
- const bottom = React.useRef("");
2457
- const left = React.useRef("");
2458
+ function useScreenSafeArea() {
2459
+ const top = React.useRef('');
2460
+ const right = React.useRef('');
2461
+ const bottom = React.useRef('');
2462
+ const left = React.useRef('');
2458
2463
  const forceUpdate = useUpdate();
2459
- useCssVar(topVarName, defaultElement, "env(safe-area-inset-top, 0px)");
2460
- useCssVar(rightVarName, defaultElement, "env(safe-area-inset-right, 0px)");
2461
- useCssVar(bottomVarName, defaultElement, "env(safe-area-inset-bottom, 0px)");
2462
- useCssVar(leftVarName, defaultElement, "env(safe-area-inset-left, 0px)");
2464
+ useCssVar(topVarName, defaultElement, 'env(safe-area-inset-top, 0px)');
2465
+ useCssVar(rightVarName, defaultElement, 'env(safe-area-inset-right, 0px)');
2466
+ useCssVar(bottomVarName, defaultElement, 'env(safe-area-inset-bottom, 0px)');
2467
+ useCssVar(leftVarName, defaultElement, 'env(safe-area-inset-left, 0px)');
2463
2468
  const { run: update } = useDebounceFn(()=>{
2464
2469
  top.current = getValue(topVarName);
2465
2470
  right.current = getValue(rightVarName);
@@ -2472,7 +2477,7 @@ const useScreenSafeArea = ()=>{
2472
2477
  }, [
2473
2478
  update
2474
2479
  ]);
2475
- useEventListener("resize", update);
2480
+ useEventListener('resize', update);
2476
2481
  return [
2477
2482
  top.current,
2478
2483
  right.current,
@@ -2480,16 +2485,16 @@ const useScreenSafeArea = ()=>{
2480
2485
  left.current,
2481
2486
  update
2482
2487
  ];
2483
- };
2488
+ }
2484
2489
  function getValue(position) {
2485
2490
  return getComputedStyle(document.documentElement).getPropertyValue(position);
2486
2491
  }
2487
2492
 
2488
2493
  const useScriptTag = (src, onLoaded = noop, options = defaultOptions$1)=>{
2489
- const { immediate = true, manual = false, type = "text/javascript", async = true, crossOrigin, referrerPolicy, noModule, defer, attrs = {} } = options;
2494
+ const { immediate = true, manual = false, type = 'text/javascript', async = true, crossOrigin, referrerPolicy, noModule, defer, attrs = {} } = options;
2490
2495
  const scriptTag = React.useRef(null);
2491
2496
  const _promise = React.useRef(null);
2492
- const [status, setStatus] = React.useState(src ? "loading" : "idle");
2497
+ const [status, setStatus] = React.useState(src ? 'loading' : 'idle');
2493
2498
  /**
2494
2499
  * Load the script specified via `src`.
2495
2500
  *
@@ -2508,7 +2513,7 @@ const useScriptTag = (src, onLoaded = noop, options = defaultOptions$1)=>{
2508
2513
  return;
2509
2514
  }
2510
2515
  if (!src) {
2511
- setStatus("idle");
2516
+ setStatus('idle');
2512
2517
  resolve(false);
2513
2518
  return;
2514
2519
  }
@@ -2517,7 +2522,7 @@ const useScriptTag = (src, onLoaded = noop, options = defaultOptions$1)=>{
2517
2522
  let el = document.querySelector(`script[src="${src}"]`);
2518
2523
  // Script tag not found, preparing the element for appending
2519
2524
  if (!el) {
2520
- el = document.createElement("script");
2525
+ el = document.createElement('script');
2521
2526
  el.type = type;
2522
2527
  el.async = async;
2523
2528
  el.src = src;
@@ -2537,22 +2542,22 @@ const useScriptTag = (src, onLoaded = noop, options = defaultOptions$1)=>{
2537
2542
  Object.entries(attrs).forEach(([name, value])=>el == null ? void 0 : el.setAttribute(name, value));
2538
2543
  // Enables shouldAppend
2539
2544
  shouldAppend = true;
2540
- } else if (el.hasAttribute("data-loaded")) {
2541
- setStatus(el.getAttribute("data-status"));
2545
+ } else if (el.hasAttribute('data-loaded')) {
2546
+ setStatus(el.getAttribute('data-status'));
2542
2547
  resolveWithElement(el);
2543
2548
  }
2544
2549
  // Event listeners
2545
- el.addEventListener("error", (event)=>{
2546
- setStatus(event.type === "load" ? "ready" : "error");
2550
+ el.addEventListener('error', (event)=>{
2551
+ setStatus(event.type === 'load' ? 'ready' : 'error');
2547
2552
  return reject(event);
2548
2553
  });
2549
- el.addEventListener("abort", (event)=>{
2550
- setStatus(event.type === "load" ? "ready" : "error");
2554
+ el.addEventListener('abort', (event)=>{
2555
+ setStatus(event.type === 'load' ? 'ready' : 'error');
2551
2556
  return reject(event);
2552
2557
  });
2553
- el.addEventListener("load", (event)=>{
2554
- setStatus(event.type === "load" ? "ready" : "error");
2555
- el.setAttribute("data-loaded", "true");
2558
+ el.addEventListener('load', (event)=>{
2559
+ setStatus(event.type === 'load' ? 'ready' : 'error');
2560
+ el.setAttribute('data-loaded', 'true');
2556
2561
  onLoaded(el);
2557
2562
  resolveWithElement(el);
2558
2563
  });
@@ -2609,11 +2614,11 @@ const useScriptTag = (src, onLoaded = noop, options = defaultOptions$1)=>{
2609
2614
  ];
2610
2615
  };
2611
2616
 
2612
- const setScrollParam = ({ axis, parent, distance })=>{
2613
- if (!parent && typeof document === "undefined") {
2617
+ function setScrollParam({ axis, parent, distance }) {
2618
+ if (!parent && typeof document === 'undefined') {
2614
2619
  return;
2615
2620
  }
2616
- const method = axis === "y" ? "scrollTop" : "scrollLeft";
2621
+ const method = axis === 'y' ? 'scrollTop' : 'scrollLeft';
2617
2622
  if (parent) {
2618
2623
  parent[method] = distance;
2619
2624
  } else {
@@ -2621,16 +2626,16 @@ const setScrollParam = ({ axis, parent, distance })=>{
2621
2626
  body[method] = distance;
2622
2627
  documentElement[method] = distance;
2623
2628
  }
2624
- };
2625
- const isScrollElement = (axis, node)=>{
2629
+ }
2630
+ function isScrollElement(axis, node) {
2626
2631
  if (!node) {
2627
2632
  return false;
2628
2633
  }
2629
- const AXIS = axis === "x" ? "X" : "Y";
2630
- return getComputedStyle(node)[`overflow${AXIS}`] === "auto" || getComputedStyle(node)[`overflow${AXIS}`] === "scroll";
2631
- };
2634
+ const AXIS = axis === 'x' ? 'X' : 'Y';
2635
+ return getComputedStyle(node)[`overflow${AXIS}`] === 'auto' || getComputedStyle(node)[`overflow${AXIS}`] === 'scroll';
2636
+ }
2632
2637
  const cache = new Map();
2633
- const getScrollParent = (axis, node)=>{
2638
+ function getScrollParent(axis, node) {
2634
2639
  if (!node || !node.parentElement) {
2635
2640
  return null;
2636
2641
  }
@@ -2645,24 +2650,26 @@ const getScrollParent = (axis, node)=>{
2645
2650
  cache.set(node, parent);
2646
2651
  }
2647
2652
  return parent;
2648
- };
2649
- const getScrollStart = ({ axis, parent })=>{
2650
- if (!parent && typeof document === "undefined") {
2653
+ }
2654
+ function getScrollStart({ axis, parent }) {
2655
+ if (!parent && typeof document === 'undefined') {
2651
2656
  return 0;
2652
2657
  }
2653
- const method = axis === "y" ? "scrollTop" : "scrollLeft";
2658
+ const method = axis === 'y' ? 'scrollTop' : 'scrollLeft';
2654
2659
  if (parent) {
2655
2660
  return parent[method];
2656
2661
  }
2657
2662
  const { body, documentElement } = document;
2658
2663
  // while one of it has a value the second is equal 0
2659
2664
  return body[method] + documentElement[method];
2660
- };
2665
+ }
2661
2666
 
2662
- const easeInOutQuad = (t)=>t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
2667
+ function easeInOutQuad(t) {
2668
+ return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
2669
+ }
2663
2670
 
2664
- const getRelativePosition = ({ axis, target, parent, alignment, offset, isList })=>{
2665
- if (!target || !parent && typeof document === "undefined") {
2671
+ function getRelativePosition({ axis, target, parent, alignment, offset, isList }) {
2672
+ if (!target || !parent && typeof document === 'undefined') {
2666
2673
  return 0;
2667
2674
  }
2668
2675
  const isCustomParent = !!parent;
@@ -2670,55 +2677,55 @@ const getRelativePosition = ({ axis, target, parent, alignment, offset, isList }
2670
2677
  const parentPosition = parentElement.getBoundingClientRect();
2671
2678
  const targetPosition = target.getBoundingClientRect();
2672
2679
  const getDiff = (property)=>targetPosition[property] - parentPosition[property];
2673
- if (axis === "y") {
2674
- const diff = getDiff("top");
2680
+ if (axis === 'y') {
2681
+ const diff = getDiff('top');
2675
2682
  if (diff === 0) {
2676
2683
  return 0;
2677
2684
  }
2678
- if (alignment === "start") {
2685
+ if (alignment === 'start') {
2679
2686
  const distance = diff - offset;
2680
2687
  const shouldScroll = distance <= targetPosition.height * (isList ? 0 : 1) || !isList;
2681
2688
  return shouldScroll ? distance : 0;
2682
2689
  }
2683
2690
  const parentHeight = isCustomParent ? parentPosition.height : window.innerHeight;
2684
- if (alignment === "end") {
2691
+ if (alignment === 'end') {
2685
2692
  const distance = diff + offset - parentHeight + targetPosition.height;
2686
2693
  const shouldScroll = distance >= -targetPosition.height * (isList ? 0 : 1) || !isList;
2687
2694
  return shouldScroll ? distance : 0;
2688
2695
  }
2689
- if (alignment === "center") {
2696
+ if (alignment === 'center') {
2690
2697
  return diff - parentHeight / 2 + targetPosition.height / 2;
2691
2698
  }
2692
2699
  return 0;
2693
2700
  }
2694
- if (axis === "x") {
2695
- const diff = getDiff("left");
2701
+ if (axis === 'x') {
2702
+ const diff = getDiff('left');
2696
2703
  if (diff === 0) {
2697
2704
  return 0;
2698
2705
  }
2699
- if (alignment === "start") {
2706
+ if (alignment === 'start') {
2700
2707
  const distance = diff - offset;
2701
2708
  const shouldScroll = distance <= targetPosition.width || !isList;
2702
2709
  return shouldScroll ? distance : 0;
2703
2710
  }
2704
2711
  const parentWidth = isCustomParent ? parentPosition.width : window.innerWidth;
2705
- if (alignment === "end") {
2712
+ if (alignment === 'end') {
2706
2713
  const distance = diff + offset - parentWidth + targetPosition.width;
2707
2714
  const shouldScroll = distance >= -targetPosition.width || !isList;
2708
2715
  return shouldScroll ? distance : 0;
2709
2716
  }
2710
- if (alignment === "center") {
2717
+ if (alignment === 'center') {
2711
2718
  return diff - parentWidth / 2 + targetPosition.width / 2;
2712
2719
  }
2713
2720
  return 0;
2714
2721
  }
2715
2722
  return 0;
2716
- };
2723
+ }
2717
2724
 
2718
2725
  const listenerOptions$1 = {
2719
2726
  passive: true
2720
2727
  };
2721
- const useScrollIntoView = (targetElement, { duration = 1250, axis = "y", onScrollFinish, easing = easeInOutQuad, offset = 0, cancelable = true, isList = false } = defaultOptions$1, scrollElement)=>{
2728
+ const useScrollIntoView = (targetElement, { duration = 1250, axis = 'y', onScrollFinish, easing = easeInOutQuad, offset = 0, cancelable = true, isList = false } = defaultOptions$1, scrollElement)=>{
2722
2729
  const frameID = React.useRef(0);
2723
2730
  const startTime = React.useRef(0);
2724
2731
  const shouldStop = React.useRef(false);
@@ -2729,7 +2736,7 @@ const useScrollIntoView = (targetElement, { duration = 1250, axis = "y", onScrol
2729
2736
  }
2730
2737
  };
2731
2738
  const element = getTargetElement(targetElement);
2732
- const scrollIntoView = ({ alignment = "start" } = {})=>{
2739
+ const scrollIntoView = ({ alignment = 'start' } = {})=>{
2733
2740
  const parent = getTargetElement(scrollElement) || getScrollParent(axis, element);
2734
2741
  shouldStop.current = false;
2735
2742
  if (frameID.current) {
@@ -2765,7 +2772,7 @@ const useScrollIntoView = (targetElement, { duration = 1250, axis = "y", onScrol
2765
2772
  if (!shouldStop.current && t < 1) {
2766
2773
  frameID.current = requestAnimationFrame(animateScroll);
2767
2774
  } else {
2768
- typeof onScrollFinish === "function" && onScrollFinish();
2775
+ typeof onScrollFinish === 'function' && onScrollFinish();
2769
2776
  startTime.current = 0;
2770
2777
  frameID.current = 0;
2771
2778
  cancel();
@@ -2778,8 +2785,8 @@ const useScrollIntoView = (targetElement, { duration = 1250, axis = "y", onScrol
2778
2785
  shouldStop.current = true;
2779
2786
  }
2780
2787
  };
2781
- useEventListener("wheel", handleStop, null, listenerOptions$1);
2782
- useEventListener("touchmove", handleStop, null, listenerOptions$1);
2788
+ useEventListener('wheel', handleStop, null, listenerOptions$1);
2789
+ useEventListener('touchmove', handleStop, null, listenerOptions$1);
2783
2790
  React.useEffect(()=>cancel, []);
2784
2791
  return {
2785
2792
  scrollIntoView,
@@ -2800,13 +2807,13 @@ function preventDefault(rawEvent) {
2800
2807
  }
2801
2808
  const useScrollLock = (target, initialState = false)=>{
2802
2809
  const [locked, setLocked] = React.useState(initialState);
2803
- const initialOverflowRef = React.useRef("scroll");
2810
+ const initialOverflowRef = React.useRef('scroll');
2804
2811
  React.useEffect(()=>{
2805
2812
  const element = getTargetElement(target);
2806
2813
  if (element) {
2807
2814
  initialOverflowRef.current = element.style.overflow;
2808
2815
  if (locked) {
2809
- element.style.overflow = "hidden";
2816
+ element.style.overflow = 'hidden';
2810
2817
  }
2811
2818
  }
2812
2819
  }, [
@@ -2819,7 +2826,7 @@ const useScrollLock = (target, initialState = false)=>{
2819
2826
  return;
2820
2827
  }
2821
2828
  if (isIOS) {
2822
- element.addEventListener("touchmove", preventDefault, {
2829
+ element.addEventListener('touchmove', preventDefault, {
2823
2830
  passive: false
2824
2831
  });
2825
2832
  }
@@ -2831,7 +2838,7 @@ const useScrollLock = (target, initialState = false)=>{
2831
2838
  return;
2832
2839
  }
2833
2840
  if (isIOS) {
2834
- element.removeEventListener("touchmove", preventDefault);
2841
+ element.removeEventListener('touchmove', preventDefault);
2835
2842
  }
2836
2843
  element.style.overflow = initialOverflowRef.current;
2837
2844
  setLocked(false);
@@ -2869,14 +2876,14 @@ function _extends() {
2869
2876
  }
2870
2877
  const useSetState = (initialState)=>{
2871
2878
  const [state, _setState] = React.useState(initialState);
2872
- const setState = React.useCallback((statePartial)=>_setState((current)=>_extends({}, current, typeof statePartial === "function" ? statePartial(current) : statePartial)), []);
2879
+ const setState = React.useCallback((statePartial)=>_setState((current)=>_extends({}, current, typeof statePartial === 'function' ? statePartial(current) : statePartial)), []);
2873
2880
  return [
2874
2881
  state,
2875
2882
  setState
2876
2883
  ];
2877
2884
  };
2878
2885
 
2879
- const useSticky = (targetElement, { axis = "y", nav = 0 }, scrollElement)=>{
2886
+ function useSticky(targetElement, { axis = 'y', nav = 0 }, scrollElement) {
2880
2887
  const [isSticky, setSticky] = React.useState(false);
2881
2888
  const { run: scrollHandler } = useThrottleFn(()=>{
2882
2889
  const element = getTargetElement(targetElement);
@@ -2884,7 +2891,7 @@ const useSticky = (targetElement, { axis = "y", nav = 0 }, scrollElement)=>{
2884
2891
  return;
2885
2892
  }
2886
2893
  const rect = element.getBoundingClientRect();
2887
- if (axis === "y") {
2894
+ if (axis === 'y') {
2888
2895
  setSticky((rect == null ? void 0 : rect.top) <= nav);
2889
2896
  } else {
2890
2897
  setSticky((rect == null ? void 0 : rect.left) <= nav);
@@ -2896,10 +2903,10 @@ const useSticky = (targetElement, { axis = "y", nav = 0 }, scrollElement)=>{
2896
2903
  if (!element || !scrollParent) {
2897
2904
  return;
2898
2905
  }
2899
- scrollParent.addEventListener("scroll", scrollHandler);
2906
+ scrollParent.addEventListener('scroll', scrollHandler);
2900
2907
  scrollHandler();
2901
2908
  return ()=>{
2902
- scrollParent.removeEventListener("scroll", scrollHandler);
2909
+ scrollParent.removeEventListener('scroll', scrollHandler);
2903
2910
  };
2904
2911
  }, [
2905
2912
  axis,
@@ -2911,10 +2918,10 @@ const useSticky = (targetElement, { axis = "y", nav = 0 }, scrollElement)=>{
2911
2918
  isSticky,
2912
2919
  setSticky
2913
2920
  ];
2914
- };
2921
+ }
2915
2922
 
2916
2923
  const useTextDirection = (options = defaultOptions$1)=>{
2917
- const { selector = "html", initialValue = "ltr" } = options;
2924
+ const { selector = 'html', initialValue = 'ltr' } = options;
2918
2925
  const getValue = ()=>{
2919
2926
  if (initialValue !== undefined) {
2920
2927
  return initialValue;
@@ -2922,11 +2929,11 @@ const useTextDirection = (options = defaultOptions$1)=>{
2922
2929
  if (isBrowser) {
2923
2930
  var _document_querySelector, _document;
2924
2931
  var _document_querySelector_getAttribute;
2925
- return (_document_querySelector_getAttribute = (_document = document) == null ? void 0 : (_document_querySelector = _document.querySelector(selector)) == null ? void 0 : _document_querySelector.getAttribute("dir")) != null ? _document_querySelector_getAttribute : initialValue;
2932
+ return (_document_querySelector_getAttribute = (_document = document) == null ? void 0 : (_document_querySelector = _document.querySelector(selector)) == null ? void 0 : _document_querySelector.getAttribute('dir')) != null ? _document_querySelector_getAttribute : initialValue;
2926
2933
  }
2927
2934
  // A default value has not been provided, and you are rendering on the server, warn of a possible hydration mismatch when defaulting to false.
2928
- if (process.env.NODE_ENV !== "production") {
2929
- console.warn("`useTextDirection` When server side rendering, defaultState should be defined to prevent a hydration mismatches.");
2935
+ if (process.env.NODE_ENV !== 'production') {
2936
+ console.warn('`useTextDirection` When server side rendering, defaultState should be defined to prevent a hydration mismatches.');
2930
2937
  }
2931
2938
  return initialValue;
2932
2939
  };
@@ -2934,7 +2941,7 @@ const useTextDirection = (options = defaultOptions$1)=>{
2934
2941
  React.useEffect(()=>{
2935
2942
  var _document_querySelector, _document;
2936
2943
  var _document_querySelector_getAttribute;
2937
- setValue((_document_querySelector_getAttribute = (_document = document) == null ? void 0 : (_document_querySelector = _document.querySelector(selector)) == null ? void 0 : _document_querySelector.getAttribute("dir")) != null ? _document_querySelector_getAttribute : initialValue);
2944
+ setValue((_document_querySelector_getAttribute = (_document = document) == null ? void 0 : (_document_querySelector = _document.querySelector(selector)) == null ? void 0 : _document_querySelector.getAttribute('dir')) != null ? _document_querySelector_getAttribute : initialValue);
2938
2945
  }, [
2939
2946
  initialValue,
2940
2947
  selector
@@ -2945,10 +2952,10 @@ const useTextDirection = (options = defaultOptions$1)=>{
2945
2952
  }
2946
2953
  if (value !== null) {
2947
2954
  var _document_querySelector;
2948
- (_document_querySelector = document.querySelector(selector)) == null ? void 0 : _document_querySelector.setAttribute("dir", value);
2955
+ (_document_querySelector = document.querySelector(selector)) == null ? void 0 : _document_querySelector.setAttribute('dir', value);
2949
2956
  } else {
2950
2957
  var _document_querySelector1;
2951
- (_document_querySelector1 = document.querySelector(selector)) == null ? void 0 : _document_querySelector1.removeAttribute("dir");
2958
+ (_document_querySelector1 = document.querySelector(selector)) == null ? void 0 : _document_querySelector1.removeAttribute('dir');
2952
2959
  }
2953
2960
  setValue(value);
2954
2961
  };
@@ -2966,7 +2973,7 @@ const useTextSelection = ()=>{
2966
2973
  // this is because `document.getSelection` will always return the same object
2967
2974
  forceUpdate();
2968
2975
  };
2969
- useEventListener("selectionchange", handleSelectionChange, ()=>document);
2976
+ useEventListener('selectionchange', handleSelectionChange, ()=>document);
2970
2977
  React.useEffect(()=>{
2971
2978
  setSelection(document.getSelection());
2972
2979
  }, []);
@@ -3046,7 +3053,9 @@ const useTitle = (title)=>{
3046
3053
  ]);
3047
3054
  };
3048
3055
 
3049
- const toggleReducer = (state, nextValue)=>typeof nextValue === "boolean" ? nextValue : !state;
3056
+ function toggleReducer(state, nextValue) {
3057
+ return typeof nextValue === 'boolean' ? nextValue : !state;
3058
+ }
3050
3059
  const useToggle = (initialValue)=>{
3051
3060
  return React.useReducer(toggleReducer, initialValue);
3052
3061
  };
@@ -3083,7 +3092,7 @@ function _async_to_generator$1(fn) {
3083
3092
  };
3084
3093
  }
3085
3094
  const useWebNotification = (requestPermissions = false)=>{
3086
- const isSupported = useSupported(()=>!!window && "Notification" in window);
3095
+ const isSupported = useSupported(()=>!!window && 'Notification' in window);
3087
3096
  const permissionGranted = React.useRef(false);
3088
3097
  const notificationRef = React.useRef(null);
3089
3098
  const show = (title, options = defaultOptions$1)=>{
@@ -3092,7 +3101,7 @@ const useWebNotification = (requestPermissions = false)=>{
3092
3101
  if (!isSupported && !permissionGranted.current) {
3093
3102
  return;
3094
3103
  }
3095
- notificationRef.current = new Notification(title || "", options);
3104
+ notificationRef.current = new Notification(title || '', options);
3096
3105
  return notificationRef.current;
3097
3106
  };
3098
3107
  const close = React.useCallback(()=>{
@@ -3102,15 +3111,15 @@ const useWebNotification = (requestPermissions = false)=>{
3102
3111
  notificationRef.current = null;
3103
3112
  }, []);
3104
3113
  React.useEffect(()=>{
3105
- permissionGranted.current = isSupported && "permission" in Notification && Notification.permission === "granted";
3114
+ permissionGranted.current = isSupported && 'permission' in Notification && Notification.permission === 'granted';
3106
3115
  }, [
3107
3116
  isSupported
3108
3117
  ]);
3109
3118
  const ensurePermissions = React.useCallback(/*#__PURE__*/ _async_to_generator$1(function*() {
3110
3119
  if (!isSupported) return;
3111
- if (!permissionGranted.current && Notification.permission !== "denied") {
3120
+ if (!permissionGranted.current && Notification.permission !== 'denied') {
3112
3121
  const result = yield Notification.requestPermission();
3113
- if (result === "granted") permissionGranted.current = true;
3122
+ if (result === 'granted') permissionGranted.current = true;
3114
3123
  }
3115
3124
  return permissionGranted.current;
3116
3125
  }), [
@@ -3134,25 +3143,25 @@ const useWebNotification = (requestPermissions = false)=>{
3134
3143
  };
3135
3144
  };
3136
3145
 
3137
- const useWindowsFocus = (defauleValue = false)=>{
3146
+ function useWindowsFocus(defauleValue = false) {
3138
3147
  const [focused, setFocused] = React.useState(defauleValue);
3139
3148
  React.useEffect(()=>{
3140
3149
  setFocused(window.document.hasFocus());
3141
3150
  }, []);
3142
- useEventListener("blur", ()=>{
3151
+ useEventListener('blur', ()=>{
3143
3152
  setFocused(false);
3144
3153
  });
3145
- useEventListener("focus", ()=>{
3154
+ useEventListener('focus', ()=>{
3146
3155
  setFocused(true);
3147
3156
  });
3148
3157
  return focused;
3149
- };
3158
+ }
3150
3159
 
3151
3160
  const listenerOptions = {
3152
3161
  capture: false,
3153
3162
  passive: true
3154
3163
  };
3155
- const useWindowScroll = ()=>{
3164
+ function useWindowScroll() {
3156
3165
  const [state, setState] = useRafState(()=>({
3157
3166
  x: 0,
3158
3167
  y: 0
@@ -3163,20 +3172,20 @@ const useWindowScroll = ()=>{
3163
3172
  y: window.scrollY
3164
3173
  });
3165
3174
  };
3166
- useEventListener("scroll", handleScroll, defaultWindow, listenerOptions);
3175
+ useEventListener('scroll', handleScroll, defaultWindow, listenerOptions);
3167
3176
  // Set scroll at the first client-side load
3168
3177
  useIsomorphicLayoutEffect(()=>{
3169
3178
  handleScroll();
3170
3179
  }, []);
3171
3180
  return state;
3172
- };
3181
+ }
3173
3182
 
3174
- const subscribe = (callback)=>{
3175
- window.addEventListener("resize", callback);
3183
+ function subscribe(callback) {
3184
+ window.addEventListener('resize', callback);
3176
3185
  return ()=>{
3177
- window.removeEventListener("resize", callback);
3186
+ window.removeEventListener('resize', callback);
3178
3187
  };
3179
- };
3188
+ }
3180
3189
  const useWindowSize = ()=>{
3181
3190
  const stateDependencies = React.useRef({}).current;
3182
3191
  const previous = React.useRef({
@@ -3247,14 +3256,14 @@ function _async_to_generator(fn) {
3247
3256
  };
3248
3257
  }
3249
3258
  const useClipboard = ()=>{
3250
- const [text, setText] = React.useState("");
3259
+ const [text, setText] = React.useState('');
3251
3260
  const updateText = React.useCallback(()=>{
3252
3261
  window.navigator.clipboard.readText().then((value)=>{
3253
3262
  setText(value);
3254
3263
  });
3255
3264
  }, []);
3256
- useEventListener("copy", updateText);
3257
- useEventListener("cut", updateText);
3265
+ useEventListener('copy', updateText);
3266
+ useEventListener('cut', updateText);
3258
3267
  const copy = React.useCallback(/*#__PURE__*/ _async_to_generator(function*(txt) {
3259
3268
  setText(txt);
3260
3269
  yield window.navigator.clipboard.writeText(txt);
@@ -3265,24 +3274,24 @@ const useClipboard = ()=>{
3265
3274
  ];
3266
3275
  };
3267
3276
 
3268
- const getPlatform = (userAgent)=>{
3277
+ function getPlatform(userAgent) {
3269
3278
  if (/iPad|iPhone|iPod|ios/i.test(userAgent)) {
3270
- return "ios";
3279
+ return 'ios';
3271
3280
  } else if (/android/i.test(userAgent)) {
3272
- return "android";
3281
+ return 'android';
3273
3282
  } else {
3274
- return "unknown";
3283
+ return 'unknown';
3275
3284
  }
3276
- };
3285
+ }
3277
3286
  const usePlatform = ({ userAgent } = {
3278
- userAgent: ""
3287
+ userAgent: ''
3279
3288
  })=>{
3280
- const [ua, setUa] = React.useState(userAgent || "");
3289
+ const [ua, setUa] = React.useState(userAgent || '');
3281
3290
  const [platform, setPlatform] = React.useState(()=>{
3282
3291
  if (userAgent) {
3283
3292
  return getPlatform(userAgent);
3284
3293
  }
3285
- return "unknown";
3294
+ return 'unknown';
3286
3295
  });
3287
3296
  React.useEffect(()=>{
3288
3297
  setPlatform(getPlatform(navigator.userAgent));
@@ -3311,18 +3320,18 @@ const usePlatform = ({ userAgent } = {
3311
3320
  };
3312
3321
  };
3313
3322
 
3314
- const useMobileLandscape = ()=>{
3323
+ function useMobileLandscape() {
3315
3324
  const [isMobileLandscape, setIsMobileLandscape] = React.useState(false);
3316
3325
  const [orientation] = useOrientation();
3317
3326
  React.useEffect(()=>{
3318
3327
  const userAgent = window.navigator.userAgent;
3319
3328
  const isMobile = /Mobi|Android|iphone/i.test(userAgent);
3320
- setIsMobileLandscape(isMobile && orientation.type === "landscape-primary");
3329
+ setIsMobileLandscape(isMobile && orientation.type === 'landscape-primary');
3321
3330
  }, [
3322
3331
  orientation.type
3323
3332
  ]);
3324
3333
  return isMobileLandscape;
3325
- };
3334
+ }
3326
3335
 
3327
3336
  const useControlled = (value, defaultValue, onChange)=>{
3328
3337
  const [stateValue, setStateValue] = React.useState(value !== undefined ? value : defaultValue);
@@ -3343,7 +3352,7 @@ const useControlled = (value, defaultValue, onChange)=>{
3343
3352
  ];
3344
3353
  };
3345
3354
 
3346
- const useDisclosure = (props = {})=>{
3355
+ function useDisclosure(props = {}) {
3347
3356
  const { defaultOpen, isOpen: isOpenProp, onClose: onCloseProp, onOpen: onOpenProp, onChange = ()=>{} } = props;
3348
3357
  const onOpenPropRef = useLatest(onOpenProp);
3349
3358
  const onClosePropRef = useLatest(onCloseProp);
@@ -3384,12 +3393,12 @@ const useDisclosure = (props = {})=>{
3384
3393
  onOpenChange,
3385
3394
  isControlled
3386
3395
  };
3387
- };
3396
+ }
3388
3397
 
3389
3398
  const useEventSource = (url, events = [], options = defaultOptions$1)=>{
3390
3399
  const [data, setData] = React.useState(null);
3391
3400
  const [error, setError] = React.useState(null);
3392
- const [status, setStatus] = React.useState("DISCONNECTED");
3401
+ const [status, setStatus] = React.useState('DISCONNECTED');
3393
3402
  const [event, setEvent] = React.useState(null);
3394
3403
  const [lastEventId, setLastEventId] = React.useState(null);
3395
3404
  const retries = React.useRef(0);
@@ -3411,7 +3420,7 @@ const useEventSource = (url, events = [], options = defaultOptions$1)=>{
3411
3420
  });
3412
3421
  const close = React.useCallback(()=>{
3413
3422
  var _eventSourceRef_current;
3414
- setStatus("DISCONNECTED");
3423
+ setStatus('DISCONNECTED');
3415
3424
  clean();
3416
3425
  (_eventSourceRef_current = eventSourceRef.current) == null ? void 0 : _eventSourceRef_current.close();
3417
3426
  eventSourceRef.current = null;
@@ -3430,21 +3439,21 @@ const useEventSource = (url, events = [], options = defaultOptions$1)=>{
3430
3439
  }
3431
3440
  const es = eventSourceRef.current;
3432
3441
  es.onopen = ()=>{
3433
- setStatus("CONNECTED");
3442
+ setStatus('CONNECTED');
3434
3443
  setError(null);
3435
3444
  };
3436
3445
  es.onmessage = (ev)=>{
3437
3446
  setData(ev.data);
3438
3447
  setLastEventId(ev.lastEventId);
3439
- setStatus("CONNECTED");
3448
+ setStatus('CONNECTED');
3440
3449
  };
3441
3450
  es.onerror = (err)=>{
3442
3451
  setError(err);
3443
- setStatus("DISCONNECTED");
3452
+ setStatus('DISCONNECTED');
3444
3453
  if (options.autoReconnect && !explicitlyClosed.current) {
3445
3454
  const { retries: maxRetries = -1, delay = 1000, onFailed } = options.autoReconnect;
3446
3455
  retries.current += 1;
3447
- if (typeof maxRetries === "number" && (maxRetries < 0 || retries.current < maxRetries) || typeof maxRetries === "function" && maxRetries()) {
3456
+ if (typeof maxRetries === 'number' && (maxRetries < 0 || retries.current < maxRetries) || typeof maxRetries === 'function' && maxRetries()) {
3448
3457
  setTimeout(open, delay);
3449
3458
  } else {
3450
3459
  onFailed == null ? void 0 : onFailed();
@@ -3487,10 +3496,34 @@ const useEventSource = (url, events = [], options = defaultOptions$1)=>{
3487
3496
  };
3488
3497
  };
3489
3498
 
3499
+ /**
3500
+ * @description copy from swr
3501
+ */ const use = React__default.default.use || ((thenable)=>{
3502
+ switch(thenable.status){
3503
+ case 'pending':
3504
+ throw thenable;
3505
+ case 'fulfilled':
3506
+ return thenable.value;
3507
+ case 'rejected':
3508
+ throw thenable.reason;
3509
+ default:
3510
+ thenable.status = 'pending';
3511
+ thenable.then((v)=>{
3512
+ thenable.status = 'fulfilled';
3513
+ thenable.value = v;
3514
+ }, (e)=>{
3515
+ thenable.status = 'rejected';
3516
+ thenable.reason = e;
3517
+ });
3518
+ throw thenable;
3519
+ }
3520
+ });
3521
+
3490
3522
  exports.assignRef = indexClient.assignRef;
3491
3523
  exports.mergeRefs = indexClient.mergeRefs;
3492
3524
  exports.useMergedRefs = indexClient.useMergedRefs;
3493
3525
  exports.defaultOptions = defaultOptions;
3526
+ exports.use = use;
3494
3527
  exports.useActiveElement = useActiveElement;
3495
3528
  exports.useAsyncEffect = useAsyncEffect;
3496
3529
  exports.useClickOutside = useClickOutside;