@reactuses/core 5.0.19 → 5.0.20

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
@@ -114,6 +114,18 @@ function useEventListener(eventName, handler, element, options = defaultOptions$
114
114
  ]);
115
115
  }
116
116
 
117
+ const useMount = (fn)=>{
118
+ if (isDev) {
119
+ if (!isFunction(fn)) {
120
+ console.error(`useMount: parameter \`fn\` expected to be a function, but got "${typeof fn}".`);
121
+ }
122
+ }
123
+ React.useEffect(()=>{
124
+ fn == null ? void 0 : fn();
125
+ // eslint-disable-next-line react-hooks/exhaustive-deps
126
+ }, []);
127
+ };
128
+
117
129
  const useActiveElement = ()=>{
118
130
  const [active, setActive] = React.useState(null);
119
131
  const listener = React.useCallback(()=>{
@@ -122,6 +134,10 @@ const useActiveElement = ()=>{
122
134
  }, []);
123
135
  useEventListener('blur', listener, ()=>window, true);
124
136
  useEventListener('focus', listener, ()=>window, true);
137
+ useMount(()=>{
138
+ var _window;
139
+ setActive((_window = window) == null ? void 0 : _window.document.activeElement);
140
+ });
125
141
  return active;
126
142
  };
127
143
 
@@ -1334,18 +1350,6 @@ const useFirstMountState = ()=>{
1334
1350
  return isFirst.current;
1335
1351
  };
1336
1352
 
1337
- const useMount = (fn)=>{
1338
- if (isDev) {
1339
- if (!isFunction(fn)) {
1340
- console.error(`useMount: parameter \`fn\` expected to be a function, but got "${typeof fn}".`);
1341
- }
1342
- }
1343
- React.useEffect(()=>{
1344
- fn == null ? void 0 : fn();
1345
- // eslint-disable-next-line react-hooks/exhaustive-deps
1346
- }, []);
1347
- };
1348
-
1349
1353
  const useFocus = (target, initialValue = false)=>{
1350
1354
  const [focus, innerSetFocus] = React.useState(initialValue);
1351
1355
  useEventListener('focus', ()=>innerSetFocus(true), target);
package/dist/index.mjs CHANGED
@@ -106,6 +106,18 @@ function useEventListener(eventName, handler, element, options = defaultOptions$
106
106
  ]);
107
107
  }
108
108
 
109
+ const useMount = (fn)=>{
110
+ if (isDev) {
111
+ if (!isFunction(fn)) {
112
+ console.error(`useMount: parameter \`fn\` expected to be a function, but got "${typeof fn}".`);
113
+ }
114
+ }
115
+ useEffect(()=>{
116
+ fn == null ? void 0 : fn();
117
+ // eslint-disable-next-line react-hooks/exhaustive-deps
118
+ }, []);
119
+ };
120
+
109
121
  const useActiveElement = ()=>{
110
122
  const [active, setActive] = useState(null);
111
123
  const listener = useCallback(()=>{
@@ -114,6 +126,10 @@ const useActiveElement = ()=>{
114
126
  }, []);
115
127
  useEventListener('blur', listener, ()=>window, true);
116
128
  useEventListener('focus', listener, ()=>window, true);
129
+ useMount(()=>{
130
+ var _window;
131
+ setActive((_window = window) == null ? void 0 : _window.document.activeElement);
132
+ });
117
133
  return active;
118
134
  };
119
135
 
@@ -1326,18 +1342,6 @@ const useFirstMountState = ()=>{
1326
1342
  return isFirst.current;
1327
1343
  };
1328
1344
 
1329
- const useMount = (fn)=>{
1330
- if (isDev) {
1331
- if (!isFunction(fn)) {
1332
- console.error(`useMount: parameter \`fn\` expected to be a function, but got "${typeof fn}".`);
1333
- }
1334
- }
1335
- useEffect(()=>{
1336
- fn == null ? void 0 : fn();
1337
- // eslint-disable-next-line react-hooks/exhaustive-deps
1338
- }, []);
1339
- };
1340
-
1341
1345
  const useFocus = (target, initialValue = false)=>{
1342
1346
  const [focus, innerSetFocus] = useState(initialValue);
1343
1347
  useEventListener('focus', ()=>innerSetFocus(true), target);
@@ -1,4 +1,4 @@
1
- import QRCode from 'qrcode';
1
+ import QRCode, { QRCodeToDataURLOptions } from 'qrcode';
2
2
 
3
3
  /**
4
4
  * @title UseQRCode
@@ -13,7 +13,7 @@ text: string,
13
13
  * @zh 传递给 `QRCode.toDataURL` 的选项
14
14
  * @en Options passed to `QRCode.toDataURL`
15
15
  */
16
- options?: QRCode.QRCodeToDataURLOptions) => UseQRCodeReturn;
16
+ options?: QRCodeToDataURLOptions) => UseQRCodeReturn;
17
17
  /**
18
18
  * @title UseQRCodeReturn
19
19
  */
@@ -1,4 +1,4 @@
1
- import QRCode from 'qrcode';
1
+ import QRCode, { QRCodeToDataURLOptions } from 'qrcode';
2
2
 
3
3
  /**
4
4
  * @title UseQRCode
@@ -13,7 +13,7 @@ text: string,
13
13
  * @zh 传递给 `QRCode.toDataURL` 的选项
14
14
  * @en Options passed to `QRCode.toDataURL`
15
15
  */
16
- options?: QRCode.QRCodeToDataURLOptions) => UseQRCodeReturn;
16
+ options?: QRCodeToDataURLOptions) => UseQRCodeReturn;
17
17
  /**
18
18
  * @title UseQRCodeReturn
19
19
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactuses/core",
3
- "version": "5.0.19",
3
+ "version": "5.0.20",
4
4
  "license": "Unlicense",
5
5
  "homepage": "https://www.reactuse.com/",
6
6
  "repository": {