@aiszlab/relax 1.2.28-beta.3 → 1.2.28-beta.4
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/hooks/use-focus.d.ts +2 -2
- package/dist/hooks/use-focus.mjs +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { type DOMAttributes } from 'react';
|
|
|
3
3
|
* @description
|
|
4
4
|
* hooks for focus
|
|
5
5
|
*/
|
|
6
|
-
type
|
|
6
|
+
type UseFocusBy<T> = Pick<DOMAttributes<T>, 'onFocus' | 'onBlur'> & {
|
|
7
7
|
onFocusChange?: (isFocused: boolean) => void;
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
@@ -11,5 +11,5 @@ type UseFoucsBy<T> = Pick<DOMAttributes<T>, 'onFocus' | 'onBlur'> & {
|
|
|
11
11
|
* dom attributes
|
|
12
12
|
*/
|
|
13
13
|
type UsedFocus<T> = [boolean, Required<Pick<DOMAttributes<T>, 'onFocus' | 'onBlur'>>];
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const useFocus: <T = Element>(useBy?: UseFocusBy<T> | undefined) => UsedFocus<T>;
|
|
15
15
|
export {};
|
package/dist/hooks/use-focus.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { useCallback } from 'react';
|
|
|
2
2
|
import { useBoolean } from './use-boolean.mjs';
|
|
3
3
|
import { chain } from '../utils/chain.mjs';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const useFocus = (useBy) => {
|
|
6
6
|
const [isFocused, { turnOn, turnOff }] = useBoolean(false);
|
|
7
7
|
const onFocus = useCallback(() => {
|
|
8
8
|
chain(useBy === null || useBy === void 0 ? void 0 : useBy.onFocus, turnOn, () => { var _a; return (_a = useBy === null || useBy === void 0 ? void 0 : useBy.onFocusChange) === null || _a === void 0 ? void 0 : _a.call(useBy, true); })();
|
|
@@ -13,4 +13,4 @@ const useFoucs = (useBy) => {
|
|
|
13
13
|
return [isFocused, { onFocus, onBlur }];
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export {
|
|
16
|
+
export { useFocus };
|
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export { useEvent } from './hooks/use-event';
|
|
|
20
20
|
export { useUpdateEffect } from './hooks/use-update-effect';
|
|
21
21
|
export { useCounter } from './hooks/use-counter';
|
|
22
22
|
export { useHover } from './hooks/use-hover';
|
|
23
|
-
export {
|
|
23
|
+
export { useFocus } from './hooks/use-focus';
|
|
24
24
|
/**
|
|
25
25
|
* @description
|
|
26
26
|
* is
|
package/dist/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ export { useEvent } from './hooks/use-event.mjs';
|
|
|
16
16
|
export { useUpdateEffect } from './hooks/use-update-effect.mjs';
|
|
17
17
|
export { useCounter } from './hooks/use-counter.mjs';
|
|
18
18
|
export { useHover } from './hooks/use-hover.mjs';
|
|
19
|
-
export {
|
|
19
|
+
export { useFocus } from './hooks/use-focus.mjs';
|
|
20
20
|
export { isRefable } from './is/is-refable.mjs';
|
|
21
21
|
export { isUndefined } from './is/is-undefined.mjs';
|
|
22
22
|
export { isStateGetter } from './is/is-state-getter.mjs';
|