@reactuses/core 2.2.4 → 2.2.5

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
@@ -84,7 +84,7 @@ function useEvent(fn) {
84
84
  const isPrimitive$1 = (val) => val !== Object(val);
85
85
  function useCustomCompareEffect(effect, deps, depsEqual) {
86
86
  if (process.env.NODE_ENV !== "production") {
87
- if (!(deps instanceof Array) || !deps.length) {
87
+ if (!Array.isArray(deps) || !deps.length) {
88
88
  console.warn(
89
89
  "`useCustomCompareEffect` should not be used with no dependencies. Use React.useEffect instead."
90
90
  );
@@ -110,7 +110,7 @@ function useCustomCompareEffect(effect, deps, depsEqual) {
110
110
  const isPrimitive = (val) => val !== Object(val);
111
111
  function useDeepCompareEffect(effect, deps) {
112
112
  if (process.env.NODE_ENV !== "production") {
113
- if (!(deps instanceof Array) || !deps.length) {
113
+ if (!Array.isArray(deps) || !deps.length) {
114
114
  console.warn(
115
115
  "`useDeepCompareEffect` should not be used with no dependencies. Use React.useEffect instead."
116
116
  );
@@ -314,6 +314,7 @@ const getInitialState = (query, defaultState) => {
314
314
  function useMediaQuery(query, defaultState) {
315
315
  const [state, setState] = React.useState(getInitialState(query, defaultState));
316
316
  React.useEffect(() => {
317
+ var _a;
317
318
  let mounted = true;
318
319
  const mql = window.matchMedia(query);
319
320
  const onChange = () => {
@@ -325,15 +326,16 @@ function useMediaQuery(query, defaultState) {
325
326
  if ("addEventListener" in mql) {
326
327
  mql.addEventListener("change", onChange);
327
328
  } else {
328
- mql.addListener(onChange);
329
+ (_a = mql.addListener) == null ? void 0 : _a.call(mql, onChange);
329
330
  }
330
331
  setState(mql.matches);
331
332
  return () => {
333
+ var _a2;
332
334
  mounted = false;
333
335
  if ("removeEventListener" in mql) {
334
336
  mql.removeEventListener("change", onChange);
335
337
  } else {
336
- mql.removeListener(onChange);
338
+ (_a2 = mql.removeListener) == null ? void 0 : _a2.call(mql, onChange);
337
339
  }
338
340
  };
339
341
  }, [query]);
@@ -391,6 +393,7 @@ function useThrottleFn(fn, wait, options) {
391
393
  wait,
392
394
  options
393
395
  ),
396
+ // eslint-disable-next-line react-hooks/exhaustive-deps
394
397
  []
395
398
  );
396
399
  useUnmount(() => {
@@ -435,6 +438,7 @@ function useDebounceFn(fn, wait, options) {
435
438
  wait,
436
439
  options
437
440
  ),
441
+ // eslint-disable-next-line react-hooks/exhaustive-deps
438
442
  []
439
443
  );
440
444
  useUnmount(() => {
@@ -594,17 +598,17 @@ function useCounter(initialValue = 0, max = null, min = null) {
594
598
  const initFunc = () => {
595
599
  let init = typeof initialValue === "function" ? initialValue() : initialValue;
596
600
  typeof init !== "number" && console.error(
597
- "initialValue has to be a number, got " + typeof initialValue
601
+ `initialValue has to be a number, got ${typeof initialValue}`
598
602
  );
599
603
  if (typeof min === "number") {
600
604
  init = Math.max(init, min);
601
605
  } else if (min !== null) {
602
- console.error("min has to be a number, got " + typeof min);
606
+ console.error(`min has to be a number, got ${typeof min}`);
603
607
  }
604
608
  if (typeof max === "number") {
605
609
  init = Math.min(init, max);
606
610
  } else if (max !== null) {
607
- console.error("max has to be a number, got " + typeof max);
611
+ console.error(`max has to be a number, got ${typeof max}`);
608
612
  }
609
613
  return init;
610
614
  };
@@ -663,6 +667,7 @@ function useRafFn(callback, initiallyActive = true) {
663
667
  }
664
668
  },
665
669
  () => rafActivity.current
670
+ // isActive
666
671
  ],
667
672
  [step]
668
673
  );
@@ -677,6 +682,7 @@ function useRafFn(callback, initiallyActive = true) {
677
682
 
678
683
  function useEventEmitter() {
679
684
  const listeners = React.useRef([]);
685
+ const _disposed = React.useRef(false);
680
686
  const _event = React.useRef((listener) => {
681
687
  listeners.current.push(listener);
682
688
  const disposable = {
@@ -693,7 +699,6 @@ function useEventEmitter() {
693
699
  };
694
700
  return disposable;
695
701
  });
696
- const _disposed = React.useRef(false);
697
702
  const fire = (arg1, arg2) => {
698
703
  const queue = [];
699
704
  for (let i = 0; i < listeners.current.length; i++) {
@@ -1184,7 +1189,7 @@ var screenfull$1 = {exports: {}};
1184
1189
 
1185
1190
  /*!
1186
1191
  * screenfull
1187
- * v5.2.0 - 2021-11-03
1192
+ * v5.0.0 - 2019-09-09
1188
1193
  * (c) Sindre Sorhus; MIT License
1189
1194
  */
1190
1195
 
@@ -1267,7 +1272,7 @@ var screenfull$1 = {exports: {}};
1267
1272
  };
1268
1273
 
1269
1274
  var screenfull = {
1270
- request: function (element, options) {
1275
+ request: function (element) {
1271
1276
  return new Promise(function (resolve, reject) {
1272
1277
  var onFullScreenEntered = function () {
1273
1278
  this.off('change', onFullScreenEntered);
@@ -1278,11 +1283,7 @@ var screenfull$1 = {exports: {}};
1278
1283
 
1279
1284
  element = element || document.documentElement;
1280
1285
 
1281
- var returnPromise = element[fn.requestFullscreen](options);
1282
-
1283
- if (returnPromise instanceof Promise) {
1284
- returnPromise.then(onFullScreenEntered).catch(reject);
1285
- }
1286
+ Promise.resolve(element[fn.requestFullscreen]()).catch(reject);
1286
1287
  }.bind(this));
1287
1288
  },
1288
1289
  exit: function () {
@@ -1299,15 +1300,11 @@ var screenfull$1 = {exports: {}};
1299
1300
 
1300
1301
  this.on('change', onFullScreenExit);
1301
1302
 
1302
- var returnPromise = document[fn.exitFullscreen]();
1303
-
1304
- if (returnPromise instanceof Promise) {
1305
- returnPromise.then(onFullScreenExit).catch(reject);
1306
- }
1303
+ Promise.resolve(document[fn.exitFullscreen]()).catch(reject);
1307
1304
  }.bind(this));
1308
1305
  },
1309
- toggle: function (element, options) {
1310
- return this.isFullscreen ? this.exit() : this.request(element, options);
1306
+ toggle: function (element) {
1307
+ return this.isFullscreen ? this.exit() : this.request(element);
1311
1308
  },
1312
1309
  onchange: function (callback) {
1313
1310
  this.on('change', callback);
@@ -1439,7 +1436,7 @@ function getConnectionState(previousState) {
1439
1436
  return {
1440
1437
  online,
1441
1438
  previous: previousOnline,
1442
- since: online !== previousOnline ? new Date() : previousState == null ? void 0 : previousState.since,
1439
+ since: online !== previousOnline ? /* @__PURE__ */ new Date() : previousState == null ? void 0 : previousState.since,
1443
1440
  downlink: conn == null ? void 0 : conn.downlink,
1444
1441
  downlinkMax: conn == null ? void 0 : conn.downlinkMax,
1445
1442
  effectiveType: conn == null ? void 0 : conn.effectiveType,
@@ -1793,7 +1790,7 @@ var __spreadValues = (a, b) => {
1793
1790
  return a;
1794
1791
  };
1795
1792
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1796
- var __async$2 = (__this, __arguments, generator) => {
1793
+ var __async$3 = (__this, __arguments, generator) => {
1797
1794
  return new Promise((resolve, reject) => {
1798
1795
  var fulfilled = (value) => {
1799
1796
  try {
@@ -1827,7 +1824,7 @@ function useInfiniteScroll(target, onLoadMore, options = {}) {
1827
1824
  const di = state[3][direction];
1828
1825
  useUpdateEffect(() => {
1829
1826
  const opts = latestOptions.current;
1830
- const fn = () => __async$2(this, null, function* () {
1827
+ const fn = () => __async$3(this, null, function* () {
1831
1828
  var _a2, _b2, _c, _d;
1832
1829
  const previous = {
1833
1830
  height: (_b2 = (_a2 = element.current) == null ? void 0 : _a2.scrollHeight) != null ? _b2 : 0,
@@ -2374,7 +2371,7 @@ function useWindowScroll() {
2374
2371
  return state;
2375
2372
  }
2376
2373
 
2377
- var __async$1 = (__this, __arguments, generator) => {
2374
+ var __async$2 = (__this, __arguments, generator) => {
2378
2375
  return new Promise((resolve, reject) => {
2379
2376
  var fulfilled = (value) => {
2380
2377
  try {
@@ -2403,7 +2400,7 @@ function useClipBorad() {
2403
2400
  }, []);
2404
2401
  useEventListener("copy", updateText);
2405
2402
  useEventListener("cut", updateText);
2406
- const copy = React.useCallback((txt) => __async$1(this, null, function* () {
2403
+ const copy = React.useCallback((txt) => __async$2(this, null, function* () {
2407
2404
  setText(txt);
2408
2405
  yield window.navigator.clipboard.writeText(txt);
2409
2406
  }), []);
@@ -2451,9 +2448,6 @@ function useFocus(target, initialValue = false) {
2451
2448
  const [focus, innerSetFocus] = React.useState(initialValue);
2452
2449
  useEventListener("focus", () => innerSetFocus(true), target);
2453
2450
  useEventListener("blur", () => innerSetFocus(false), target);
2454
- useMount(() => {
2455
- setFocus(focus);
2456
- });
2457
2451
  const setFocus = (value) => {
2458
2452
  const element = getTargetElement(target);
2459
2453
  if (!element) {
@@ -2465,14 +2459,18 @@ function useFocus(target, initialValue = false) {
2465
2459
  element.focus();
2466
2460
  }
2467
2461
  };
2462
+ useMount(() => {
2463
+ setFocus(focus);
2464
+ });
2468
2465
  return [focus, setFocus];
2469
2466
  }
2470
2467
 
2471
- function useControlled({
2472
- controlled,
2473
- defaultValue: defaultProp,
2474
- state = "value"
2475
- }) {
2468
+ function useControlled(props) {
2469
+ const { controlled, defaultValue: defaultProp, state } = props != null ? props : {
2470
+ controlled: void 0,
2471
+ defaultValue: void 0,
2472
+ state: "value"
2473
+ };
2476
2474
  const { current: isControlled } = React.useRef(controlled !== void 0);
2477
2475
  const [valueState, setValue] = React.useState(defaultProp);
2478
2476
  const value = isControlled ? controlled : valueState;
@@ -2748,7 +2746,7 @@ const useSticky = ({
2748
2746
  return [isSticky, setSticky];
2749
2747
  };
2750
2748
 
2751
- var __async = (__this, __arguments, generator) => {
2749
+ var __async$1 = (__this, __arguments, generator) => {
2752
2750
  return new Promise((resolve, reject) => {
2753
2751
  var fulfilled = (value) => {
2754
2752
  try {
@@ -2771,7 +2769,7 @@ var __async = (__this, __arguments, generator) => {
2771
2769
  function useAsyncEffect(effect, cleanup = noop, deps) {
2772
2770
  const mounted = useMountedState();
2773
2771
  React.useEffect(() => {
2774
- const execute = () => __async(this, null, function* () {
2772
+ const execute = () => __async$1(this, null, function* () {
2775
2773
  if (!mounted()) {
2776
2774
  return;
2777
2775
  }
@@ -2818,6 +2816,69 @@ const useCountDown = (time, format = getHMSTime, callback) => {
2818
2816
  return [hour, minute, secoud];
2819
2817
  };
2820
2818
 
2819
+ function useSupported(callback, sync = false) {
2820
+ const [supported, setSupported] = React.useState(false);
2821
+ const effect = sync ? useIsomorphicLayoutEffect : React.useEffect;
2822
+ effect(() => {
2823
+ setSupported(Boolean(callback()));
2824
+ }, []);
2825
+ return supported;
2826
+ }
2827
+
2828
+ function useTextSelection() {
2829
+ const [selection, setSelection] = React.useState(null);
2830
+ const forceUpdate = useUpdate();
2831
+ const handleSelectionChange = () => {
2832
+ setSelection(document.getSelection());
2833
+ forceUpdate();
2834
+ };
2835
+ useEventListener("selectionchange", handleSelectionChange, () => document);
2836
+ React.useEffect(() => {
2837
+ setSelection(document.getSelection());
2838
+ }, []);
2839
+ return selection;
2840
+ }
2841
+
2842
+ var __async = (__this, __arguments, generator) => {
2843
+ return new Promise((resolve, reject) => {
2844
+ var fulfilled = (value) => {
2845
+ try {
2846
+ step(generator.next(value));
2847
+ } catch (e) {
2848
+ reject(e);
2849
+ }
2850
+ };
2851
+ var rejected = (value) => {
2852
+ try {
2853
+ step(generator.throw(value));
2854
+ } catch (e) {
2855
+ reject(e);
2856
+ }
2857
+ };
2858
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2859
+ step((generator = generator.apply(__this, __arguments)).next());
2860
+ });
2861
+ };
2862
+ function useEyeDropper() {
2863
+ const isSupported = useSupported(
2864
+ () => typeof window !== "undefined" && "EyeDropper" in window,
2865
+ true
2866
+ );
2867
+ const open = React.useCallback(
2868
+ (..._0) => __async(this, [..._0], function* (options = {}) {
2869
+ if (!isSupported) {
2870
+ return {
2871
+ sRGBHex: ""
2872
+ };
2873
+ }
2874
+ const eyeDropper = new window.EyeDropper();
2875
+ return eyeDropper.open(options);
2876
+ }),
2877
+ [isSupported]
2878
+ );
2879
+ return [isSupported, open];
2880
+ }
2881
+
2821
2882
  exports.getHMSTime = getHMSTime;
2822
2883
  exports.useActiveElement = useActiveElement;
2823
2884
  exports.useAsyncEffect = useAsyncEffect;
@@ -2841,6 +2902,7 @@ exports.useElementVisibility = useElementVisibility;
2841
2902
  exports.useEvent = useEvent;
2842
2903
  exports.useEventEmitter = useEventEmitter;
2843
2904
  exports.useEventListener = useEventListener;
2905
+ exports.useEyeDropper = useEyeDropper;
2844
2906
  exports.useFavicon = useFavicon;
2845
2907
  exports.useFileDialog = useFileDialog;
2846
2908
  exports.useFirstMountState = useFirstMountState;
@@ -2886,7 +2948,9 @@ exports.useScrollIntoView = useScrollIntoView;
2886
2948
  exports.useScrollLock = useScrollLock;
2887
2949
  exports.useSessionStorage = useSessionStorage;
2888
2950
  exports.useSticky = useSticky;
2951
+ exports.useSupported = useSupported;
2889
2952
  exports.useTextDirection = useTextDirection;
2953
+ exports.useTextSelection = useTextSelection;
2890
2954
  exports.useThrottle = useThrottle;
2891
2955
  exports.useThrottleFn = useThrottleFn;
2892
2956
  exports.useTimeout = useTimeout;
package/dist/index.d.ts CHANGED
@@ -45,9 +45,9 @@ declare function useSessionStorage(key: string, defaults: boolean, options?: Use
45
45
  declare function useSessionStorage<T>(key: string, defaults: T, options?: UseStorageOptions<T>): readonly [T | null, Dispatch<SetStateAction<T | null>>];
46
46
  declare function useSessionStorage<T = unknown>(key: string, defaults: null, options?: UseStorageOptions<T>): readonly [T | null, Dispatch<SetStateAction<T | null>>];
47
47
 
48
- type Fn = (this: any, ...args: any[]) => any;
49
- type Stoppable = [boolean, Fn, Fn];
50
- type PointerType = "mouse" | "touch" | "pen";
48
+ declare type Fn = (this: any, ...args: any[]) => any;
49
+ declare type Stoppable = [boolean, Fn, Fn];
50
+ declare type PointerType = "mouse" | "touch" | "pen";
51
51
  interface Position {
52
52
  x: number;
53
53
  y: number;
@@ -166,11 +166,11 @@ declare function useTimeout(ms?: number, options?: UseTimeoutFnOptions): Stoppab
166
166
 
167
167
  declare function useMountedState(): () => boolean;
168
168
 
169
- type TargetValue<T> = T | undefined | null;
170
- type TargetType = HTMLElement | Element | Window | Document | EventTarget;
171
- type BasicTarget<T extends TargetType = Element> = (() => TargetValue<T>) | TargetValue<T> | MutableRefObject<TargetValue<T>>;
169
+ declare type TargetValue<T> = T | undefined | null;
170
+ declare type TargetType = HTMLElement | Element | Window | Document | EventTarget;
171
+ declare type BasicTarget<T extends TargetType = Element> = (() => TargetValue<T>) | TargetValue<T> | MutableRefObject<TargetValue<T>>;
172
172
 
173
- type Target = BasicTarget<HTMLElement | Element | Window | Document | EventTarget>;
173
+ declare type Target = BasicTarget<HTMLElement | Element | Window | Document | EventTarget>;
174
174
  declare function useEventListener<K extends keyof WindowEventMap>(eventName: K, handler: (event: WindowEventMap[K]) => void, element?: Window, options?: boolean | AddEventListenerOptions): void;
175
175
  declare function useEventListener<K extends keyof DocumentEventMap>(eventName: K, handler: (event: DocumentEventMap[K]) => void, element: Document, options?: boolean | AddEventListenerOptions): void;
176
176
  declare function useEventListener<K extends keyof HTMLElementEventMap, T extends HTMLElement = HTMLDivElement>(eventName: K, handler: (event: HTMLElementEventMap[K]) => void, element: T, options?: boolean | AddEventListenerOptions): void;
@@ -180,7 +180,7 @@ declare function useEventListener(eventName: string, handler: (...p: any) => voi
180
180
 
181
181
  declare function useCounter(initialValue?: number | (() => number), max?: number | null, min?: number | null): readonly [number, (newState: number | ((prev: number) => number) | (() => number)) => void, (delta?: number) => void, (delta?: number) => void, () => void];
182
182
 
183
- type RafLoopReturns = readonly [() => void, () => void, () => boolean];
183
+ declare type RafLoopReturns = readonly [() => void, () => void, () => boolean];
184
184
  declare function useRafFn(callback: FrameRequestCallback, initiallyActive?: boolean): RafLoopReturns;
185
185
 
186
186
  interface IListener<T, U = void> {
@@ -218,7 +218,7 @@ declare function useFavicon(href: string, baseUrl?: string, rel?: string): void;
218
218
 
219
219
  declare function useMutationObserver(callback: MutationCallback, target: BasicTarget, options?: MutationObserverInit): () => void;
220
220
 
221
- type DepsEqualFnType<TDeps extends DependencyList> = (prevDeps: TDeps, nextDeps: TDeps) => boolean;
221
+ declare type DepsEqualFnType<TDeps extends DependencyList> = (prevDeps: TDeps, nextDeps: TDeps) => boolean;
222
222
  declare function useCustomCompareEffect<TDeps extends DependencyList>(effect: EffectCallback, deps: TDeps, depsEqual: DepsEqualFnType<TDeps>): void;
223
223
 
224
224
  declare function useDeepCompareEffect(effect: EffectCallback, deps: DependencyList): void;
@@ -260,12 +260,12 @@ interface UseScriptTagOptions {
260
260
  */
261
261
  attrs?: Record<string, string>;
262
262
  }
263
- type Status = "idle" | "loading" | "ready" | "error";
263
+ declare type Status = "idle" | "loading" | "ready" | "error";
264
264
  declare function useScriptTag(src: string, onLoaded?: (el: HTMLScriptElement) => void, options?: UseScriptTagOptions): readonly [HTMLScriptElement | null, Status, (waitForScriptLoad?: boolean) => Promise<HTMLScriptElement | boolean>, () => void];
265
265
 
266
- type IState = PermissionState | "";
267
- type DescriptorNamePolyfill = "accelerometer" | "accessibility-events" | "ambient-light-sensor" | "background-sync" | "camera" | "clipboard-read" | "clipboard-write" | "gyroscope" | "magnetometer" | "microphone" | "notifications" | "payment-handler" | "persistent-storage" | "push" | "speaker";
268
- type GeneralPermissionDescriptor = PermissionDescriptor | {
266
+ declare type IState = PermissionState | "";
267
+ declare type DescriptorNamePolyfill = "accelerometer" | "accessibility-events" | "ambient-light-sensor" | "background-sync" | "camera" | "clipboard-read" | "clipboard-write" | "gyroscope" | "magnetometer" | "microphone" | "notifications" | "payment-handler" | "persistent-storage" | "push" | "speaker";
268
+ declare type GeneralPermissionDescriptor = PermissionDescriptor | {
269
269
  name: DescriptorNamePolyfill;
270
270
  };
271
271
  declare function usePermission(permissionDesc: GeneralPermissionDescriptor | GeneralPermissionDescriptor["name"]): IState;
@@ -296,7 +296,7 @@ declare function useMediaDevices(): {
296
296
  };
297
297
  declare const _default$3: typeof useMediaDevices;
298
298
 
299
- type UseTextDirectionValue = "ltr" | "rtl" | "auto";
299
+ declare type UseTextDirectionValue = "ltr" | "rtl" | "auto";
300
300
  interface UseTextDirectionOptions {
301
301
  /**
302
302
  * CSS Selector for the target element applying to
@@ -352,7 +352,7 @@ declare function useFullscreen(target: BasicTarget, options?: UseFullScreenOptio
352
352
  readonly enterFullscreen: () => void;
353
353
  readonly exitFullscreen: () => void;
354
354
  readonly toggleFullscreen: () => void;
355
- readonly isEnabled: true;
355
+ readonly isEnabled: boolean;
356
356
  }];
357
357
 
358
358
  interface INetworkInformation extends EventTarget {
@@ -539,7 +539,7 @@ interface UseInfiniteScrollOptions extends UseScrollOptions {
539
539
  }
540
540
  declare function useInfiniteScroll(target: BasicTarget<HTMLElement | SVGElement>, onLoadMore: (state: ReturnType<typeof useScroll>) => void | Promise<void>, options?: UseInfiniteScrollOptions): void;
541
541
 
542
- type KeyModifier = "Alt" | "AltGraph" | "CapsLock" | "Control" | "Fn" | "FnLock" | "Meta" | "NumLock" | "ScrollLock" | "Shift" | "Symbol" | "SymbolLock";
542
+ declare type KeyModifier = "Alt" | "AltGraph" | "CapsLock" | "Control" | "Fn" | "FnLock" | "Meta" | "NumLock" | "ScrollLock" | "Shift" | "Symbol" | "SymbolLock";
543
543
  interface UseModifierOptions {
544
544
  /**
545
545
  * Event names that will prompt update to modifier states
@@ -556,8 +556,8 @@ interface UseModifierOptions {
556
556
  }
557
557
  declare function useKeyModifier(modifier: KeyModifier, options?: UseModifierOptions): boolean;
558
558
 
559
- type IHookStateInitialSetter<S> = () => S;
560
- type IHookStateInitAction<S> = S | IHookStateInitialSetter<S>;
559
+ declare type IHookStateInitialSetter<S> = () => S;
560
+ declare type IHookStateInitAction<S> = S | IHookStateInitialSetter<S>;
561
561
 
562
562
  interface MousePressedOptions {
563
563
  /**
@@ -579,7 +579,7 @@ interface MousePressedOptions {
579
579
  */
580
580
  initialValue?: IHookStateInitAction<boolean>;
581
581
  }
582
- type MouseSourceType = "mouse" | "touch" | null;
582
+ declare type MouseSourceType = "mouse" | "touch" | null;
583
583
  declare function useMousePressed(target?: BasicTarget, options?: MousePressedOptions): readonly [boolean, MouseSourceType];
584
584
 
585
585
  declare function useScrollLock(target: BasicTarget<HTMLElement>, initialState?: boolean): readonly [boolean, (flag: boolean) => void];
@@ -626,10 +626,10 @@ interface UseVirtualListReturn<T> {
626
626
  }
627
627
  declare function useVirtualList<T = any>(list: T[] | undefined, options: UseVirtualListOptions): UseVirtualListReturn<T>;
628
628
 
629
- type ColorScheme = "dark" | "light" | "no-preference";
629
+ declare type ColorScheme = "dark" | "light" | "no-preference";
630
630
  declare function usePreferredColorScheme(defaultState?: ColorScheme): ColorScheme;
631
631
 
632
- type Contrast = "more" | "less" | "custom" | "no-preference";
632
+ declare type Contrast = "more" | "less" | "custom" | "no-preference";
633
633
  declare function usePreferredContrast(defaultState?: Contrast): Contrast;
634
634
 
635
635
  declare function useActiveElement<T extends Element>(): T | null;
@@ -751,7 +751,7 @@ declare function useClipBorad(): readonly [
751
751
  (txt: string) => Promise<void>
752
752
  ];
753
753
 
754
- type EventType = MouseEvent | TouchEvent;
754
+ declare type EventType = MouseEvent | TouchEvent;
755
755
  declare function useClickOutSide(target: BasicTarget, handler: (evt: EventType) => void): void;
756
756
 
757
757
  declare function useCycleList<T>(list: T[], i?: number): readonly [T, (i?: number) => void, (i?: number) => void];
@@ -763,7 +763,7 @@ interface IProps<T> {
763
763
  defaultValue?: T;
764
764
  state?: T;
765
765
  }
766
- declare function useControlled<T = string>({ controlled, defaultValue, state, }: IProps<T>): readonly [T, (newValue: T) => void];
766
+ declare function useControlled<T = string>(props?: IProps<T>): readonly [T, (newValue: T) => void];
767
767
 
768
768
  declare const _default$1: typeof useEffect | typeof react.useLayoutEffect;
769
769
 
@@ -816,4 +816,17 @@ declare function useAsyncEffect<T extends void>(effect: () => Promise<T> | T, cl
816
816
  declare const getHMSTime: (timeDiff: number) => [string, string, string];
817
817
  declare const useCountDown: (time: number, format?: (number: any) => [string, string, string], callback?: () => void) => readonly [string, string, string];
818
818
 
819
- export { ColorScheme, Contrast, CursorState, GeneralPermissionDescriptor, IDisposable, IEvent, IEventOnce, IListener, INetworkInformation, IState, IUseNetworkState, KeyModifier, MousePressedOptions, MouseSourceType, OrientationState, RafLoopReturns, ScrollIntoViewAnimation, ScrollIntoViewParams, State, Status, Target, UseDarkOptions, UseDraggableOptions, UseElementBoundingOptions, UseEventEmitterReturn, UseFileDialogOptions, UseFpsOptions, UseFullScreenOptions, UseInfiniteScrollOptions, UseLongPressOptions, UseModifierOptions, UseScriptTagOptions, UseScrollOptions, UseStickyParams, UseTextDirectionOptions, UseTextDirectionValue, UseTimeoutFnOptions, UseVirtualListItem, UseVirtualListOptions, UseVirtualListReturn, WindowSize, getHMSTime, useActiveElement, useAsyncEffect, useClickOutSide as useClickOutside, useClipBorad as useClipboard, useControlled, useCountDown, useCounter, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useFavicon, useFileDialog, useFirstMountState, useFocus, _default$2 as useFps, useFullscreen, useGeolocation, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLongPress, _default$3 as useMediaDevices, useMediaQuery, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, _default$1 as useOnceEffect, _default as useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSticky, useTextDirection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, _default$5 as useUpdateEffect, _default$4 as useUpdateLayoutEffect, useVirtualList, useWindowScroll, useWindowSize, useWindowsFocus };
819
+ declare function useSupported(callback: () => unknown, sync?: boolean): boolean;
820
+
821
+ declare function useTextSelection(): Selection | null;
822
+
823
+ interface EyeDropperOpenOptions {
824
+ signal?: AbortSignal;
825
+ }
826
+ interface EyeDropperOpenReturnType {
827
+ sRGBHex: string;
828
+ }
829
+ declare function useEyeDropper(): readonly [boolean, (options?: EyeDropperOpenOptions) => Promise<EyeDropperOpenReturnType>];
830
+ declare type UseEyeDropperReturn = ReturnType<typeof useEyeDropper>;
831
+
832
+ export { ColorScheme, Contrast, CursorState, EyeDropperOpenReturnType, GeneralPermissionDescriptor, IDisposable, IEvent, IEventOnce, IListener, INetworkInformation, IState, IUseNetworkState, KeyModifier, MousePressedOptions, MouseSourceType, OrientationState, RafLoopReturns, ScrollIntoViewAnimation, ScrollIntoViewParams, State, Status, Target, UseDarkOptions, UseDraggableOptions, UseElementBoundingOptions, UseEventEmitterReturn, UseEyeDropperReturn, UseFileDialogOptions, UseFpsOptions, UseFullScreenOptions, UseInfiniteScrollOptions, UseLongPressOptions, UseModifierOptions, UseScriptTagOptions, UseScrollOptions, UseStickyParams, UseTextDirectionOptions, UseTextDirectionValue, UseTimeoutFnOptions, UseVirtualListItem, UseVirtualListOptions, UseVirtualListReturn, WindowSize, getHMSTime, useActiveElement, useAsyncEffect, useClickOutSide as useClickOutside, useClipBorad as useClipboard, useControlled, useCountDown, useCounter, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, _default$2 as useFps, useFullscreen, useGeolocation, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLongPress, _default$3 as useMediaDevices, useMediaQuery, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, _default$1 as useOnceEffect, _default as useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, _default$5 as useUpdateEffect, _default$4 as useUpdateLayoutEffect, useVirtualList, useWindowScroll, useWindowSize, useWindowsFocus };
package/dist/index.mjs CHANGED
@@ -76,7 +76,7 @@ function useEvent(fn) {
76
76
  const isPrimitive$1 = (val) => val !== Object(val);
77
77
  function useCustomCompareEffect(effect, deps, depsEqual) {
78
78
  if (process.env.NODE_ENV !== "production") {
79
- if (!(deps instanceof Array) || !deps.length) {
79
+ if (!Array.isArray(deps) || !deps.length) {
80
80
  console.warn(
81
81
  "`useCustomCompareEffect` should not be used with no dependencies. Use React.useEffect instead."
82
82
  );
@@ -102,7 +102,7 @@ function useCustomCompareEffect(effect, deps, depsEqual) {
102
102
  const isPrimitive = (val) => val !== Object(val);
103
103
  function useDeepCompareEffect(effect, deps) {
104
104
  if (process.env.NODE_ENV !== "production") {
105
- if (!(deps instanceof Array) || !deps.length) {
105
+ if (!Array.isArray(deps) || !deps.length) {
106
106
  console.warn(
107
107
  "`useDeepCompareEffect` should not be used with no dependencies. Use React.useEffect instead."
108
108
  );
@@ -306,6 +306,7 @@ const getInitialState = (query, defaultState) => {
306
306
  function useMediaQuery(query, defaultState) {
307
307
  const [state, setState] = useState(getInitialState(query, defaultState));
308
308
  useEffect(() => {
309
+ var _a;
309
310
  let mounted = true;
310
311
  const mql = window.matchMedia(query);
311
312
  const onChange = () => {
@@ -317,15 +318,16 @@ function useMediaQuery(query, defaultState) {
317
318
  if ("addEventListener" in mql) {
318
319
  mql.addEventListener("change", onChange);
319
320
  } else {
320
- mql.addListener(onChange);
321
+ (_a = mql.addListener) == null ? void 0 : _a.call(mql, onChange);
321
322
  }
322
323
  setState(mql.matches);
323
324
  return () => {
325
+ var _a2;
324
326
  mounted = false;
325
327
  if ("removeEventListener" in mql) {
326
328
  mql.removeEventListener("change", onChange);
327
329
  } else {
328
- mql.removeListener(onChange);
330
+ (_a2 = mql.removeListener) == null ? void 0 : _a2.call(mql, onChange);
329
331
  }
330
332
  };
331
333
  }, [query]);
@@ -383,6 +385,7 @@ function useThrottleFn(fn, wait, options) {
383
385
  wait,
384
386
  options
385
387
  ),
388
+ // eslint-disable-next-line react-hooks/exhaustive-deps
386
389
  []
387
390
  );
388
391
  useUnmount(() => {
@@ -427,6 +430,7 @@ function useDebounceFn(fn, wait, options) {
427
430
  wait,
428
431
  options
429
432
  ),
433
+ // eslint-disable-next-line react-hooks/exhaustive-deps
430
434
  []
431
435
  );
432
436
  useUnmount(() => {
@@ -586,17 +590,17 @@ function useCounter(initialValue = 0, max = null, min = null) {
586
590
  const initFunc = () => {
587
591
  let init = typeof initialValue === "function" ? initialValue() : initialValue;
588
592
  typeof init !== "number" && console.error(
589
- "initialValue has to be a number, got " + typeof initialValue
593
+ `initialValue has to be a number, got ${typeof initialValue}`
590
594
  );
591
595
  if (typeof min === "number") {
592
596
  init = Math.max(init, min);
593
597
  } else if (min !== null) {
594
- console.error("min has to be a number, got " + typeof min);
598
+ console.error(`min has to be a number, got ${typeof min}`);
595
599
  }
596
600
  if (typeof max === "number") {
597
601
  init = Math.min(init, max);
598
602
  } else if (max !== null) {
599
- console.error("max has to be a number, got " + typeof max);
603
+ console.error(`max has to be a number, got ${typeof max}`);
600
604
  }
601
605
  return init;
602
606
  };
@@ -655,6 +659,7 @@ function useRafFn(callback, initiallyActive = true) {
655
659
  }
656
660
  },
657
661
  () => rafActivity.current
662
+ // isActive
658
663
  ],
659
664
  [step]
660
665
  );
@@ -669,6 +674,7 @@ function useRafFn(callback, initiallyActive = true) {
669
674
 
670
675
  function useEventEmitter() {
671
676
  const listeners = useRef([]);
677
+ const _disposed = useRef(false);
672
678
  const _event = useRef((listener) => {
673
679
  listeners.current.push(listener);
674
680
  const disposable = {
@@ -685,7 +691,6 @@ function useEventEmitter() {
685
691
  };
686
692
  return disposable;
687
693
  });
688
- const _disposed = useRef(false);
689
694
  const fire = (arg1, arg2) => {
690
695
  const queue = [];
691
696
  for (let i = 0; i < listeners.current.length; i++) {
@@ -1176,7 +1181,7 @@ var screenfull$1 = {exports: {}};
1176
1181
 
1177
1182
  /*!
1178
1183
  * screenfull
1179
- * v5.2.0 - 2021-11-03
1184
+ * v5.0.0 - 2019-09-09
1180
1185
  * (c) Sindre Sorhus; MIT License
1181
1186
  */
1182
1187
 
@@ -1259,7 +1264,7 @@ var screenfull$1 = {exports: {}};
1259
1264
  };
1260
1265
 
1261
1266
  var screenfull = {
1262
- request: function (element, options) {
1267
+ request: function (element) {
1263
1268
  return new Promise(function (resolve, reject) {
1264
1269
  var onFullScreenEntered = function () {
1265
1270
  this.off('change', onFullScreenEntered);
@@ -1270,11 +1275,7 @@ var screenfull$1 = {exports: {}};
1270
1275
 
1271
1276
  element = element || document.documentElement;
1272
1277
 
1273
- var returnPromise = element[fn.requestFullscreen](options);
1274
-
1275
- if (returnPromise instanceof Promise) {
1276
- returnPromise.then(onFullScreenEntered).catch(reject);
1277
- }
1278
+ Promise.resolve(element[fn.requestFullscreen]()).catch(reject);
1278
1279
  }.bind(this));
1279
1280
  },
1280
1281
  exit: function () {
@@ -1291,15 +1292,11 @@ var screenfull$1 = {exports: {}};
1291
1292
 
1292
1293
  this.on('change', onFullScreenExit);
1293
1294
 
1294
- var returnPromise = document[fn.exitFullscreen]();
1295
-
1296
- if (returnPromise instanceof Promise) {
1297
- returnPromise.then(onFullScreenExit).catch(reject);
1298
- }
1295
+ Promise.resolve(document[fn.exitFullscreen]()).catch(reject);
1299
1296
  }.bind(this));
1300
1297
  },
1301
- toggle: function (element, options) {
1302
- return this.isFullscreen ? this.exit() : this.request(element, options);
1298
+ toggle: function (element) {
1299
+ return this.isFullscreen ? this.exit() : this.request(element);
1303
1300
  },
1304
1301
  onchange: function (callback) {
1305
1302
  this.on('change', callback);
@@ -1431,7 +1428,7 @@ function getConnectionState(previousState) {
1431
1428
  return {
1432
1429
  online,
1433
1430
  previous: previousOnline,
1434
- since: online !== previousOnline ? new Date() : previousState == null ? void 0 : previousState.since,
1431
+ since: online !== previousOnline ? /* @__PURE__ */ new Date() : previousState == null ? void 0 : previousState.since,
1435
1432
  downlink: conn == null ? void 0 : conn.downlink,
1436
1433
  downlinkMax: conn == null ? void 0 : conn.downlinkMax,
1437
1434
  effectiveType: conn == null ? void 0 : conn.effectiveType,
@@ -1785,7 +1782,7 @@ var __spreadValues = (a, b) => {
1785
1782
  return a;
1786
1783
  };
1787
1784
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1788
- var __async$2 = (__this, __arguments, generator) => {
1785
+ var __async$3 = (__this, __arguments, generator) => {
1789
1786
  return new Promise((resolve, reject) => {
1790
1787
  var fulfilled = (value) => {
1791
1788
  try {
@@ -1819,7 +1816,7 @@ function useInfiniteScroll(target, onLoadMore, options = {}) {
1819
1816
  const di = state[3][direction];
1820
1817
  useUpdateEffect(() => {
1821
1818
  const opts = latestOptions.current;
1822
- const fn = () => __async$2(this, null, function* () {
1819
+ const fn = () => __async$3(this, null, function* () {
1823
1820
  var _a2, _b2, _c, _d;
1824
1821
  const previous = {
1825
1822
  height: (_b2 = (_a2 = element.current) == null ? void 0 : _a2.scrollHeight) != null ? _b2 : 0,
@@ -2366,7 +2363,7 @@ function useWindowScroll() {
2366
2363
  return state;
2367
2364
  }
2368
2365
 
2369
- var __async$1 = (__this, __arguments, generator) => {
2366
+ var __async$2 = (__this, __arguments, generator) => {
2370
2367
  return new Promise((resolve, reject) => {
2371
2368
  var fulfilled = (value) => {
2372
2369
  try {
@@ -2395,7 +2392,7 @@ function useClipBorad() {
2395
2392
  }, []);
2396
2393
  useEventListener("copy", updateText);
2397
2394
  useEventListener("cut", updateText);
2398
- const copy = useCallback((txt) => __async$1(this, null, function* () {
2395
+ const copy = useCallback((txt) => __async$2(this, null, function* () {
2399
2396
  setText(txt);
2400
2397
  yield window.navigator.clipboard.writeText(txt);
2401
2398
  }), []);
@@ -2443,9 +2440,6 @@ function useFocus(target, initialValue = false) {
2443
2440
  const [focus, innerSetFocus] = useState(initialValue);
2444
2441
  useEventListener("focus", () => innerSetFocus(true), target);
2445
2442
  useEventListener("blur", () => innerSetFocus(false), target);
2446
- useMount(() => {
2447
- setFocus(focus);
2448
- });
2449
2443
  const setFocus = (value) => {
2450
2444
  const element = getTargetElement(target);
2451
2445
  if (!element) {
@@ -2457,14 +2451,18 @@ function useFocus(target, initialValue = false) {
2457
2451
  element.focus();
2458
2452
  }
2459
2453
  };
2454
+ useMount(() => {
2455
+ setFocus(focus);
2456
+ });
2460
2457
  return [focus, setFocus];
2461
2458
  }
2462
2459
 
2463
- function useControlled({
2464
- controlled,
2465
- defaultValue: defaultProp,
2466
- state = "value"
2467
- }) {
2460
+ function useControlled(props) {
2461
+ const { controlled, defaultValue: defaultProp, state } = props != null ? props : {
2462
+ controlled: void 0,
2463
+ defaultValue: void 0,
2464
+ state: "value"
2465
+ };
2468
2466
  const { current: isControlled } = useRef(controlled !== void 0);
2469
2467
  const [valueState, setValue] = useState(defaultProp);
2470
2468
  const value = isControlled ? controlled : valueState;
@@ -2740,7 +2738,7 @@ const useSticky = ({
2740
2738
  return [isSticky, setSticky];
2741
2739
  };
2742
2740
 
2743
- var __async = (__this, __arguments, generator) => {
2741
+ var __async$1 = (__this, __arguments, generator) => {
2744
2742
  return new Promise((resolve, reject) => {
2745
2743
  var fulfilled = (value) => {
2746
2744
  try {
@@ -2763,7 +2761,7 @@ var __async = (__this, __arguments, generator) => {
2763
2761
  function useAsyncEffect(effect, cleanup = noop, deps) {
2764
2762
  const mounted = useMountedState();
2765
2763
  useEffect(() => {
2766
- const execute = () => __async(this, null, function* () {
2764
+ const execute = () => __async$1(this, null, function* () {
2767
2765
  if (!mounted()) {
2768
2766
  return;
2769
2767
  }
@@ -2810,4 +2808,67 @@ const useCountDown = (time, format = getHMSTime, callback) => {
2810
2808
  return [hour, minute, secoud];
2811
2809
  };
2812
2810
 
2813
- export { getHMSTime, useActiveElement, useAsyncEffect, useClickOutSide as useClickOutside, useClipBorad as useClipboard, useControlled, useCountDown, useCounter, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useFavicon, useFileDialog, useFirstMountState, useFocus, useFps$1 as useFps, useFullscreen, useGeolocation, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLongPress, useMediaDevices$1 as useMediaDevices, useMediaQuery, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSticky, useTextDirection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useVirtualList, useWindowScroll, useWindowSize, useWindowsFocus };
2811
+ function useSupported(callback, sync = false) {
2812
+ const [supported, setSupported] = useState(false);
2813
+ const effect = sync ? useIsomorphicLayoutEffect : useEffect;
2814
+ effect(() => {
2815
+ setSupported(Boolean(callback()));
2816
+ }, []);
2817
+ return supported;
2818
+ }
2819
+
2820
+ function useTextSelection() {
2821
+ const [selection, setSelection] = useState(null);
2822
+ const forceUpdate = useUpdate();
2823
+ const handleSelectionChange = () => {
2824
+ setSelection(document.getSelection());
2825
+ forceUpdate();
2826
+ };
2827
+ useEventListener("selectionchange", handleSelectionChange, () => document);
2828
+ useEffect(() => {
2829
+ setSelection(document.getSelection());
2830
+ }, []);
2831
+ return selection;
2832
+ }
2833
+
2834
+ var __async = (__this, __arguments, generator) => {
2835
+ return new Promise((resolve, reject) => {
2836
+ var fulfilled = (value) => {
2837
+ try {
2838
+ step(generator.next(value));
2839
+ } catch (e) {
2840
+ reject(e);
2841
+ }
2842
+ };
2843
+ var rejected = (value) => {
2844
+ try {
2845
+ step(generator.throw(value));
2846
+ } catch (e) {
2847
+ reject(e);
2848
+ }
2849
+ };
2850
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2851
+ step((generator = generator.apply(__this, __arguments)).next());
2852
+ });
2853
+ };
2854
+ function useEyeDropper() {
2855
+ const isSupported = useSupported(
2856
+ () => typeof window !== "undefined" && "EyeDropper" in window,
2857
+ true
2858
+ );
2859
+ const open = useCallback(
2860
+ (..._0) => __async(this, [..._0], function* (options = {}) {
2861
+ if (!isSupported) {
2862
+ return {
2863
+ sRGBHex: ""
2864
+ };
2865
+ }
2866
+ const eyeDropper = new window.EyeDropper();
2867
+ return eyeDropper.open(options);
2868
+ }),
2869
+ [isSupported]
2870
+ );
2871
+ return [isSupported, open];
2872
+ }
2873
+
2874
+ export { getHMSTime, useActiveElement, useAsyncEffect, useClickOutSide as useClickOutside, useClipBorad as useClipboard, useControlled, useCountDown, useCounter, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, useFps$1 as useFps, useFullscreen, useGeolocation, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLongPress, useMediaDevices$1 as useMediaDevices, useMediaQuery, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useVirtualList, useWindowScroll, useWindowSize, useWindowsFocus };
package/package.json CHANGED
@@ -1,16 +1,6 @@
1
1
  {
2
2
  "name": "@reactuses/core",
3
- "version": "2.2.4",
4
- "main": "./dist/index.cjs",
5
- "module": "./dist/index.mjs",
6
- "types": "./dist/index.d.ts",
7
- "files": [
8
- "dist",
9
- "package.json",
10
- "LICENSE",
11
- "README.md"
12
- ],
13
- "sideEffects": false,
3
+ "version": "2.2.5",
14
4
  "license": "Unlicense",
15
5
  "homepage": "https://www.reactuse.com/",
16
6
  "repository": {
@@ -21,6 +11,32 @@
21
11
  "bugs": {
22
12
  "url": "https://github.com/childrentime/reactuse/issues"
23
13
  },
14
+ "keywords": [
15
+ "react",
16
+ "react-use",
17
+ "react hooks",
18
+ "hook",
19
+ "hooks",
20
+ "component"
21
+ ],
22
+ "sideEffects": false,
23
+ "exports": {
24
+ "./package.json": "./package.json",
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "require": "./dist/index.cjs",
28
+ "import": "./dist/index.mjs"
29
+ }
30
+ },
31
+ "main": "./dist/index.cjs",
32
+ "module": "./dist/index.mjs",
33
+ "types": "./dist/index.d.ts",
34
+ "files": [
35
+ "dist",
36
+ "package.json",
37
+ "LICENSE",
38
+ "README.md"
39
+ ],
24
40
  "scripts": {
25
41
  "lint": "eslint \"{hooks,tests}/**/*.{ts,tsx}\"",
26
42
  "build": "esno scripts/build.ts",
@@ -32,8 +48,10 @@
32
48
  "test": "jest",
33
49
  "test:coverage": "jest --coverage"
34
50
  },
51
+ "peerDependencies": {
52
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
53
+ },
35
54
  "dependencies": {
36
- "@testing-library/react": "^13.4.0",
37
55
  "lodash": "^4.17.21",
38
56
  "screenfull": "^5.0.0"
39
57
  },
@@ -53,16 +71,11 @@
53
71
  "@types/lodash": "^4.14.184",
54
72
  "@types/node": "^18.11.9",
55
73
  "@types/react": "^18.0.25",
56
- "@typescript-eslint/eslint-plugin": "^5.36.1",
57
- "@typescript-eslint/parser": "^5.36.1",
58
74
  "babel-jest": "^29.0.2",
59
75
  "consola": "^2.15.3",
60
76
  "cross-env": "^7.0.3",
77
+ "esbuild": "^0.17.15",
61
78
  "esbuild-register": "^3.4.1",
62
- "eslint": "^8.23.0",
63
- "eslint-config-prettier": "^8.5.0",
64
- "eslint-plugin-react": "^7.31.5",
65
- "eslint-plugin-react-hooks": "^4.6.0",
66
79
  "esno": "^0.16.3",
67
80
  "fast-glob": "^3.2.12",
68
81
  "fs-extra": "^10.1.0",
@@ -74,17 +87,7 @@
74
87
  "rollup-plugin-dts": "^4.2.2",
75
88
  "rollup-plugin-esbuild": "^4.10.1",
76
89
  "ts-node": "^10.9.1",
77
- "typescript": "^4.8.2"
78
- },
79
- "peerDependencies": {
80
- "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
81
- },
82
- "keywords": [
83
- "react",
84
- "react-use",
85
- "react hooks",
86
- "hook",
87
- "hooks",
88
- "component"
89
- ]
90
+ "typescript": "^4.8.2",
91
+ "@testing-library/react": "^13.4.0"
92
+ }
90
93
  }